Skip to content

The record contract

View as Markdown

weft’s observability pipeline sends every run as OpenTelemetry spans and log records, and obsdb reads them back into a run. This page lists every span kind and attribute, every weft.record kind with its fields and position, the identity chain that joins them, the content values, the GenAI conventions weft writes, the run row a reader derives, and how Studio builds a run from stock GenAI spans. Use it to query weft data in your own backend, or to make a non-Go agent emit records Studio reads as its own.

The authority is weft’s docs/record-contract.md at v0.20.2. This page restates it and checks it against the code. Where they disagree, this page follows the code and says so in a note. obsdb/model.go and TestRecordContractDocNames pin the names: the test fails when the contract names a weft.* or gen_ai.* key no emitter or reader spells. A change to a name, a kind or a rule is a schema change that needs an ADR amendment and regenerated fixtures. How to send the records somewhere is in Use your own OpenTelemetry SDK and Record every run.

Section of docs/record-contract.mdOn this page
The record contract (intro)This page’s opening and Conformance fixtures
1. The transportTransport
2. The identity chainIdentity chain
3. Spans: invoke_agent, chat, attempt, execute_toolSpans
4. Log records: event and delta, messages, request/prompt/tools, raw, compaction, heartbeatLog records
App log records, the slog bridgeApp log records
5. Content policyContent policy
6. The run row: what a reader derivesThe run row
7. BadgesBadges, and Badges and holes
8. The GenAI semantic conventionsGenAI semantic conventions
9. Deriving a run from stock spansDeriving a run from stock spans
10. The conformance fixturesConformance fixtures

The contract document arrived in 0.15.0 as one spec. Before that, ADR 0016 (spans), ADR 0024 (records, identity) and ADR 0028 (the request record, the compaction view, the badges) held it; they keep the reasons.

ItemRule
SignalsSpans through the trace API, log records through the Logs API, exported as OTLP
Studio’s receiverPOST /v1/traces and POST /v1/logs, OTLP/HTTP protobuf or JSON, optionally gzip, at most 16 MiB decompressed per request
Ids on OTLP/JSONLowercase hex: traceId 32 digits, spanId 16
What is weft’sA span or record that carries weft.run.id. Anything else is stored as it came: other spans appear in the trace view, other log records become the run’s app logs when they share its spans. They never become a run, except by derivation
Integer valuesA reader accepts an int, a double or a decimal string. Run metadata is stamped as strings, so weft.turn arrives as "3"
Boolean flagstrue or the string "true". weft.playground arrives as "true"; readers take that spelling since 0.8.0
Resourceservice.name (the run row’s service) and weft.version (the framework release that built the pipeline)
Instrumentation scopegithub.com/weftgo/weft/core for spans, weft records and heartbeats, with the core’s version for spans and weft records; heartbeats, the thread marker and bridged lines carry no scope version. A thread compaction marker comes from github.com/weftgo/weft/thread; a bridged slog line from github.com/weftgo/weft/otel/slog
Trace and span idsCorrelation, not identity: zero without an SDK, missing when sampled out. Every join is on a weft id

Contract and code. The contract document names the records’ logger github.com/weftgo/weft (record-contract.md:358-359); the code names it github.com/weftgo/weft/core (core/observe.go:44, core/agent.go:715), as the contract’s own §1 says (record-contract.md:69). The same §1 gives one scope for everything; the compaction marker’s is github.com/weftgo/weft/thread (thread/compactmarker.go:41).

Every span and record of a run carries these attributes. The run’s metadata rides every span and record verbatim.

LinkAttributeTypeMinted byNotes
runweft.run.idstringthe core32 lowercase hex digits for a plain run; <session>-t<n> for a thread turn; <parent>/<step>/<call id> for a Subagent child; or your own through weft.RunID. Do not start your own with otel-, the derived-run prefix: nothing enforces it, and an id of the exact shape otel-<32 hex>-<16 hex> would be read as a derived run’s
parent runweft.parent.run.idstringthe coreOn the invoke_agent span and run_start record of a core.Subagent child only
parent callweft.parent.call.idstringthe coreThe parent’s tool call the child ran under (its gen_ai.tool.call.id)
caller runweft.caller.run.id, weft.caller.call.idstringthe coreSince 0.20.0 also on a run started on a context weft.WithCaller named, with weft.caller.remote "true". That caller is in another process, such as an MCP client under mcp.CallerMeta (Link a served run to its caller). Readers never place a run by a remote link: the run stays top-level, and obsdb leaves its caller_run_id empty. Since 0.18.0, on any other run started on a tool call’s context: a thread/pool child session’s turn, another agent’s Generate in a handler (whose id stays random), a run under a Subagent child’s own tool call. A link, not parenthood. A run started inside a run’s machinery (its model chain, PrepareStep, a tap, OnRunEnd) carries neither. Before 0.18.0 these runs carried weft.parent.*
sessionweft.session.idstringthread, or the app through metadataMirrored as gen_ai.conversation.id and session.id on every span and record the core emits, and on heartbeats; not on the compaction marker
turnweft.turnint, as a stringthreadThe turn number the run id was minted from
public idweft.public_idstringthread.PublicID, weft/runtime (playground runs), or the appThe browser-facing id a panel token is scoped to
agentgen_ai.agent.namestringthe coreAbsent for an unnamed agent
agent configweft.manifest.hash, weft.versionstringthe coreOn the invoke_agent span and the run_start record
stepweft.step.indexintthe core0-based model-call ordinal within the run
tool callweft.tool.seq, gen_ai.tool.call.idint, stringthe coreOn the span and the tool_start record, weft.tool.seq is the tool_start event’s seq
event, deltaweft.event.pos, weft.delta.posintthe coreTwo separate counters
end userenduser.id, mirrored as user.idstringthe app through metadataAttribution, not part of the chain
flowweft.flowstringscope.Header (the scope’s flow, else the request’s own Weft-Scope), scope.WithFlow, or the app through metadataSince 0.20.0. Studio’s flow= filters on it (runs, sessions, search, traces, live), and the devtools panel narrows its list by it. A flow narrows a view, never grants one. A scope’s tag.<k>=<v> pairs are read the same way, as metadata the caller wrote; a tag scope, such as a panel token minted with tags, is only as tight as the app’s own tagging

Contract and code. The contract puts the parent attributes on a Subagent child’s span and run_start only (record-contract.md:86, 88). The code stamps both whenever the run’s context holds a tool call (core/loop.go:139-139, core/observe.go:1258-1259), so a plain Generate started inside a tool handler carries them too, under its own random 32-hex id.

Contract and code. The contract says weft.tool.seq is the tool_start event’s seq everywhere (record-contract.md:95, 435). The code stamps a tool_finish record with the tool_finish event’s own seq (core/observe.go:1250): in one scratch run, for illustration, a call’s span and tool_start carried 1 and its tool_finish 3; the numbers depend on the run. Pair a finish with its start on gen_ai.tool.call.id, not on weft.tool.seq.

Subagent children. A weft.Subagent tool runs a child with the id <parent run id>/<step>/<call id>, or <parent run id>/resume/<call id> when the call ran under Approve. Studio’s cost split subtracts exactly those children’s usage from the parent’s, because the parent’s own usage includes every child’s. The link is still explicit (weft.parent.run.id, weft.parent.call.id), and a reader never parses an id to find a parent. The child’s invoke_agent span is a child of the parent’s execute_tool span. A thread/pool child is a separate session: no / in its id, no parent attributes, linked by session metadata.

These are run metadata, so they are strings on every span and record of the run. The last column says where a reader puts each: a run-row column, or the row’s meta map.

AttributeSet byMeaningRun row
weft.session.titlethread (SetInfo’s title)The session’s title as the turn started; absent before one is set. A label, not content: it survives a content-off destination. A fork carries the newest title on the copied pathmeta; the session row’s title
weft.session.forked_fromthread (Fork)<origin session>#<entry id>meta
weft.session.parentthread/poolThe parent session of a pool childmeta
weft.session.parent_callthread/poolThe parent’s tool call that spawned it, when knownmeta
weft.turn.parentthreadSince 0.18.0, the turn whose line this turn continues (its weft.turn), set only when that is not the session’s newest turn: the first turn after a navigation (Branch, Uncompact, a rollback, an overflow re-run’s branch-back) took the leaf off the newest line. "0" when the line it continues holds no turn; absent for a linear turnmeta
weft.session.branchthreadSince 0.18.0, the branch the turn’s line descends from: the label (Label) on the entry the newest navigation on its path went to, else that navigation’s leaf entry id. On every turn of that line; absent on a line no navigation made. A failed send’s leaf move back (LeafEntry.Abandoned) is no navigationmeta
weft.playgroundweft/runtime"true" on a run Studio’s playground started; never part of a sessioncolumn playground
weft.playground.commandweft/runtimeThe playground command idmeta
weft.playground.actorweft/runtimeWho issued the command, from the caller’s identity at POST /api/playground/runs: server (the server token), panel:<public id> (a panel token) or local (setup A’s open API)meta
weft.playground.breakpointsweft/runtimeThe tool names a playground run parks at, comma-joined and sorted: a park_on park named there reads as a breakpoint, not an approval gatemeta
weft.experiment.idweft/runtimeThe saved experiment the run belongs tocolumn experiment_id
weft.forked_fromweft/runtime<source run>#<from step>: the run this replay continuescolumn forked_from
weft.replay.viewweft/runtimeA replay from step N > 0: transcript, compacted:<index>, derived or unknownmeta
weft.editsweft/runtimeThe transcript edits a replay appliedmeta
weft.page_urlweft/scopeThe app page the run started from, sanitisedmeta
weft.approval.actorthread (each decision’s key id, else its Who), weft/runtime (panel:<public id>, server, local), or the appWho decided the calls this run resumes, distinct actors in call order, comma-joined. Metadata survives content-off and goes to every destination, so put an opaque id here, not an email. thread sets it on every resume turn and "" on every othermeta
enduser.idthe app through metadataThe end usermeta (its mirror user.id is not)

Empty means none. Metadata rides the context into every run started under it, so a session turn started inside another run’s tool handler would inherit that run’s pairs. thread therefore sets every key a session owns (weft.public_id, weft.session.title, weft.session.forked_from, weft.session.parent, weft.session.parent_call) on each of its runs, "" when it has none. The core reads "" as none: it removes the inherited pair, which then appears on no span or record. Readers hold the same rule: obsdb.MetaOf drops an empty string, and a public_id of "" matches no scope.

obsdb.MetaOf keeps every string attribute of any span or record of the run, merged, whose key is not on one closed list, obsdb.NonMetaKeys. Your own metadata keys, enduser.id, the meta rows above and any other weft. key (a module’s own) land there. A non-string attribute off the list is dropped on SQLite and stringified on ClickHouse.

Never in metaKeys
Identityweft.run.id, weft.parent.run.id, weft.parent.call.id, weft.session.id, weft.public_id, weft.turn, gen_ai.agent.name
Run-row columnsweft.playground, weft.experiment.id, weft.forked_from, weft.resumed_from, weft.version, weft.manifest.hash, weft.instructions.hash, weft.run.stopped_by, weft.cancel.cause
Record keysweft.record, weft.event.type, weft.event.pos, weft.delta.pos, weft.messages.index, weft.messages.count, weft.messages.input, weft.messages.reason, weft.messages.from_seq, weft.messages.to_seq, weft.request.index, weft.prompt.index, weft.tools.index, weft.raw.index, weft.system.hash, weft.catalog.hash, weft.compaction.hash, weft.compaction.scope, weft.content, weft.content.truncated_bytes, weft.step.index, weft.tool.seq, weft.attempt.index, weft.latency_ms, weft.records.dropped, weft.logs.bridged
Span keysweft.run.steps, weft.run.pending, weft.run.denied, weft.run.stop_reason, weft.run.events, weft.run.messages, weft.stop.raw, weft.model.tool_calls, weft.stream, weft.ttft_ms, weft.attempt.retry_after_ms, weft.attempt.layer, weft.attempt.wait_ms, http.response.status_code, weft.tool.approved, weft.tool.pending, weft.tool.pending.source, weft.tool.timeout_ms, weft.tool.queue_ms, weft.subagent.pending, weft.tool.result_bytes, weft.tool.truncated_bytes, weft.tool.input_error, weft.tool.retry, weft.tool.retry_budget, weft.panic.layer, weft.output.submitted, weft.metadata.dropped, weft.tap.panics, weft.resume.calls, weft.tool.denied, weft.tool.denied_kind, weft.override.hash and every weft.override.* key
GenAI keysgen_ai.operation.name, gen_ai.provider.name, gen_ai.request.model, gen_ai.response.model, gen_ai.response.finish_reasons, the five gen_ai.usage.* keys, gen_ai.tool.name, gen_ai.tool.call.id, error.type
Mirrorsgen_ai.conversation.id, session.id, user.id

Contract and code. The contract calls its list exact (record-contract.md:175-185) but leaves out keys the code excludes too: weft.run.events, weft.run.messages, weft.attempt.layer, weft.attempt.wait_ms, http.response.status_code, weft.tool.pending.source, weft.tool.timeout_ms, weft.tool.queue_ms, weft.subagent.pending and weft.output.submitted, beside the ones its prose names elsewhere (obsdb/model.go:338-452). The table above is the code’s list.

On ClickHouse a run’s meta is the greatest of its rows’ JSON maps compared as strings, not a merge. The core’s spans and records carry the same map, so this only shows when a reopened thread session emits a compaction marker for a run it did not see: that marker’s map can win and drop your pairs from the run’s ClickHouse meta.

Four span kinds, named <operation> <name> by the GenAI conventions, and a fifth, layer, only under the development detail level. Spans carry ids, names, counts, durations, reasons and error types, never content (ADR 0016). Every weft span carries weft.run.id and the run’s metadata.

SpanNameKindParentOne per
invoke_agentinvoke_agent <agent>, or invoke_agentInternalnone; a Subagent child’s is the parent’s execute_toolrun
chatchat <model>Clientinvoke_agentmodel call (a step)
attemptattemptClientchattry inside a model call, when the model chain reports attempts
execute_toolexecute_tool <tool>Internalinvoke_agenttool call, and a zero-length one per call a resume denied
layerlayer <name>Internalthe layer outside it, else the chat or execute_tool spanmiddleware layer per call, under otel.DevDetail only (since 0.20.0; layer)

The root of the run’s tree. It ends when the run does, however the run ends. Status Ok on success (a run parked at an approval succeeded); Error with the error text as the description and a recorded exception on failure.

AttributeTypeWhen
gen_ai.operation.namestring invoke_agentAlways
weft.run.idstringAlways
gen_ai.agent.namestringNamed agents
gen_ai.provider.namestringThe model reports a provider: openai, anthropic, gcp.gemini, else verbatim
gen_ai.request.modelstringThe model reports a name
weft.instructions.hashstring, sha256 hexAlways since 0.10.0; the empty string’s hash when there are no instructions
weft.parent.run.id, weft.parent.call.idstringSubagent children
weft.caller.run.id, weft.caller.call.idstringOther runs started on a tool call’s context (pool child turns, nested Generates), and runs started on a weft.WithCaller context
weft.caller.remotestring "true"A weft.WithCaller link: a caller in another process, which readers never place a run by. The span also carries an OpenTelemetry link to the caller’s span when one was given
weft.manifest.hashstringNamed agents
weft.versionstringAlways
weft.logs.bridgedintAt start, while the pipeline has a live slog bridge, on the copy a destination that takes app logs exports: the lines bridged so far. Its presence means “this store holds the run’s bridged lines”. Set by weft/otel, not the core
weft.metadata.droppedintThe metadata limits dropped pairs: the run’s truncated hole, cause metadata_cap
weft.resumed_fromstringThe run this one resumes, as weft.ResumeOf named it. thread and weft/runtime always pass it; an app resuming a plain Generate passes the parked RunResult.ID
weft.resume.callsstringA run fed decisions: each parked call in call order as <call id>=<kind>, comma-joined, kind approved, denied, resolved or no_decision. The decision, not the outcome. Capped at 32 calls, then ,…+k. thread writes an undecided call as an explicit deny, so only a plain core resume reads no_decision
weft.override.hashstring, sha256 hexA run option changed the agent’s configuration: the experiment fingerprint
weft.override.instructionsbool trueThe instructions were replaced; the text is never on a span
weft.override.toolsstring, sorted names, comma-joinedOnlyTools
weft.override.modelstring <provider>/<name>, or the bare nameUseModel
weft.override.park_on, weft.override.park_all_exceptstringParkOn, ParkAllExcept
weft.override.thinkingstringA per-run thinking level
weft.override.tool_choicestringA per-run tool choice: auto, any, none, tool:<name> (a named choice with no name reads tool)
weft.override.paramsstring, JSONPer-run sampling params: the replacement’s set knobs, plus null for each knob the agent’s default set that the replacement leaves unset, such as {"temperature":0.4,"top_p":null}. The hash takes the set knobs alone
weft.override.max_steps, weft.override.parallelismintLowered per run
gen_ai.usage.input_tokens, gen_ai.usage.output_tokensintAt end: run totals, Subagent children included
gen_ai.usage.cache_read.input_tokens, gen_ai.usage.cache_creation.input_tokens, gen_ai.usage.reasoning.output_tokensintAt end, each only when non-zero
weft.run.stepsintAt end
weft.run.eventsintAt end, always: the durable event records the run handed to its LoggerProvider, 0 with no logger. A reader compares it with what it stored
weft.run.messagesintAt end, always: growth messages records emitted (views excluded), 0 with content capture off or no logger
weft.run.pendingintAt end, when calls are parked for approval
weft.output.typestringAt start, an agent built with Output only: the type its typed answer decodes into, package-qualified (main.Invoice; a pointer’s element; struct for an anonymous struct), at most 128 bytes cut at a rune boundary. The manifest’s submit_output tool carries it as output_type
weft.output.submittedboolAt end, an agent built with Output only: true when the run ended with a valid submit_output call, false when it did not (the case GenerateAs answers ErrNoOutput)
weft.run.deniedintAt end, on a resuming run that denied parked calls: explicit denies and calls left undecided. Not a Resolve, not an mw.Allow refusal (that has its own span)
weft.tap.panicsintAt end, when observers panicked and were contained: taps, OnMessages observers, a record or report that failed to build. OnRunEnd panics are not counted here
weft.run.stop_reasonstringAt end: the last step’s stop, tool_calls or max_tokens
weft.run.stopped_bystringAt end, what ended the run: a fired StopWhen condition’s name (has_tool_call:<tools>, step_count_is:N, output_submitted, a custom condition’s String(), else custom), final_answer, parked, max_steps, usage_limit, loop_detected, model_retries_exceeded, canceled. Absent on a failure no control decided. On a failed run this span is its only carrier
weft.cancel.causestringAt end, a canceled run whose cause names itself: thread.interrupted, thread.closed, studio.cancel, app.shutdown, any weft.CancelCause kind, or deadline. Absent for a plain cancel
error.typestringOn failure, a closed table: max_steps, usage_limit, loop_detected, model_retries_exceeded, model_contract, duplicate_tool, nil_tool, no_output, stream_idle, unsupported, model_requests_denied, run_panicked, model_error (a provider failure, the default), context.Canceled, context.DeadlineExceeded. A run row reads the last two as cancelled

Started after PrepareStep built the request, ended when the stream is consumed. Model middleware such as retry and fallback runs inside it. Status Ok on success; Error with the error text, a recorded exception and error.type on failure.

AttributeTypeWhen
gen_ai.operation.namestring chatAlways
weft.run.id, weft.step.indexstring, intAlways
weft.streambool trueAlways
gen_ai.provider.name, gen_ai.request.modelstringThe model the call asked
gen_ai.usage.input_tokens, gen_ai.usage.output_tokens, the three splitsintAt end: this call’s usage, splits only when non-zero
gen_ai.response.finish_reasonsstring array, one elementAt end: stop, tool_calls or max_tokens
weft.stop.rawstringAt end, the vendor’s raw reason when set
weft.model.tool_callsintAt end: tool calls requested
gen_ai.response.modelstringAt end, a call that finished: the model that answered
weft.ttft_msintAt end, when a TextDelta or ToolArgsDelta arrived: ms to the first one (reasoning deltas don’t count); absent otherwise
error.typestringOn failure
event weft.repairgen_ai.tool.call.id, weft.repair.kind, weft.repair.bytes_before, weft.repair.bytes_afterSince 0.20.0, one per tool call whose arguments a model middleware repaired (Reporter.Repair, mw.RepairJSON), at the moment it did. weft.repair.kind is fence (a Markdown fence stripped), unterminated (open strings, objects or arrays closed), fence+unterminated, or trim (whitespace or an empty argument made {}). The two byte counts are ints. The call’s execute_tool span carries weft.tool.args_repaired
event weft.repair, under otel.DevDetailweft.repair.original, weft.repair.original_cutWith the run’s content on: the arguments as the model sent them, capped at 4 KiB on a rune boundary. weft.repair.original_cut (int) counts the rest, only when cut. Content: only Local and Studio destinations with content on receive them; an OTLP preset gets the event without them

Present only when the model chain reports attempts through weft.ReportFromContext: mw.Retry, mw.Fallback, or an adapter reporting its SDK’s retries. It carries no gen_ai.operation.name.

AttributeTypeWhen
weft.run.id, weft.step.indexstring, intAlways
weft.attempt.indexintAlways: 1-based, numbered per model call
gen_ai.provider.name, gen_ai.request.modelstringThe attempt names them
weft.attempt.retry_after_msintThe provider asked to wait
weft.attempt.layerstringfallback on a request mw.Fallback sent to a backup: the marker the fallbacks counter keys on; retry on one mw.Retry sent again after a failure (since 0.20.0). A backup that reports its own attempts (a mw.Retry around it) marks every request it sends fallback, its retries included. Absent on a first try
weft.attempt.giveup_reasonstringOn the attempt after which a retrying layer stopped: budget, not_retryable or retry_after_too_long
weft.attempt.wait_msintThe backoff the reporting layer slept before sending this attempt (mw.Retry’s delay, a retry-after it honoured), rounded up, never 0. Absent on an attempt sent at once: a first try, a fallback’s backup
http.response.status_codeintThe provider’s HTTP status, when the reporter found one (mw.HTTPStatus reads it off the error)
gen_ai.response.modelstringOn success
error.typestringOn failure, with status Error. Since 0.20.0 classified: rate_limit (429), overloaded (503, 529), timeout (408, 504, a transport timeout), auth (401, 403), server_error (any other 5xx), context_overflow, the run’s own failure types as it reads them, else model_error

Studio’s live stream also sends each attempt span as an attempt frame the moment it lands (/api/live?kinds=attempt). That is a reading of this span, not a record: nothing new is emitted or stored, and the frame is never backfilled.

Status Ok for a result; Error with an empty description for an error result (the result text is content); unset for a call parked for approval. A Resolved call has no span: nothing executed.

AttributeTypeWhen
gen_ai.operation.namestring execute_toolAlways
gen_ai.tool.name, gen_ai.tool.call.idstringAlways
weft.run.id, weft.step.index, weft.tool.seqstring, int, intAlways; a denied call’s span has no weft.tool.seq and carries weft.step.index 0
weft.tool.approvedbool trueA call resumed by Approve
weft.tool.approved_by, weft.grant.idstring, stringSince 0.18.0, an approved call’s provenance as weft.ApproveBy named it; absent for a plain Approve. thread passes user (Decide, DecideSigned), grant (a standing grant matched, weft.grant.id its entry id), approver, quorum or policy on every resume it runs; weft/runtime passes runtime on a playground approval. Ids and enums, never who by name (that is the thread record’s content.who); span attributes, never meta
weft.tool.denied, weft.tool.denied_kindbool true, stringA parked call the resume denied: denied (Deny) or no_decision (left undecided). The span is zero-length at the moment the resume decided, carries weft.step.index 0 and no weft.tool.seq, error.type DENIED, status Error, never the reason. Since 0.16.0
weft.tool.result_bytesintAt end, a successful result only: the length the model sees, after the result cap
weft.tool.pendingbool trueAt end: the call was parked for approval
weft.tool.pending.sourcestringBeside weft.tool.pending, why it parked: approval (RequireApproval), park_on (the run’s ParkOn, which is how playground breakpoints park), park_source (an agent ParkSource), park_all_except, middleware (an error wrapping ErrApprovalRequired)
weft.tool.timeout_msintAt start, when a deadline is in force: the call’s Timeout, rounded up (a sub-millisecond deadline reads 1)
weft.tool.queue_msintAt start, a call that waited behind a Sequential barrier or for a Parallelism slot: the wait, rounded up, never 0
weft.subagent.pendingstringerror.type SUBAGENT_PENDING: the parked child’s pending calls by tool name, comma-joined
weft.tool.truncated_bytesintAt end, a result or error result the result cap (MaxResultBytes) cut: the bytes removed, the number in the model’s …[truncated N bytes] marker
error.typestringAn error result, in this order: the ToolError code (INVALID_INPUT, NO_SUCH_TOOL, DENIED from a policy middleware, RETRY, your own); timeout; panic; context.Canceled or context.DeadlineExceeded. Then the error’s own ErrorType() string when one in its chain declares it, else tool_error. weft/mcp declares mcp_transport (no answer), mcp_rpc_error (a JSON-RPC error answer, since 0.20.0) and mcp_tool_error (an isError result)
weft.tool.retry, weft.tool.retry_budgetint, interror.type RETRY (weft.ModelRetry) counted by the loop: the tool’s consecutive RETRY count (a success resets it) and the run’s MaxModelRetries. On the span only, not on tool_finish. Absent on a resumed approved call’s RETRY
weft.panic.layerstringerror.type panic: handler or middleware
weft.tool.input_errorstringerror.type INVALID_INPUT from the loop’s own decode: strict (an undeclared field under StrictInput), schema (wrong type or shape), syntax (not one JSON value)
event weft.panicweft.panic.stack, weft.panic.stack_cuterror.type panic, under otel.DevDetail with content on: the panicking goroutine’s stack, capped at 16 KiB, the rest counted. Only Local and Studio destinations with content on receive it
weft.tool.args_repairedbool trueAt start: a model middleware repaired the call’s arguments (Reporter.Repair, mw.RepairJSON); the chat span’s weft.repair event says how
weft.tool.originstringAt start, a tool that is not local: subagent, mcp:<server> (an import under mcp.Server(name); mcp without it), or your own Origin word. Never an address
weft.tool.denied_bystringAn error result a tool layer reported refusing (ToolReporter.Denied): allow for mw.Allow. On a resume’s denied span: approval, or grant with weft.grant.id (weft.DenyBy)
weft.tool.error_maskedstringAn error result a tool layer replaced (ToolReporter.Masked, mw.MapErrors): the hidden error’s kind, never its text: its ErrorKind(), a context error’s name, its ErrorType(), a ToolError code, a standard sentinel such as io.EOF or fs.ErrNotExist, else its Go type (Studio and the devtools panel draw *errors.errorString as “plain error” and *errors.joinError or *fmt.wrapErrors as “joined errors”; the value recorded is the type)

One span per WrapModel or WrapTools layer per call, named layer <name>, kind Internal, under otel.DevDetail() alone: the development gate (WEFT_ENV=dev, or otel.DevMode()), and only the Local and Studio destinations with content on receive it. Never by default. A layer span’s parent is the layer outside it, the outermost’s the chat or execute_tool span (The onion in the record). Spans your code starts inside a layer, such as a handler’s or an attempt, keep the call’s span as their parent, so a destination that drops layer spans orphans nothing. A layer that returned an error has status Error, except a parked call’s ErrApprovalRequired.

AttributeTypeWhen
weft.layer.namestringAlways: the layer’s name as the manifest names it (mw.Retry, a type, a function)
weft.layer.kindstringAlways: model or tool
weft.layer.indexintAlways: its place outer to inner, 0 the outermost (a tool’s own WrapTools numbered after the agent’s)
weft.run.id, weft.step.indexstring, intAlways
gen_ai.tool.name, gen_ai.tool.call.idstringA tool layer
error.typestringThe layer returned an error: a model layer the chat span’s classification; a tool layer the ToolError’s code, a context error’s name, else tool_error. panic when a panic went through the layer. Status Error

Every weft record is one OTel log record: logger github.com/weftgo/weft/core, an EventName, a JSON string body, the emission time, severity INFO (WARN for a tool_finish with is_error) and attributes. Every record but the heartbeat carries weft.record (its kind, mirroring the EventName for backends that drop it), weft.run.id, gen_ai.agent.name when named, weft.content, and the run’s metadata.

weft.recordEventNamePosition attributeCount per runBodyTrace context
eventweft.eventweft.event.posone per durable eventthe event’s wire JSONinvoke_agent
deltaweft.deltaweft.delta.posone per streamed deltathe delta’s wire JSON; counted, never storedinvoke_agent
messagesweft.messagesweft.messages.indexone per transcript batch, plus compaction viewsa JSON array of messagesinvoke_agent for growth; chat for a view
requestweft.requestweft.request.indexone per model-call attemptthe request objectchat
promptweft.promptweft.prompt.indexone per distinct system hash{"hash", "text"}chat
toolsweft.toolsweft.tools.indexone per distinct catalog hash{"hash", "tools": [...]}chat
rawweft.rawweft.raw.indexone per HTTP exchange, development onlythe wire request and responsechat
compactionweft.compactionnone: the store keys it on weft.compaction.hashone per thread compactionthe session markerthe run it is filed under, when the Session saw that run; none after a reopen. It describes no span
threadweft.thread.<kind>none: a store derives it from the bodyone per fact of a session’s state log (since 0.18.0){kind, session, at, …, content?}the run it is filed under; none when held to Close
heartbeatweft.heartbeatnoneevery 10 s per open runnone; never storednone

The app log record (slog bridge) is a log record too, but no weft.record kind: it carries neither weft.record nor weft.run.id. See App log records.

Which span a record names. A record carries the trace and span id of the context it was emitted on, not of the span it describes: a tool_start does not carry its execute_tool span’s ids, nor a step_finish its chat span’s. Join records to spans, and records to each other, on weft.run.id, weft.step.index and gen_ai.tool.call.id, never on span ids.

The storage key. A store is idempotent on (run id, kind, position), so a retried export is a no-op. Each positioned kind has its own per-run counter from 0 without gaps: a hole below the high-water mark is a lost record (gap). A positioned record without its position attribute comes only from a malformed producer; it is stored at position -1 and readers skip it. A delta without one counts as position 0. The compaction and heartbeat kinds have no position attribute: a store derives a marker’s position from its hash, and never stores a heartbeat.

The body is the core’s event wire, discriminated by type; weft.event.type repeats it. Durable events, on weft.event.pos:

weft.event.typeBody fieldsExtra attributes
run_startid, model {provider, name}, agent, instructions_hash (informational: readers take the attribute)weft.parent.run.id and weft.parent.call.id (Subagent children), weft.caller.run.id and weft.caller.call.id (other runs started on a tool call’s context), weft.manifest.hash (named agents), weft.instructions.hash, weft.version, weft.resumed_from and weft.resume.calls (a resume)
step_startrun_id, indexweft.step.index
tool_startrun_id, seq, call_id, name, argsweft.tool.seq, gen_ai.tool.call.id, gen_ai.tool.name
tool_finishrun_id, seq, call_id, name, content, is_errorthe same three keys (weft.tool.seq is this event’s own seq); weft.tool.truncated_bytes when the result cap cut the content
step_finishrun_id, index, reason, usage, raw, latency_ms, ttft_msweft.step.index, weft.latency_ms, weft.ttft_ms when known, gen_ai.response.model
steeredrun_id, seq, step, messagesweft.step.index
run_finishrun_id, usage, steps, pending (parked calls), stopped_bynone from the core

usage is {input_tokens, output_tokens, cached_input_tokens?, cache_write_tokens?, reasoning_tokens?}. Deltas (text_delta, reasoning_delta, tool_args_delta) are on weft.delta.pos, a counter of their own, so a dropped delta never opens a gap in the event counter. A Subagent child’s events are its own records under its own run id; the parent’s nested wrapper is never recorded. A run that ended has a run_finish (success, or parked) or a stored invoke_agent span (status Error: failed; any other status: succeeded); with neither it is running or interrupted.

Attributes weft.messages.index, weft.messages.count (messages in the body), weft.step.index (the step the batch joined, 0 for the input) and weft.messages.input = true on index 0. The body is a JSON array of {"role": "user" | "assistant" | "tool", "content": [parts]}. There is no system role: the system text is the prompt record.

FormHow to tellWhat it is
Growthno weft.messages.reasonEmitted at the run’s input (index 0), the tool message a resume creates or rebuilds, each assistant message, each tool message and each steered batch. Concatenated in index order, the growth records are the run’s transcript, byte for byte
Viewweft.messages.reason = compactedWhat one request saw instead of the transcript, when a PrepareStep trimmed or summarised it (since 0.10.0). Never part of the transcript, never counted. Extra attributes: weft.messages.from_seq and weft.messages.to_seq (the half-open range of transcript ordinals it replaced; equal for a pure insertion), weft.compaction.scope = run, weft.compaction.hash. It takes the next index, right before the request record that names it

The view’s hash is lowercase hex sha256 over the canonical JSON of {"entries": <the view's body>, "from_seq": n, "to_seq": m}, keys sorted. The messages the model saw are the growth records below the view’s index, concatenated, with [from_seq, to_seq) replaced by the view’s body. A transcript builder skips every record with a non-empty weft.messages.reason; only a reader applying views fails on a reason it does not know.

Since 0.10.0. Emitted in the model-call phase after PrepareStep, immediately before the model is called, in this order: prompt (when its hash is new to the run), tools (when its hash is new), the view (when the messages were rewritten), request. A request that was never sent is never recorded.

RecordAttributesBody
requestweft.request.index, weft.step.index, weft.attempt.index (1 for the loop’s call, then 2, 3 per further reported attempt), weft.system.hash (when there was system text), weft.catalog.hash (when tools were offered)step, attempt, system_hash, messages_ref {index?, count}, tools {catalog_hash, names} (offered order), tool_choice?, thinking? {level, budget?, wire?}, sequential_tools, params {temperature?, top_p?, max_tokens?, stop?, seed?}, model {provider, name}, stream, prepared?
promptweft.prompt.index, weft.system.hash{"hash", "text"}: the composed system text (instructions after PrepareStep, the tools’ prompt snippets appended); segments?: [{source, text}] attributes it to instructions and tool:<name>, absent when no tool contributed a snippet
toolsweft.tools.index, weft.catalog.hash{"hash", "tools": [{name, description, schema, timeout_ms, approval, replay, max_result_bytes, sequential, source, output?}]} in name order; output: true marks submit_output
Body fieldMeaning
messages_refThe messages record the request’s messages are the view as of; index absent when capture was off or a content-off destination removed it
thinking.wireHow the adapter sends the level, the provider field it writes, never a value: openai reasoning_effort, thinking or none; anthropic thinking.adaptive, thinking.budget_tokens or thinking.disabled; google thinking_level or thinking_budget; none when the level maps to nothing. Declared by a model’s optional ThinkingWire method; absent when none does
preparedThe parts the agent’s PrepareStep chain changed, in the order system, messages, tools, tool_choice, params, thinking, sequential_tools. Names only, so it survives content off; absent when nothing changed
segmentsContent like the text: a content-off chain drops the record; a content-on chain redacts each segment and drops segments when its cap cut the text

Hashes. Every text hash is lowercase hex sha256 of the UTF-8 bytes, taken before any destination redacts or caps the text: weft.system.hash over the composed system text, weft.instructions.hash over the raw configured instructions (fixed for the run; e3b0c442…b855, the empty string’s, when there are none). The catalog hash is sha256 over canonical JSON built in four steps:

StepRule
1Decode each tool’s JSON schema keeping every number’s source lexeme
2Build one map per tool with the keys description, name and schema, and sort the maps by name. Every object at every level is written with its keys sorted
3Encode with no insignificant whitespace, no HTML escaping and no trailing newline
4sha256 the bytes

Go’s encoder output is the definition. An emitter starting from RFC 8785 (JCS) must keep three differences: numbers keep their source lexeme (1.0 stays 1.0), U+2028 and U+2029 are written escaped, and invalid UTF-8 becomes U+FFFD. No tools offered is catalog_hash "" and no tools record. A stored record’s step is -1 when weft.step.index was absent.

Only under otel.RawBodies(true) behind the development gate (WEFT_ENV=dev, or otel.DevMode()), and only to Local and Studio destinations with content on. Attributes weft.raw.index, weft.step.index, weft.attempt.index, weft.content = full, and weft.content.truncated_bytes when a body was cut. The body is {step, attempt, request {method?, url?, headers, media_type?, body, encoding?, bytes, truncated_bytes?}, response {status?, headers, media_type?, body, encoding?, bytes, truncated_bytes?, complete?} or null, redacted_headers, redacted_query?}. Credentials are stripped before emission, and each body is capped at 256 KiB (ADR 0028 §12).

Emitted by thread when a session compaction lands, under the id of the last run of the session that produced the compacted context; with no such run it waits for the next run the Session drives. Informational: it carries no messages and a reader never applies it, because the next run’s input record already holds the compacted context. See Compaction.

FieldValue
Attributesweft.compaction.scope = session, weft.compaction.hash (sha256 of the compaction entry’s JSON as thread wrote it, entry id included), weft.content = none, gen_ai.agent.name, and the session’s metadata verbatim (weft.session.id, weft.turn, weft.public_id, …), but not the gen_ai.conversation.id and session.id mirrors
PositionNo attribute: a store derives it from the hash
Body{scope, hash, entry, reason, replaced, entries, messages_before, messages_after, tokens_before, tokens_after}

Since 0.18.0 weft/thread reports its state log, every decision, grant, receipt and tree move it writes, as one record per fact. It emits through the agent’s LoggerProvider under the instrumentation scope github.com/weftgo/weft/thread. Each record has weft.record = thread, EventName weft.thread.<kind>, severity INFO (WARN for approval.refused), weft.run.id and gen_ai.agent.name. Its weft.content is full when the body carries a content object, else none, or stripped on a content-off chain. It carries the session’s metadata with weft.session.id, but not the gen_ai.conversation.id and session.id mirrors, and no position attribute. The exported trail is an index, not evidence: the session file is the record (ADR 0021).

The run it is filed under. A record is filed under the run its entry names: a request’s, a decision’s or a delivered receipt’s parking or draining run. Else it is filed under the turn in flight: a receipt’s busy turn, the turn whose chain saw a grant lapse, a pool receipt’s delegating turn. Else it goes under the last run of the session on the leaf’s line, as the compaction marker does. With no run yet (grants minted before the first turn), or when that run has not reported yet, the record is held and emitted when the run reports. What is still held at Close is emitted then with held: true in its body, on a context with no span: under the run it waited for, or, with no run at all, with no weft.run.id, keyed by weft.session.id. Past 256 held records the oldest are dropped, counted in a Debug line. thread decides each record under its session lock and hands it to one emitter goroutine per Session, in order, so no provider call runs while the session is locked; Close waits for it. A logger that panics or refuses changes nothing the session does.

The body is one JSON object: kind, session, at (the fact’s time, RFC 3339), the kind’s fields below (ids, enums and counts, absent when empty), and content, an object of strings that rides only when capture is on (the agent’s Content option, else the destination’s Enabled for weft.messages). Under weft/otel a content-off destination strips content, and a content-on one passes it through Redact as otel.ContentThread and caps it at MaxBytes. App-chosen names, such as a label’s name, are metadata, never content.

KindWhenFieldscontent
weft.thread.approval.requesta call parksentry, call_id, tool, args_sha256, expiry, quorum (above 1), child_session / wrapper_call (a mirrored pool child’s)—
weft.thread.approval.decisionany decision: Decide, DecideSigned, a grant or approver step, an expiry, an interrupt, a pool resolutionentry, call_id, outcome (approve, deny, resolve, resolve_error), via (user, signed, grant, approver, expiry, interrupt, child, parent, quorum), key_id, request_entry, always, grant_id and grant_scope (shared) for a grant stepwho, reason, content (a resolve’s result)
weft.thread.approval.refuseda signed decision refused, at most 16 audited per requestentry, call_id, reason (bad_signature, replayed, expired, args_changed, not_pending), key_id (when the ring holds it)—
weft.thread.grant.mintGrant, or an approve-always verdictentry, grant_id, tool, scope session, args (the predicate count, never their values), deny, max_uses, expiry; via always and call_id when a decision minted itreason (a deny grant’s model-visible text)
weft.thread.grant.usethe chain matched a grantentry, call_id, grant_id, outcome (approved, denied), scope (session, shared), uses (this one included), max_uses—
weft.thread.grant.revokeRevokeentry, grant_id, tool, uses—
weft.thread.grant.expirea grant’s lapse, once per grant per Session: its last use under MaxUses, or its Expiry passedgrant_id, tool, reason (max_uses, expiry), uses, max_uses, expiry—
weft.thread.receipta busy-policy receipt (Busy sessions and steering)entry, receipt_id (the acceptance entry), state (queued, accepted, delivered, deferred, dropped), input (steer, send), minted_run and turn (an accepted send’s, and a queued steer’s). A steer takes a turn number as it is accepted; one delivered into the busy turn names no run, which explains the gaps in a session’s run ids. Then follow_up_entry (a deferred steer’s), unansweredtext
weft.thread.interruptan Interrupt or Rollback send felled a running turn (target run) or an open approval boundary (target boundary)policy (interrupt, rollback), target, by_run, by_turn, denied_calls—
weft.thread.rewindthe leaf moved back so a run’s entries left the path: a rollback, or an overflow re-run’s branch-backentry, from_entry, to_entry, reason (rollback, overflow)—
weft.thread.branchBranchentry, from_entry, to_entry, summarized; with SummarizeLeft also summary_entry, branch_from, summarizer_usage, summarizer_modelsummary
weft.thread.uncompactUncompactentry, from_entry, to_entry, compaction (the entry undone)—
weft.thread.labelLabelentry, target, name—
weft.thread.pinPinentry, target—
weft.thread.forkFork, on the origin, under the run that produced the forked entry’s lineentry (the fork point on the origin; a fork writes no entry there) and new_session—
weft.thread.pool.delegatea thread/pool delegation acceptedentry, receipt_id, child_session, call_id, state acceptedprompt
weft.thread.pool.retireits settlemententry, receipt_id, child_session, call_id, state (done, failed, canceled, capped), usage (the child session’s whole cost)stop

A store keeps each as a plain record under the run it is filed under (obsdb.RecordThread), never as an app log line, a record filed under no run included. No reader applies one to the run row, though it moves the run’s last-seen like any record, and its attributes add nothing to meta but the run’s own metadata. Each thread record and compaction marker with a weft.session.id is also indexed by its session, which is what Studio’s session timeline reads (GET /api/sessions/{id}/timeline).

weft/otel’s pipeline emits one per open run every 10 s (otel.Heartbeat changes the interval): weft.record = heartbeat, weft.run.id, and a copy of the string attributes of the run’s run_start record (metadata with its mirrors, gen_ai.agent.name, the hashes, weft.version). No body, no position. It is never stored; it moves the run’s last-seen so a quiet run reads running instead of interrupted. A plain SDK without the pipeline emits none.

Two counters ride on it, both kept out of meta:

AttributeOnValue
weft.records.droppedthe heartbeat, run_start and run_finish records, on each destination’s own copy once it has lost a recordCumulative records that destination lost since the pipeline started: its queue full (deltas shed at half full, ordinary records at seven eighths, run_start, run_finish and heartbeats only when full), a failed export or write, a redaction failure. Policy filters are not losses. Studio keeps the largest per service.name as its ingest health (/api/meta’s ingest.dropped, weft doctor). Since 0.16.0
weft.logs.bridgedthe heartbeat, while a slog bridge is live, on copies to destinations that take app logsThe lines the bridge emitted since the pipeline started. Informational: the logs route reads the root span’s mark instead

Not weft records: they carry no weft.record and no weft.run.id. A store keeps them with the app’s other log records (other_logs on SQLite, otel_logs on ClickHouse), and a reader attributes them to a run through the span they were logged under: the run’s own spans and non-weft spans below them, never a child run’s. weft/otel’s bridge (otel.Slog(), otel.SlogHandler, Pipeline.SlogHandler) emits one per slog line logged under a valid span context; a line with no span is not bridged. Since 0.17.0. Bridge your app’s slog lines into runs shows the setup.

FieldValue
Instrumentation scopegithub.com/weftgo/weft/otel/slog, which is how the destination chains recognise a bridged line
Trace id, span idThe context’s: the chat span for mw.Log’s lines and the model chain’s, the execute_tool span for a tool handler’s and mw.Audit’s, and for weft.Logger’s lines the span of the phase: run start, finish and error on invoke_agent, model call and model attempt on chat, tool call on execute_tool
TimestampThe slog record’s time (its emission when zero); observed timestamp the bridge’s clock
Severity numberThe slog level + 9, held to 1–24: DEBUG 5, INFO 9, WARN 13, ERROR 17
Severity textThe level’s name: DEBUG, INFO, WARN, ERROR, INFO+2
BodyThe slog message
AttributesThe handler’s and the record’s attributes, flattened: group keys joined with . (db.table). Strings, ints, floats and bools as themselves; durations and times as strings; anything else its fmt text. Every key starting weft. is renamed slog.weft.…. The first 120 are kept and the rest counted in weft.log.attrs_dropped
weft.content, weft.content.truncated_bytesThe destination’s content policy: stripped on a content-off destination’s copy; the bytes Redact-then-MaxBytes cut on a content-on one. Absent on a content-on copy with nothing cut

Contract and code. The contract puts all of core.Logger’s run lines on the invoke_agent span (record-contract.md:720). The code logs each line on its phase’s context: run start, run finish and run error on the run’s (core/observe.go:331, 409-436), model call and model attempt on the chat span’s (core/observe.go:554, core/report.go:500), tool call on the execute_tool span’s (core/observe.go:737). The scratch run’s stored lines carry those span ids.

Which destinations take the lines is otel.AppLogs: Local and Studio with content on by default; Datadog, Langfuse, OTLP and Exporters only with otel.AppLogs(true). The opt-in never bypasses content policy. Every slog level goes to the pipeline: the bridge has no level of its own, and weft.Logger’s and mw.Log’s lines are DEBUG. An agent’s weft.Content(false) reaches its own lines first: the tool call line names an error result’s size (err_bytes) instead of its text. Under a full queue, bridged lines are shed at the delta threshold. The pipeline’s own WARNs about its destinations are never bridged.

Content means message text, tool arguments and results, the system prompt and the catalog. It is off in the core by default and decided per destination: on for otel.Local and otel.Studio, off for otel.OTLP, otel.Exporters and the vendor presets. weft.content says what a record holds. Control what content leaves the process is the how-to.

weft.contentMeaning
fullAs emitted. A content-on chain may still have redacted or capped it
strippedA content-off destination’s chain stripped it, or a request record the core emitted with capture off
noneThe core captured none (no destination wanted content, or weft.Content(false)); also every compaction marker, which carries none by nature
KindOn a content-off destination
event, deltaKept, the shape intact and the content fields emptied: tool_start.args null, tool_finish.content "", text_delta.text "", reasoning_delta.text "", tool_args_delta.args "", steered.messages [], parked calls’ args null. Marked stripped
messages, prompt, tools, rawDropped
requestKept with params.stop emptied and messages_ref.index removed (count stays), marked stripped: hashes, names and numbers survive
App log lineKept only with otel.AppLogs(true): body and string values "", weft.content = stripped, time, severity, span and other attributes kept

A content-on chain may cap content (MaxBytes, default 32 KiB) and then sets weft.content.truncated_bytes (int, the bytes cut). The transcript (messages) is never capped.

A conforming store keeps one row per weft.run.id and fills it from spans and records as they arrive, in any order. Every rule holds on both shipped backends, obsdb/sqlite and obsdb/clickhouse. The Go type is obsdb.RunRow; Studio serves most fields on GET /api/runs. Where two carriers disagree, “the larger” means the larger string, on both backends.

FieldDerived from
idweft.run.id
parent_run_id, parent_call_idweft.parent.run.id, weft.parent.call.id
caller_run_id, caller_call_idweft.caller.run.id, weft.caller.call.id, fill-if-empty like every identity column; empty when the run carries weft.caller.remote "true", so a remote link places nothing. RunQuery.CallerRunID lists the runs started from one run’s calls. "" on a run recorded before 0.18.0
trace_idThe invoke_agent span’s trace id, else any record’s
serviceThe resource’s service.name
agentgen_ai.agent.name
provider, modelrun_start’s model.provider and model.name, or the span’s gen_ai.provider.name and gen_ai.request.model, from either carrier: SQLite keeps the first to arrive, ClickHouse the larger string, so a Google run may read gcp.gemini (the span’s spelling of google)
session_id, public_id, turnweft.session.id, weft.public_id, weft.turn
playground, experiment_id, forked_fromweft.playground, weft.experiment.id, weft.forked_from
resumed_fromweft.resumed_from on the span or run_start; the larger when they differ
resumed_byOn a parked run, at read time, never stored: the latest run by start time whose resumed_from names it (a tie goes to the larger id). Deleting the resumer unlinks it
manifest_hash, weft_versionweft.manifest.hash, weft.version from any record or span that carries them, so a run whose records were lost still names both. For the version, run_start and the root span rank together; the root’s resource weft.version only when the root has no attribute
metaEvery string attribute outside the contract (obsdb.MetaOf, above)
startedThe earliest time of anything of the run
last_seenThe latest time of anything of the run, heartbeats included
finishedThe later of the invoke_agent span’s end and run_finish’s time; absent until either arrives
root_endedThe invoke_agent span is stored, any status. Kept by both backends, not served by Studio
finish_recorded, settlingfinish_recorded: run_finish is stored (not served). settling, at read time (obsdb.DeriveSettling): root stored, not derived, not failed, no run_finish, last-seen at most 30 s old. While settling, no reader calls records lost
statusAt read time, never stored: failed if the root’s status is Error; else succeeded if run_finish exists or the root is stored; else running if last-seen is at most 30 s old; else interrupted. No parked status: a parked run is succeeded with pending > 0. As a filter, two more read-time words: parked (succeeded, pending, no resumer stored) and cancelled (failed with error_type cancelled); obsdb.ParseStatus refuses any other word
errorThe invoke_agent span’s status description
steps, pendingrun_finish’s steps and the length of its pending, else the span’s weft.run.steps and weft.run.pending
stop_reasonweft.run.stop_reason: the last model call’s finish, not what ended the run
stopped_byThe span’s weft.run.stopped_by or run_finish’s stopped_by, the larger when they differ; "" when neither carried one. Filterable exactly, or by prefix ending in : (has_tool_call:)
cancel_causeThe span’s weft.cancel.cause; "" on a plain cancel and every other run
usagerun_finish’s usage, else the span’s gen_ai.usage.*; the cache and reasoning splits from the span
event_countStored event records
message_countStored growth messages records, views excluded
delta_countThe delta counter’s high-water mark; deltas are not stored
instructions_hashweft.instructions.hash from run_start or the span, the larger when they differ
events_emitted, messages_emittedThe span’s weft.run.events and weft.run.messages, the larger across roots; 0 when the root carried neither. Fewer events stored is gap, events_lost; fewer messages stored, with at least one stored, is gap, messages_lost. None stored is never called lost: a content-off destination stores none by design
error_typeA failed run’s kind: the span’s error.type, with context.Canceled and context.DeadlineExceeded read as cancelled (obsdb.RunErrorType); "" otherwise. The status stays failed
problemsCounters derived at ingest from the spans, one token per span id, so a span stored twice counts once. attempts_retried (failed attempt spans a later attempt of the same call followed), fallbacks (successful attempt spans with weft.attempt.layer fallback). tool_errors (execute_tool spans with status Error, except DENIED, RETRY and the context errors). denied (DENIED spans plus each root’s weft.run.denied), truncated (weft.tool.truncated_bytes > 0), repaired (0 for now), tap_panics (each root’s weft.tap.panics). metadata_dropped rides the same fold as the truncated hole. log_warn and log_error are read time, on the run document only
children_count, children_failedStudio’s run row only, read time, never stored: the rows whose parent_run_id is this run, one level deep, and how many of them failed
prompt_previewThe run’s prompt (the turn’s own; a resume’s new prompt when it carries one), cut to 200 runes; "" when the records carried no content or no user text
catalog_hashweft.catalog.hash of request index 0; "" when it offered no tools
request_countThe highest weft.request.index + 1
ReadRule
StepsThe run’s chat spans ordered by weft.step.index, equally its step_start and step_finish events
Tool callsThe run’s execute_tool spans ordered by weft.tool.seq, equally its tool_start and tool_finish events
TranscriptThe growth messages records concatenated in index order
SessionThe runs sharing weft.session.id that are top-level and not playground runs, ordered by weft.turn, then started. Its title is the newest turn’s non-empty weft.session.title; first_prompt the first turn’s prompt preview; content_off true when the first turn stored events and no messages record, and is not derived, not running and not settling
Run treeA run’s spans plus every descendant run’s, found through parent_run_id and, for a run no row names a parent of, core’s child id shape. Capped at 10,000 spans (obsdb.TreeSpanCap) and 10,000 rows; a derived run’s trace is read up to its first 50,000 spans. Served as GET /api/runs/{id}/spans?tree=1
ManifestNot derived from records: manifest_hash names a one-agent manifest an obsdb.ManifestStore keeps, written by Studio from weft.json and runtime registrations, kept forever

What the record says about your own code. PrepareStep, WrapModel, WrapTools, Tap, OnMessages and OnRunEnd are not recorded as hooks; only their effects are. A step whose weft.system.hash or catalog differs from the run’s instructions or the step before reads as rewritten, and the request’s prepared names what changed. WrapModel shows through the attempt spans its middleware reports. WrapTools shows through the execute_tool outcome (weft.panic.layer middleware, DENIED). Observer panics are counted in weft.tap.panics; OnRunEnd leaves nothing.

Every place a record is missing, cut or derived is shown with a badge from one closed table, obsdb.Hole. Badges and holes lists every hole, cause, reason and fix. The run-level rules, in short:

BadgeOn a run when
not_recordedinstructions_hash is "" and request_count is 0: written before 0.10.0, no request, prompt or tools records
not_recorded, cause no_loggerA weft run, not derived, not running, whose spans are stored and no record, and whose root says none were emitted: the app exported spans only
interruptedThe status is interrupted
max_tokensstop_reason is max_tokens
strippedAn event record is marked stripped or none
truncatedAn event record carries weft.content.truncated_bytes > 0
truncated, cause metadata_capThe root carries weft.metadata.dropped > 0
gapThe event counter has a hole below its high-water mark
gap, cause events_lost, messages_lost or tail_lostFewer records stored than the root says were emitted, or (a root without the counts) a stored root with events and no run_finish. Raised only once the run stopped settling
compactedThe run holds a run-scope view
derivedThe run was built from stock spans
derived (replay view)On the run document, a top-level playground replay (one with no parent run) whose weft.replay.view is derived or unknown

These rules are the ones the export’s and the fixtures’ holes follow (studio/export.go:765-851); the export also adds per-record notes (holes from the prompt and catalog refs, not_recorded for a batch at step < 0, derived for a derived input batch, a hidden-children hole). GET /api/runs/{id} raises a subset and leaves max_tokens, a cut event and compacted to the step or event they belong to, as Run-level badges explains. redacted is reserved. hidden comes from the reader’s token scope, not the data. It is used more widely than the contract’s “a read-scoped token’s view of a system prompt”. Request records, the tool catalog, a run tree’s descendants outside a panel token’s public id, and routes that answer the dev token only all answer it.

Status words beyond the four stored ones are read time: cancelled is failed with error_type cancelled; parked is succeeded with pending > 0 while nothing is known to have resumed it, and parked → tN once resumed_by or a later turn of its session says so.

weft writes the OTel GenAI conventions (semconv v1.41.0) beside its own keys, so any GenAI-aware backend renders its traces:

KeyWhere weft writes it
gen_ai.operation.nameEvery span but attempt: invoke_agent, chat, execute_tool
gen_ai.agent.nameinvoke_agent; every record
gen_ai.provider.nameinvoke_agent, chat, attempt
gen_ai.request.modelinvoke_agent, chat, attempt
gen_ai.response.modelchat, attempt on success; the step_finish record
gen_ai.response.finish_reasonschat
gen_ai.usage.input_tokens, gen_ai.usage.output_tokensinvoke_agent (run totals), chat (the call’s)
gen_ai.usage.cache_read.input_tokens, gen_ai.usage.cache_creation.input_tokens, gen_ai.usage.reasoning.output_tokensThe same spans, when non-zero
gen_ai.tool.name, gen_ai.tool.call.idexecute_tool; the tool_start and tool_finish records
gen_ai.conversation.idEvery span and record the core emits for a run with a weft.session.id, and its heartbeats, beside session.id; not the compaction marker
error.typeFailed spans

weft never writes the conventions’ opt-in content attributes (input and output messages on spans): content travels in log records under each destination’s content policy.

An app that exports stock GenAI spans, such as a Python or TypeScript agent instrumented by the OTel GenAI conventions with no weft.* attribute anywhere, gets runs too. obsdb.DeriveStockRuns is the one derivation both backends write through (since 0.15.0). Inspect agents written in other languages shows how to send such spans.

RuleDetail
A span’s operationIts gen_ai.operation.name (an empty value is unset); without it, its name: starting with invoke_agent or execute_tool, or chat alone or followed by a space (so a chatbot span is not a model call)
A rootAn invoke_agent span with no weft.run.id and a gen_ai.conversation.id. Each root is one derived run
A subtreeThe spans under the root by parent span id, down to, not into, any nested root or any span with weft.run.id
No conversation idAn invoke_agent span without one opens no run; its chat and execute_tool spans count toward the enclosing root. A tree with no conversation id anywhere stays a trace only
weft spansNever derived: a weft run’s spans carry the GenAI mirrors, gen_ai.conversation.id among them, and still make no derived twin
Partial exportsA span counts only through a complete chain of stored parents, so a run whose spans arrive over several exports converges: steps, usage and last-seen only grow
When it runsThe writers re-derive a trace from all its stored spans whenever an export brings a span without weft.run.id whose operation is one of the three
FieldDerived as
idotel-<trace id>-<root span id>, lowercase hex; deterministic, so a retried export lands on the same row (obsdb.ParseStockRunID splits it)
derivedtrue: the row says the reader built it
trace_id, serviceThe root’s trace id and resource service.name
agentThe root’s gen_ai.agent.name
provider, modelThe root’s gen_ai.provider.name and gen_ai.request.model, else the first chat span’s
session_idThe root’s gen_ai.conversation.id: the conversation is the session, its derived runs its turns; "" (no session) for a root without one, since 0.20.0 a run in its own right rather than skipped
turn0 on the row. Studio’s session document numbers a session’s derived top-level runs 1..n by start order (after the highest numbered thread turn, when the session holds both) for display, never stored; a session whose every run is derived is badged “derived (stock OTel)”
parent_run_id, parent_call_idFor a root nested in another root’s subtree: that root’s derived id and the gen_ai.tool.call.id of the nearest execute_tool span above. A stock root under a weft run’s tool is top-level
started, finishedThe root’s start and end
last_seenThe latest time in the subtree
status, errorfailed with the status description when the root’s status is Error (with no description: “the root span’s status is Error (no description)”), else succeeded. Never running or interrupted
usageThe run’s own: the root’s gen_ai.usage.* when present, as given; else the sum over the subtree’s chat spans. No correction either way. With no usage key anywhere the row reads zero and Studio prices it unknown
stepsThe number of chat spans in the subtree
chatThe subtree’s chat spans in start order, each span’s step its 0-based ordinal
toolsThe subtree’s execute_tool spans in start order: gen_ai.tool.name, gen_ai.tool.call.id, seq the 1-based ordinal, step the latest chat span that started before it, absent when none did
holesderived

A derived run’s spans are read from its trace at read time with the reader’s numbers stamped on the copy: weft.step.index on chat and execute_tool spans, weft.tool.seq on execute_tool spans, and gen_ai.operation.name as resolved. Not derivable, and badged derived (cause stock_spans) rather than shown empty: events, the transcript, message bodies, the request, prompt and catalog, turn, public_id, stop_reason, pending, meta, the record counts and the hashes. Studio refuses a derived run as a replay or fixture source, and a panel token never reaches one, since it has no public id.

obsdb/testdata/contract/ holds one directory per case: an OTLP/JSON export (traces.json, logs.json) and expect.json, the run rows any conforming store derives from it. TestContract checks every case on SQLite, TestContractClickHouse on ClickHouse with WEFT_CLICKHOUSE_DSN. The inputs are real pipeline output, except stock_genai, which is hand-written. go test ./obsdb -run 'TestContract$' -update-contract regenerates them, normalised so a regeneration with no code change leaves git diff empty.

CaseWhat it pins
plainOne model call, no tools: the minimal succeeded run
tool_callsTwo steps, one tool call, catalog_hash; metadata in meta (enduser.id yes, user.id no); the playground marks as columns and meta
subagentA parent and its <id>/0/call_1 child, linked; the parent’s usage includes the child’s; the parent’s run tree
session_turnsTwo thread turns: run ids, session id, public id, turn
compactedA run-scope view, excluded from message_count; the compacted badge
content_offStripped events, no messages, request records kept; the stripped badge
max_tokensstop_reason max_tokens; the max_tokens badge
interruptedNo invoke_agent, no run_finish: status interrupted
pre_upgradeNo request, prompt or tools records, no weft.instructions.hash: not_recorded
failedMaxSteps(1) exceeded: failed, the error text, steps, usage and stop reason from the span; error_type max_steps
parkedA RequireApproval call parked: succeeded, pending 1, stopped_by parked
session_titleA content-off session titled after its first turn: weft.session.title in meta, the session row’s title, content_off
stopped_byStopWhen(HasToolCall("submit_ticket")): stop_reason tool_calls, stopped_by has_tool_call:submit_ticket
canceledA cancel with cause studio.cancel: failed, error_type cancelled, stopped_by canceled, cancel_cause from the span alone
tool_problemsA handler panic, a StrictInput refusal, a cut result, an mw.Allow refusal: tool_errors 2, truncated 1, denied 1
retry_fallbackmw.Retry and mw.Fallback cases: attempts_retried, fallbacks keyed on weft.attempt.layer
approval_deniedTwo parked calls, one denied, one undecided: zero-length denied spans, weft.resume.calls, weft.run.denied 2, resumed_from, resumed_by
retries_tapsweft.tool.retry 1 and 2 under MaxModelRetries(1), model_retries_exceeded; a panicking Tap; 65 metadata pairs (metadata_cap); prompt segments
resumedApprove and Resolve with weft.ResumeOf and weft.approval.actor: weft.tool.approved, weft.resume.calls, the actor in meta
stock_genaiStock spans only: two derived runs in one conversation, one with a tool call, one failed
tracer_onlySpans only: succeeded from the root, events_emitted 0, not_recorded cause no_logger
tracer_only_failedThe failed run, spans only: failed from the root, no_logger
tail_lostEvery record after a tool_finish dropped: succeeded, gap with events_lost and messages_lost
slog_bridgedmw.Log lines under chat (DEBUG 5) and a tool’s WARN 13 under execute_tool, attributed to the run; the root’s weft.logs.bridged 0, not in meta
records_droppedweft.records.dropped 3 on run_start and run_finish; no row field
run_cardsOutput runs (weft.output.submitted), park_on and park_source parks, a Timeout (timeout_ms), a parked Subagent child (SUBAGENT_PENDING), prepared and thinking.wire, a 503 then an answer (http.response.status_code, weft.attempt.wait_ms)
queue_breakpointsweft.tool.queue_ms under Parallelism(1); a playground breakpoint park (weft.playground.breakpoints)
bridge_overridesweft.override.params with a null, weft.override.tool_choice any; a redacted bridged WARN with 125 attributes (weft.log.attrs_dropped 5)
bridge_strippedA bridged WARN on a content-off destination that opted in: stored stripped
messages_lostOne growth messages record dropped: message_count 3 of 4, gap with messages_lost

expect.json is {case, description, pending?, derived?, runs: [...], sessions?}; each run lists the run-row fields, derived when true, its chat and tools lists, its tree and its holes, and may carry logs, hole_causes and problems. Empty fields are omitted. Runs are ordered by started, then id; times are RFC 3339 UTC.

NormalisationRule
ExportFolded to one resource and scope block
TimesEach signal keeps its own order on a 1 ms grid from the case’s epoch (2026-10-01T09:00Z plus one minute per case). Span and record times are not comparable with each other
Durationsweft.ttft_ms, weft.latency_ms, weft.attempt.wait_ms, weft.tool.queue_ms and step_finish’s latency_ms and ttft_ms read 1 where set
Versionweft.version and the scope’s version read v0.0.0-contract
IdsRenumbered in first-seen order with their shapes kept: trace ids 7ace…, span ids 5ba0…, run ids a110…, session ids 01K…, manifest hashes 3a21f…
BatchesEach step holds at most one tool call, so no parallel race churns a fixture
SinceWhat arrived
0.8.0weft.playground read in its string spelling, "true"
0.10.0The request, prompt and tools records, weft.instructions.hash; the compaction view (weft.messages.reason = compacted)
0.15.0docs/record-contract.md and the conformance fixtures; derived runs from stock spans
0.16.0weft.resumed_from, weft.resume.calls, denied calls’ execute_tool spans; weft.run.stopped_by, weft.cancel.cause; weft.run.events, weft.run.messages, weft.records.dropped
0.17.0The slog bridge: app log records, weft.logs.bridged. The run cards’ facts: weft.attempt.wait_ms, http.response.status_code, weft.tool.timeout_ms, weft.tool.queue_ms, weft.tool.pending.source, weft.subagent.pending, weft.output.submitted, the tools record’s output, the request’s prepared and thinking.wire, weft.playground.breakpoints. Breaking: weft.override.params changed shape from the Go struct’s JSON to the request record’s lower-case names with nulls, which changes a params override’s weft.override.hash