Attach output references
Explain model-returned identifiers with text or structured JSON.
When a model selects an identifier, attach a dictionary explaining those IDs. The console can render the matching output as readable text or structured JSON.
let response = try await session.respond(
to: "Choose C1 or C2 as the clearest explanation of durable delivery.",
recording: .init(outputReferences: [
"C1": "Save locally, then upload when delivery is available.",
"C2": .object([
"title": .string("Durable outbox"),
"description": .string("Pending spans survive an app restart."),
"tags": .array([.string("delivery"), .string("offline")])
])
])
)The dictionary values use LedgeOutputReference: either a string or a JSON
object. Nested object fields can contain arbitrary JSON; root-level arrays,
numbers, and booleans are not reference values.
What the viewer changes
Reference enrichment changes display only. Original input, output, and transcript capture retain the model's identifiers. Matching is exact, including complete lines in text responses; references do not perform fuzzy replacement in prose.
References are scoped to one span and recorded on success, failure, or
cancellation. A later request without references does not inherit them. Manual
provider adapters pass references through startSpan(recording:).
See capture types.