Applies to:
- Plan -
- Deployment -
Summary
Dataset rows expose core evaluation fields likeinput, expected, metadata, and tags. There is no top-level output field. Put the model’s runtime output into a namespaced metadata key on the span you add to the dataset, such as metadata.run_output. For trace-level adds from Logs, put it on the root span.
What is happening
Datasets are designed for stable test cases and exposeinput, expected, metadata, and tags. The UI action that adds a trace to a dataset maps span fields into dataset row fields, commonly span input -> dataset input and span output -> dataset expected.
Metadata from the span you add is copied into dataset.metadata. When you add a trace row from Logs, that is typically the root span, so child-span outputs are not included unless you also copy them onto that span or add the child span/programmatic row explicitly.
If you need the model generation that occurred at runtime in the dataset export, it must be present in the added span’s metadata or added when creating the dataset row.
Fix or suggestion
Option 1: Store runtime output in dataset metadata (recommended)
- On the span you plan to add to the dataset, write the generation output to a namespaced metadata key, e.g.
metadata.run_output. For trace-level adds from Logs, put it on the root span. - If you use traced functions, the return value can populate the span’s
output; also logmetadata.run_outputif you need it in dataset exports. - With OpenTelemetry, set
braintrust.outputorgen_ai.completionfor the span if you want Braintrust to populate spanoutput. Also setbraintrust.metadata.run_outputfor dataset exporting. - Use the UI Add to dataset action. The dataset export will include
metadata.run_output.
span.log):
- Ensure you write
metadata.run_outputon the span before clicking Add to dataset. - If the model output lives in a child span, copy it into the root span’s metadata for trace-level adds from Logs, or include
span_id/root_span_idif you need linkage.
Option 2: Programmatic insert or export logs and spans
- Export Logs or Spans: use logs or spans export if you want raw runtime outputs preserved without touching datasets.
- Dataset Insert API: create dataset rows programmatically and include
run_outputin metadata along with span linkage fields likespan_idandroot_span_id.
How to confirm it worked
- Export the dataset JSON and verify each row’s
metadatacontainsrun_outputwith the expected generation. - In the UI, open the dataset row and confirm
metadata.run_outputappears. - Open the source trace and verify the relevant span shows the output value or metadata key.
Notes
- Use
expectedfor the durable ground-truth label. - Use
metadata.run_outputfor the model’s runtime generation to avoid overwritingexpected. - When adding a trace row from Logs, the UI captures the root span. If you rely on child-span outputs, copy them into root metadata or use the API/custom mapping.