ADR 0017: Run Traces: One Base, the Context Record and Reported Spans
Status: accepted, 2026-11-21, from the owner's decisions in the run traces research (section 7) and in the review of its design. Run traces S1–S4b and S7 and run quality S5 and S6
Status: accepted, 2026-11-21, from the owner's decisions in the run traces research (section 7) and in the review of its design. Run traces S1–S4b and S7 and run quality S5 and S6 are built; run insights (S8, designed 2026-11-29 with the owner's decisions; S8a to S8e built) adds decision 8. The designs are run traces, run context and run quality.
Context
Orquelo commits most facts of a run: observed_events, model_calls, tool_calls, session_entries, interactions and deliveries. Nothing ties them into one trace, though, and the context a run started with is gone when the run ends. Plugins and runtimes also have no way to add steps the Host cannot see. The owner asked for:
- ◆traces from the request's birth to its end, with analysis, on any channel;
- ◆one base whose output every channel consumes;
- ◆extensions that join the trace on their own;
- ◆a design verified on a real run, which was done on 2026-11-21.
Decision
- One base, one exit.
internal/host/traceis the only reader of trace records.TraceReader.Build(run, viewer)returnstrace.v1(pkg/plugin), and it is the only way a surface gets trace data. The base authorizes the viewer, resolves content and applies the rules. It emits codes and machine names, never display text. Surfaces own display: the chat/tracethrough each channel's Presentation, the HTML file, the CLI, the agent tool, and later HTTP JSON, an OpenTelemetry exporter and the daily report. - A view of committed facts. The trace is assembled from the records the Host already commits. Each record's writer completes it in the transaction that commits the fact. No tracing calls are added elsewhere, and the base owns no table.
- The context record.
- ◆Zone map: runtimes declare
ChatRequest.Zones: each zone's range in the request, and its parts with the runtime's decisions (included, cut, cleared, deferred, truncated, omitted) and their reasons. - ◆Measured by the Host: the Host measures each zone's tokens and digest from the request it actually sends, and stores them in
model_inputs. - ◆Zone text: bytes kept nowhere else go to
context_textsonce per tenant, user and digest, for every run (the owner's decision). - ◆Mismatch: a map that does not cover its request is dropped and logged, and the call goes on.
- ◆Display: surfaces show the zones formatted: messages by role, tools with their parameters, and arguments and results re-indented, with long text folded.
- Reported spans. Runtimes and tools may report steps the Host cannot see, through
ReportSpanson the host of their current call (the optional interfaceSpanReporter).
- ◆Placement: the Host attaches them under the reporting call and clamps their times into it.
- ◆Limits: at most 200 per call and 2 KiB of attributes each. Attributes are scalars under the plugin's prefix, references point to artifacts, and nothing carries content.
- ◆Labeling: each is marked
reported_byits instance and stored inreported_spans. - ◆Refusal: a report that breaks a rule is dropped and logged, and the call goes on.
- ◆Kinds:
externalorx-<plugin>.<name>. Surfaces show a kind they do not know in a neutral style, named by the plugin's message key.
- Visibility. A person sees the traces of their own direct-chat runs, and admins see every run of their tenant. Only admins see a group run's trace, and only in a direct chat. Content follows session visibility, and secrets never appear. Traces go with their runs (retention,
sessions forget). - Time. One
timezoneper Host (the owner's decision). Machine times stay in UTC. - Evaluators (added on 2026-11-27 for run quality S6). A plugin with the
evaluatorrole scores finished runs:Evaluate(EvaluationInput) → []ScoreInput(evaluator/evaluatefor process plugins), for the runtimes that list the instance inuses. The Host owns the rest: it samples by a hash of the run id (the instance'ssample, a fraction), leaves group runs out whengroupsis false, requires theconversationgrant, passes the run's input, reply and trace cut for a model, and keeps only scores of keys the manifest declares (scores:), within their ranges and citing spans of the trace. An evaluator rides the observers' durable cursor and retries, never changes the run, and its model calls are audited with purposejudge. People's ratings (TransportHost.Rate, theratedecision) are stored beside its scores by the Host's scores service, and the trace base reads both.
- Stream kinds (added on 2026-11-29 for run insights S8e; built the same day). A streamed piece carries its kind:
text,reasoningortool_args(Delta; the protocol'smodel/deltagains an optionalkindthat defaults totext). The Host's caller times the first piece of any kind and each kind's first and last piece, and its audit keeps them with the call; callers that show streamed text take thetextpieces only.
Consequences
- ◆Contract additions, all optional:
trace.v1(withscoressince run quality S6),Output.Report,ChatRequest.Zones, the optional host interfaceSpanReporterwithhost/report_spans,Manager.Trace, thetraceandratedecisions,TransportHost.Rate(host/rate), and theevaluatorrole with the manifest'sscores:. Model and process plugins that ignore them are unaffected, and the protocol schemas are regenerated. - ◆Storage grows:
model_inputsper model call,context_textsper run and epoch (a few tens of KB per run),reported_spans, and the completed times. All of it follows run retention andsessions forget. - ◆Automatic coverage: everything that passes through the Host appears in traces without work from the plugin. Only steps a plugin runs itself need a report, and those are labeled as the plugin's claims.
- ◆No channel specifics in the base: a new channel or surface needs no change to it.
- ◆Older runs stay partial: a run recorded before slices S3 and S4 has no first-response times, context record or background calls, and its spans keep estimated starts.
- ◆ADR count: this is the seventeenth ADR, beyond the v1 guideline of about ten; on 2026-11-21 the owner asked for an ADR for reported spans.