obsdb record and span types
Package obsdb stores what weft and stock OpenTelemetry send as OTLP-shaped spans and log records, and reads them back as typed records: events, transcript batches, compaction views, request, prompt, tools and raw records, and app log lines. This page lists those types, the live-lane hub, and the three small stores a database keeps beside its runs: experiments, manifests and the playground’s commands. The database interface, the queries and the run, session and trace rows are on obsdb: reading the observability database from Go; the holes a record can carry are on Badges and holes.
The shapes on this page are what a backend returns from DB’s methods and from the optional ManifestStore and CommandStore. The functions that build them from stored rows are shared plumbing, exported so the backends, Studio and otel parse alike. This page names them only:
| Builds | Shared functions |
|---|---|
| Request, prompt, tools and raw records | RequestRecordOf, PromptRecordOf, ToolsRecordOf, RawRecordOf, AttachRaw |
| Compactions and step messages | CompactionOf, ViewOf, ApplyView, AssembleStep, MessagesAsOf |
| Identity and the transcript | DeriveRecord, DeriveSpan, DedupBatches, TranscriptBodies |
| Command store and manifests | CommandByRun, CommandTerminal, CheckStoredCommand, CheckStoredManifest |
What a Write takes
Section titled “What a Write takes”A backend’s Write takes one Batch: spans and log records exactly as ingested, OTLP-shaped, resource included. Weft identity is never parsed out of ids; it is derived from attributes into a Weft and stored as indexed columns. These types arrived with obsdb’s first release in 0.7.0.
obsdb.Batch is one write, in arrival order. Write is idempotent on (run, record kind, position) and (trace, span), so a retried transport’s duplicate is a no-op.
| Field | Meaning |
|---|---|
Spans | The finished spans of the write, as Span values |
Records | The log records of the write, as Record values: weft records and non-weft lines alike |
obsdb.Span is one finished span, OTLP-shaped. Non-weft spans pass through unchanged, so a polyglot trace is stored whole.
| Field | Meaning |
|---|---|
TraceID | The trace id, lowercase hex |
SpanID | The span id, lowercase hex |
ParentSpanID | The parent span’s id, lowercase hex; "" for a root |
Name | The span name (invoke_agent …, chat …, execute_tool …, attempt, or any other producer’s) |
Kind | The OTLP SpanKind number |
Start | When the span started |
End | When the span ended |
StatusCode | 0 unset, 1 ok, 2 error |
StatusMessage | The status description |
Service | The resource’s service.name |
Attrs | The span attributes: string, bool, int64, float64 or []any values |
Resource | The resource attributes |
Events | The span’s events (exceptions and markers), as SpanEvent values |
SpanEvent
Section titled “SpanEvent”obsdb.SpanEvent is one event recorded on a span.
| Field | Meaning |
|---|---|
Time | When the event happened |
Name | The event name (exception, a marker’s name) |
Attrs | The event’s attributes |
Record
Section titled “Record”obsdb.Record is one log record, OTLP-shaped. A record with weft.run.id is a weft record, routed by its weft.record kind; one without is an app log line and lands in the app-log table (other_logs on SQLite, otel_logs on ClickHouse). Since 0.14.0 a non-string weft.messages.reason reads as its text, so such a record is a compaction view, not growth, and no longer counts in a SQLite run’s message count.
| Field | Meaning |
|---|---|
Time | The record’s time. FromOTLPLogs leaves a zero time zero, and so do hub frames; a backend stores a zero-time record at its Observed time |
Observed | When the SDK observed the record |
TraceID | The trace of the span the record was emitted under, lowercase hex; "" without one |
SpanID | That span’s id; app log lines are attributed to a run through it |
Severity | The OTLP severity number, 0 unspecified or 1–24 |
EventName | The OTLP event name (weft.event, weft.messages, weft.request, …) |
Body | The body as text: a weft record’s JSON, an app line’s message |
Service | The resource’s service.name |
Attrs | The record’s attributes |
Resource | The resource attributes |
obsdb.Weft is the identity obsdb derives from a span’s or record’s attributes and stores as indexed columns. Zero values mean absent; a span or record with no weft.run.id is non-weft and every field reads absent.
| Field | Attribute | Meaning |
|---|---|---|
RunID | weft.run.id | The run the span or record belongs to |
ParentRunID | weft.parent.run.id | The parent run, for a subagent child |
ParentCallID | weft.parent.call.id | The parent’s tool call that started this run |
SessionID | weft.session.id | The thread session of the run |
PublicID | weft.public_id | The session’s public id |
Turn | weft.turn | The session turn number |
Agent | gen_ai.agent.name | The agent’s name |
Record | weft.record | The record kind, one of ten: event, delta, messages, heartbeat, request, prompt, tools, raw, compaction, thread (a thread session’s records, since 0.18.0); "" for a span or a non-weft record |
EventType | weft.event.type | The event’s type (run_start, tool_start, …) |
Pos | weft.event.pos, weft.messages.index, weft.delta.pos, weft.request.index, weft.prompt.index, weft.tools.index, weft.raw.index | The record’s position in its kind: the value of the (run, kind, pos) key and the live lane’s dedup |
Step | weft.step.index | The step; -1 when absent |
ToolSeq | weft.tool.seq | The tool call’s sequence number; -1 when absent |
Playground | weft.playground | The run was started by the playground |
ExperimentID | weft.experiment.id | The saved experiment the run belongs to |
ForkedFrom | weft.forked_from | The run this one was forked from |
ResumedFrom | weft.resumed_from | The parked run this one resumes; on the invoke_agent span and the run_start record only |
CallerRunID, CallerCallID | weft.caller.run.id, weft.caller.call.id | The tool call that started this run when it is no Subagent child, such as a thread/pool child session’s turn or a Generate inside a handler. A link, never parenthood. On the invoke_agent span and the run_start record only. Empty when the link is remote (weft.caller.remote, weft.WithCaller), since readers place a run by its local link alone |
Reason | weft.messages.reason | "" for transcript growth, compacted for a compaction view, which is never counted or concatenated as transcript; a non-string value reads as its text |
Input | weft.messages.input | The messages record is the run’s input record: what search reads the turn’s prompt from |
Decoding OTLP
Section titled “Decoding OTLP”Both decoders arrived in 0.7.0, with golden protobuf and JSON fixtures under obsdb/testdata that Studio’s ingest and the SDK path pin against. Scalars are kept verbatim, arrays become []any, key-value lists become maps and bytes become base64; a nil element at any layer is skipped.
| Function | Meaning |
|---|---|
FromOTLPTraces | Decodes an OTLP/HTTP trace export request into []Span. Studio’s receiver and a stock collector’s dump produce the same rows the local sink does |
FromOTLPLogs | Decodes an OTLP/HTTP log export request into []Record. Weft and non-weft records both pass through; the kind they carry decides where Write puts them |
The live lane
Section titled “The live lane”The SQLite backend’s Write publishes its frames to its hub before it returns, so an in-process subscriber (Studio’s /api/live handler in setup A) sees a record with no network hop; the handle exposes the hub through Hub(). ClickHouse’s Write publishes nothing: for a backend without a hub, Studio publishes what it ingests into its own NewHub.
obsdb.Hub is the live lane’s interface. It promises only that Publish never blocks the caller beyond a bounded per-subscriber queue, and that a slow subscriber is dropped. The rest of the behaviour below is the in-process hub’s, from NewHub.
| Method | Meaning |
|---|---|
Publish(ctx, f) | Sends the frame to every matching subscriber without blocking. NewHub’s hub stamps f.Seq from its hub-wide counter, and drops a subscriber whose queue is full: its channel closes |
Subscribe(ctx, sel, after) | Returns a channel of the frames sel matches with Seq above after. The channel closes when the hub drops it or ctx ends; tell the two apart by ctx.Err(). A cursor ahead of this hub’s counter (one minted by a previous process) reads as 0 |
A Selector scopes a subscription to one run, session, public id or agent, or to every run with All; an empty or over-set selector matches nothing.
| Name | Meaning |
|---|---|
NewHub(opts...) | Returns the in-process hub: one Seq counter for every frame, one bounded queue per subscriber. A hosted Studio may swap in another implementation of Hub |
HubOption | Configures NewHub |
QueueSize(n) | Sets the per-subscriber queue depth; default 1000, and 0 or less keeps it. Publishing to a full queue drops the subscriber rather than blocking the writer: a live tail resumes from the database |
obsdb.Frame is one live-lane message.
| Field | Meaning |
|---|---|
Kind | record, run or attempt (the constants below) |
Record | The record as ingested, deltas included; set when Kind is record |
Weft | The frame’s derived identity, what a Selector matches on |
Run | The run row that changed; set when Kind is run |
Span | The attempt span as it landed; set when Kind is attempt |
Seq | Hub-wide and monotonic: the SSE id and the resume cursor |
| Constant or function | Value | Meaning |
|---|---|---|
FrameRecord | record | A record as ingested, deltas included |
FrameRun | run | A run row that changed |
FrameAttempt | attempt | An attempt span (one try inside a model call) published as it lands: a step is retrying or falling back before its chat span ends. Live only: the span is stored as any span is, and the frame is never backfilled |
RecordFrame(r) | The frame a Write publishes for one record, with its derived identity | |
RunFrame(r) | The frame a Write publishes for a run row that changed | |
AttemptFrame(s) | The frame for an attempt span; ok is false for any other span and for an attempt span that names no run |
Events and the transcript
Section titled “Events and the transcript”Deltas travel on the live lane but are counted, never stored; heartbeats are never stored and only move a run’s last-seen. What a backend keeps of a run’s stream is its positioned events and its messages records.
PosEvent
Section titled “PosEvent”obsdb.PosEvent is one positioned event of a run, as DB.Events pages them in an EventPage.
| Field | Meaning |
|---|---|
Pos | The durable position, weft.event.pos |
Time | The record’s time |
Event | The event body, verbatim JSON (weft.UnmarshalEvent restores it) |
Content | weft.content: stripped from a content-off chain, "" as emitted |
TruncatedBytes | weft.content.truncated_bytes: what a content-on chain’s cap cut, 0 for none. A ClickHouse row written before migration 0004 carries neither attribute |
TranscriptBatch
Section titled “TranscriptBatch”obsdb.TranscriptBatch is one growth messages record as DB.TranscriptBatches returns it. Readers place a batch by its Step, never by its neighbours. TranscriptBatch, with the internal TranscriptBodies and DedupBatches, arrived in 0.10.0 (ADR 0028 §8).
| Field | Meaning |
|---|---|
Index | weft.messages.index: the record’s place in the run’s transcript |
Step | weft.step.index, the step the batch joined; -1 when the record carried none (a ClickHouse row before migration 0004, or a producer that never stamped it), and a reader that places it anyway shows the derived badge |
Input | weft.messages.input: the run’s input record. On a partial resume it ends at the last assistant message with tool calls; the rebuilt tool message is the next batch, at step 0 |
InputDerived | Input was inferred by the backend for a row that did not store the flag (ClickHouse rows before weft_records.Input): true on index 0 unless the body is a lone assistant message. Readers badge it derived |
Messages | The body: a JSON array of messages, through the backends’ dedup of the old partial-resume shape |
Compaction
Section titled “Compaction”obsdb.Compaction is one compaction a run’s records name, as DB.Compactions returns it: the run-scope views by index, then the session markers in emission order. A view is never part of the plain transcript and applies only to the request whose messages_ref names its index.
| Field | Meaning |
|---|---|
Scope | run for a compaction view, session for thread’s marker (the constants below) |
Hash | weft.compaction.hash |
Index | The view’s messages index; -1 for a session marker |
Step | The step the view was recorded at; -1 for a session marker |
FromSeq | Start of the replaced transcript range, inclusive; 0 for a marker |
ToSeq | End of the replaced range, exclusive; 0 for a marker |
Messages | The view’s messages, which replace [FromSeq, ToSeq); a marker carries none and is never applied |
Reason | Thread’s compaction reason: manual, threshold, overflow, from_hook or trim; "" for a view |
Replaced | Messages replaced: ToSeq-FromSeq for a view, thread’s count for a marker |
Entries | Messages put in their place: the length of Messages for a view, thread’s count for a marker |
TokensBefore | Thread’s estimate before compacting; 0 for a view |
TokensAfter | Thread’s estimate after compacting; 0 for a view |
| Constant | Value | Meaning |
|---|---|---|
CompactionRun | run | The weft.compaction.scope of a view the core emits when a PrepareStep sent messages that are not the run’s transcript |
CompactionSession | session | The scope of thread’s informational marker, filed under the last run that produced the compacted context |
ReasonCompacted | compacted | The one weft.messages.reason ADR 0028 §8 defines. A messages record with any other reason fails DB.Compactions loudly |
RecordCompaction | compaction | The weft.record kind of thread’s session marker |
StepMessages
Section titled “StepMessages”obsdb.StepMessages is the messages one step’s model call carried: the replay prefix for from_step and what a replay fixture keys on. Studio’s transcript?step=N, weft/runtime’s replay and the wefttest fixtures all assemble it the same way.
| Field | Meaning |
|---|---|
Step | The step asked for |
Messages | The growth records up to the request’s own index, or, under a view, up to the view’s index with its range replaced |
View | The run-scope compaction view the step’s request named; nil when it carried the plain transcript |
Derived | No request record placed the messages (a run written before ADR 0028, or a messages_ref a content-off chain stripped): the transcript before step Step’s assistant message was used instead |
StepMessagesError
Section titled “StepMessagesError”obsdb.StepMessagesError is the refusal when the stored records do not rebuild the messages a request names. errors.Is(err, obsdb.ErrStepMessages) holds; its text is obsdb: step <n>: <msg>. Badges and holes has its two holes in full.
| Field | Meaning |
|---|---|
Step | The step that could not be rebuilt |
Hole | gap when a record the request names is missing or does not fit; stripped when the run stored no messages at all |
Msg | What did not fit, in words |
Assembler
Section titled “Assembler”obsdb.Assembler assembles several steps of one run from batches decoded once, for a reader that walks every step (the wefttest fixture export). It is not safe for concurrent use, and the messages it returns share their parts with its decoded batches: read them, or copy before changing them.
| Name | Meaning |
|---|---|
NewAssembler(batches) | Decodes the run’s growth batches once |
(*Assembler).Step(requests, compactions, step) | Answers one step’s StepMessages from the decoded batches, the run’s request records (the answering, last, attempt of the step is used) and its compactions |
MessageText
Section titled “MessageText”obsdb.MessageText is one message reduced to what search reads.
| Field or function | Meaning |
|---|---|
Role | The message’s role: user, assistant or tool |
Text | The text of its text parts, joined by \n, empty parts included |
ToolCall | The message carries a tool_call part |
MessagesText(body) | Reads a messages record body into its messages’ text, in order. A body that does not parse reads as no messages: search never fails a write over it |
Session title
Section titled “Session title”| Constant | Value | Meaning |
|---|---|---|
SessionTitleKey | weft.session.title | The run metadata a thread session stamps with its current title: it lands in RunRow.Meta and is read back as SessionRow.Title. It survives content-off |
Request, prompt, tools and raw records
Section titled “Request, prompt, tools and raw records”Each model-call attempt writes a request record; a system text new to the run writes a prompt record and a tool catalog new to the run a tools record, each keyed by its hash. Under otel.RawBodies(true) behind the development gate (WEFT_ENV=dev, or otel.DevMode()), a raw record holds the provider wire exchange. A content-off chain strips the request record and drops the prompt and tools records it names.
RequestRecord
Section titled “RequestRecord”obsdb.RequestRecord is one stored request record: one model-call attempt, as DB.Requests pages them.
| Field | Meaning |
|---|---|
Index | weft.request.index, the record’s per-run position |
Step | The stored weft.step.index; -1 when absent |
Attempt | The body’s attempt: 1 for the loop’s call, 2, 3, … per further reported attempt |
Time | The record’s time |
SystemHash | weft.system.hash when set (it wins over the body when they disagree), else the body’s system_hash |
CatalogHash | weft.catalog.hash when set, else the body’s tools.catalog_hash; "" when no tools were offered |
Content | The record’s hole: "" as emitted, stripped from a content-off chain, derived when an unstripped body did not parse (then Body is zero and Attempt 0) |
TruncatedBytes | Informational only: weft never caps a request record |
Body | The parsed body, a RequestBody |
Raw | The body verbatim |
Wire | The attempt’s RawRecord; nil when the run holds none for it (raw bodies off, an adapter that does not report, a run written before the raw record) |
RequestBody
Section titled “RequestBody”obsdb.RequestBody is the request record’s body, keys as the core writes them; an absent field is unset.
| Field | JSON | Meaning |
|---|---|---|
Step | step | The step of the call |
Attempt | attempt | The attempt number |
SystemHash | system_hash | The composed system text’s hash: the PromptRecord it names |
MessagesRef | messages_ref | Which messages the request carried, a RequestMessagesRef |
Tools | tools | The catalog offered, a RequestTools |
ToolChoice | tool_choice | The tool choice in force; nil when unset |
Thinking | thinking | The thinking configuration in force; nil when unset |
SequentialTools | sequential_tools | The step’s tool calls run one at a time |
Parallelism | parallelism | The step’s Parallelism dial: how many of its tool calls may run at once; 0 on a record written before 0.20.0 |
Params | params | The sampling parameters, a RequestParams |
Model | model | The model requested, a RequestModel |
Stream | stream | The call streamed |
Prepared | prepared | The parts the run’s PrepareStep chain changed, in the order system, messages, tools, tool_choice, params, thinking, sequential_tools; absent when none did |
Wire | wire | Since 0.20.0, how the adapter’s escape hatches shape the request, names only, a RequestWire; nil when no model along the Unwrap chain declares the optional WireFacts() method (what the run record names) |
The request body’s parts
Section titled “The request body’s parts”| Type and field | JSON | Meaning |
|---|---|---|
RequestMessagesRef .Index | index | The messages record the request’s messages are the run’s view as of; nil where no messages record exists (capture off, or stripped by a content-off chain) |
RequestMessagesRef.Count | count | How many messages the request carried |
RequestTools .CatalogHash | catalog_hash | The offered catalog’s hash: the ToolsRecord it names; "" for no tools |
RequestTools.Names | names | The tool names, in the order offered |
RequestToolChoice .Mode | mode | The tool-choice mode in force |
RequestToolChoice.Name | name | The tool a named choice forces |
RequestThinking .Level | level | The thinking level in force |
RequestThinking.Budget | budget | The token budget, when one was set |
RequestThinking.Wire | wire | How the adapter sends the level: the provider field it writes (reasoning_effort, thinking.budget_tokens, thinking_level, …) or none; absent when the model declares none |
RequestParams .Temperature | temperature | The temperature; nil is the adapter’s default (as for every parameter below) |
RequestParams.TopP | top_p | The nucleus-sampling bound |
RequestParams.MaxTokens | max_tokens | The output token limit |
RequestParams.Stop | stop | The stop sequences; removed by a content-off chain |
RequestParams.Seed | seed | The sampling seed |
RequestModel .Provider | provider | The provider of the model the attempt requested |
RequestModel.Name | name | The model name the attempt requested |
RequestWire .ServerAddress | server_address | The endpoint’s host[:port], never its credentials, path or query. The model reports all four facts through the optional WireFacts() method, found along the Unwrap chain; behind mw.Fallback they are the primary’s (what the run record names) |
RequestWire.ExtraBodyKeys | extra_body_keys | The top-level keys of the adapter’s ExtraBody, never their values |
RequestWire.ExtraHeaders | extra_headers | The names of the adapter’s ExtraHeaders, lowercase, never their values |
RequestWire.Dropped | dropped | How many names were left out. Each list is sorted and keeps at most 32 names, each at most 128 bytes |
PromptRecord
Section titled “PromptRecord”obsdb.PromptRecord is one stored prompt record: the composed system text of one distinct system hash, as DB.Prompt returns it. A missing one is ErrNotFound, a *HoleError when the reader knows why.
| Field | Meaning |
|---|---|
Index | weft.prompt.index |
Time | The record’s time |
Hash | The hash, over the text before any cut; from the weft.system.hash attribute when the body did not parse |
Text | The composed system text: the instructions after PrepareStep, with the tools’ prompt snippets appended |
Segments | The text attributed to its sources, as PromptSegment values; nil when no tool contributed a snippet, a cap cut the text, or the writer predates the field |
Content | truncated when a destination’s cap cut Text, derived when the body did not parse, else "" |
TruncatedBytes | What the cap cut, 0 for none |
PromptSegment
Section titled “PromptSegment”obsdb.PromptSegment is one source’s share of a composed system text. Joined by blank lines, the segments are Text exactly.
| Field | JSON | Meaning |
|---|---|---|
Source | source | instructions, or tool:<name> for a tool’s PromptSnippet |
Text | text | That source’s text |
ToolsRecord
Section titled “ToolsRecord”obsdb.ToolsRecord is one stored tools record: the catalog of one distinct catalog hash, tools in name order, as DB.Tools and DB.Catalogs return it. A missing one is ErrNotFound, a *HoleError when the reason is known.
| Field | Meaning |
|---|---|
Index | weft.tools.index |
Time | The record’s time |
Hash | The hash over the whole catalog; from the weft.catalog.hash attribute when the body did not parse |
Tools | The catalog, as ToolEntry values in name order |
Content | truncated when a destination’s cap dropped entries from the end, derived when the body did not parse, else "" |
TruncatedBytes | What the cap removed, 0 for none |
Skipped | Since 0.20.0, the tools an importer left out of the offered sources (weft/mcp’s ImportError), each a SkippedTool {name, reason, source}, its source the origin it would have come from (mcp:billing); at most 64, nil when none was skipped |
SkippedMore | How many skipped tools past those 64 |
ToolEntry
Section titled “ToolEntry”obsdb.ToolEntry is one tool of a catalog: the model-visible triple and the policy this run applied to it. Playground tool_args edits are checked against its Schema.
| Field | JSON | Meaning |
|---|---|---|
Name | name | The tool’s name |
Description | description | The description the model saw |
Schema | schema | The input JSON schema the model saw |
TimeoutMS | timeout_ms | The call deadline in milliseconds: the tool’s own, else the agent’s; 0 for none |
Approval | approval | The call parks: the tool requires approval, or the run’s park rule parks it |
Replay | replay | The side-effect class for re-runs: safe or never |
MaxResultBytes | max_result_bytes | The result cap: the tool’s own, else the agent’s; 0 is no cap |
Sequential | sequential | The tool is a barrier: it runs alone |
Source | source | Where the tool comes from: local, subagent, or the tool’s origin (mcp:<server> from weft/mcp under mcp.Server, else mcp) |
Output | output | The tool is the run’s submit_output (weft.Output): its typed answer |
SourceDetail | source_detail | Since 0.20.0, the tool’s origin in parts, a SourceDetail {server, transport, prefix, remote_name}; nil when the producer set none (MCP identity) |
StoredRecord
Section titled “StoredRecord”obsdb.StoredRecord is a request, prompt, tools or raw record as a backend stored it. A backend fills it from its columns and builds the read types above through the shared parsers, so every backend parses alike. You meet it when you write a backend.
| Field | Meaning |
|---|---|
Index | The record’s per-kind index |
Step | The stored weft.step.index; -1 when absent |
Time | The record’s time |
Body | The body bytes |
Content | weft.content, the content mark (stripped or "") |
TruncatedBytes | weft.content.truncated_bytes |
SystemHash | weft.system.hash |
CatalogHash | weft.catalog.hash |
RawRecord
Section titled “RawRecord”obsdb.RawRecord is one stored raw record: an attempt’s wire exchange as the core shaped it, attached to its attempt’s RequestRecord.Wire. Raw records reach only the Local and Studio destinations, and only under otel.RawBodies(true) behind the development gate (WEFT_ENV=dev, or otel.DevMode()).
| Field | JSON | Meaning |
|---|---|---|
Index | index | weft.raw.index |
Step | step | The stored weft.step.index |
Attempt | attempt | The attempt in flight when the adapter reported; where an SDK’s own retries put several exchanges on one attempt, the highest index is the attempt’s |
Time | time | The record’s time |
Request | request | The request side, a RawSide |
Response | response | The response side; nil when the exchange got no response (a transport error) |
RedactedHeaders | redacted_headers | The credential headers stripped from both sides |
RedactedQuery | redacted_query | The credential query parameters whose values were replaced |
Content | content | truncated when a body was cut, derived when the record’s body did not parse (both sides zero), else "" |
TruncatedBytes | truncated_bytes | weft.content.truncated_bytes: what the cap cut over both bodies |
RawSide
Section titled “RawSide”obsdb.RawSide is one side of the exchange. Each body is capped at 256 KiB, with the cut counted.
| Field | JSON | Meaning |
|---|---|---|
Method | method | The HTTP method; request side only |
URL | url | The request URL, credential query values replaced; request side only |
Status | status | The HTTP status; response side only |
Headers | headers | The headers, credentials stripped |
MediaType | media_type | The body’s media type |
Body | body | The body as text, or base64 when Encoding is base64 |
Encoding | encoding | base64 when the bytes were not UTF-8, else empty |
Bytes | bytes | The whole body’s size before the cap |
TruncatedBytes | truncated_bytes | What the cap removed |
Complete | complete | Response side: false when the body was not read to its end (a transport retry closed it, a timeout, a reader that stopped); nil on the request side and on records that do not say |
| Constant | Value | Meaning |
|---|---|---|
RecordRaw | raw | The weft.record kind of a raw record, positioned by weft.raw.index and stored beside the request records |
Stock derivation
Section titled “Stock derivation”Studio derives a run from stock OTel GenAI spans that carry no weft.run.id (How Studio derives a run); the derived run is a StockRun. These functions are the derivation’s rules, shared by the backends:
| Function | Meaning |
|---|---|
StockRunID(traceID, spanID) | The derived run’s id, otel-<trace id>-<root span id>, lowercase hex: deterministic, never contains /, cannot collide with a core id |
ParseStockRunID(id) | Splits a derived run id into its trace and root span ids; ok false for any other id |
StockTraces(ids) | The trace ids the derived run ids among ids name, in order, once each |
IsStockRoot(s) | Reports whether a span opens a derived run on its own: an invoke_agent span with no weft.run.id and a gen_ai.conversation.id. A top-level one without a conversation id opens one too, but only DeriveStockRuns can tell, from the trace |
StockCandidate(s) | Reports whether a span may take part in a derived run: no weft.run.id, and one of invoke_agent, chat, execute_tool |
DeriveStockRuns(spans) | Every run the spans hold, ordered by start then id; converges whatever order the spans arrived in. One run per stock root, and one per top-level invoke_agent span without a conversation id: that run has no session |
StockRunSpans(spans, id) | The spans of derived run id among one trace’s spans; nil when no root of that id is there |
StockRunsOf(all, keys, deleted) | The derived runs whose root a deletion takes, so their rows do not outlive their spans |
ExampleDeriveStockRuns derives a run from a stock trace.
App log lines
Section titled “App log lines”OtherLog
Section titled “OtherLog”obsdb.OtherLog is one app log record of a run: a non-weft line (the app’s slog lines, OTel Logs API records) attributed to the run through the span it was emitted under, as DB.OtherLogs pages them in a LogPage.
| Field | Meaning |
|---|---|
Index | The line’s place among the run’s app logs, in time order; stable once the run has ended |
Time | The record’s time |
Severity | The OTLP severity number, 0 unspecified or 1–24 (SeverityText names it: 13 is WARN) |
EventName | The OTLP event name, when the producer set one |
Body | The line’s body; a structured body renders as JSON |
Attrs | The record’s attributes: typed on SQLite, strings on ClickHouse, whose otel_logs keeps the collector’s string map |
TraceID | The trace the line was emitted under |
SpanID | The span the line was emitted under: the run’s attribution key |
Service | The resource’s service.name |
Saved experiments
Section titled “Saved experiments”DB.SaveExperiment, DB.Experiments and DB.Experiment keep the playground’s saved groups in one small table beside the runs. The definition is keyed by the weft.experiment.id its runs carry; the runs stay in the runs table.
Experiment
Section titled “Experiment”obsdb.Experiment is one saved playground group.
| Field | Meaning |
|---|---|
ID | The experiment id, the weft.experiment.id its runs carry; SaveExperiment upserts by it |
Name | The name it was saved under |
Agent | The agent its runs ran |
Created | When it was first saved |
Updated | When it was last saved; Experiments lists newest update first |
Variants | The matrix’s columns, as ExperimentVariant values, wire shapes verbatim |
Inputs | The matrix’s rows, as ExperimentInput values |
PassPredicate | The experiment’s pass predicate, as the playground sent it: stored and returned verbatim; "" when none, or on an experiment saved before 0.19.0 |
ExperimentCommand | The embedded rest of the run command the matrix sent, so the experiment reopens as the form that ran it; zero on one saved before obsdb kept it |
ExperimentCommand
Section titled “ExperimentCommand”obsdb.ExperimentCommand is the experiment-wide part of the run command, kept as sent and stored as one JSON document. obsdb does not validate it (Studio does, on the way in). Every field is optional; zero is “not recorded” or the command’s default, and a reader cannot tell the two apart.
| Field | JSON | Meaning |
|---|---|---|
Engine | engine | live or scripted |
SideEffects | side_effects | substitute, park or allow |
Thread | thread | ephemeral or fork |
FromStep | from_step | The step every cell continues from |
SourceRunID | source_run_id | The run the cells replay from |
TranscriptEdits | transcript_edits | The transcript edits, the list as sent |
ExperimentVariant
Section titled “ExperimentVariant”obsdb.ExperimentVariant is one column of the matrix.
| Field | JSON | Meaning |
|---|---|---|
Key | key | The column’s key |
Overrides | overrides | The overrides object it applies, verbatim: instructions, tools_enabled, model, thinking, options, params, tool_choice, park_on, only_tools, and any key a later command adds |
Engine | engine | The engine when it differs from the experiment’s; empty is the experiment’s own |
SideEffects | side_effects | The side-effect mode when it differs; empty is the experiment’s own |
Thread | thread | The thread mode when it differs; empty is the experiment’s own |
ExperimentInput
Section titled “ExperimentInput”obsdb.ExperimentInput is one row of the matrix: a source run to take the turn from, or a literal text.
| Field | JSON | Meaning |
|---|---|---|
Key | key | The row’s key |
SourceRunID | source_run_id | The run whose turn the row replays |
Text | text | A literal prompt |
FromStep | from_step | The row’s own step, so each source run continues from its own failing step; nil is the experiment’s FromStep |
Stored manifests
Section titled “Stored manifests”ManifestStore
Section titled “ManifestStore”obsdb.ManifestStore is a database’s optional manifest capability: each agent’s configuration by its hash, so a run’s RunRow.ManifestHash resolves to the configuration it ran with, even after it stopped being current.
- Both first-party backends implement it: SQLite migration 0014, ClickHouse migration 0016. The conformance table holds them to the same answers.
- Studio writes it from the
weft.jsonit serves and from runtime registrations;/api/manifests/{hash}reads it.
| Method | Meaning |
|---|---|
PutManifest(ctx, m) | Stores m unless its hash is stored already (then a no-op returning nil). A zero FirstSeen is stamped with the current time. ErrInvalidManifest when the body is not a JSON object or the hash is not its sha256 |
Manifest(ctx, hash) | The manifest stored under hash; false when none is |
The store is content-addressed and immutable: a second PutManifest of a stored hash changes nothing, so FirstSeen and Source are the first write’s. Manifests are kept forever; DeleteRun, DeleteSession, Sweep and Vacuum never touch them.
StoredManifest
Section titled “StoredManifest”obsdb.StoredManifest is one stored agent configuration.
| Field | Meaning |
|---|---|
Hash | sha256 of Body, lowercase hex |
Body | The one-agent weft.Manifest document, byte for byte: the bytes whose sha256 the agent’s runs carry |
Source | Where Studio first saw it: file or runtime; "" when the writer did not say |
FirstSeen | When it was first stored |
| Name | Value | Meaning |
|---|---|---|
ManifestSourceFile | file | Written from the weft.json Studio serves |
ManifestSourceRuntime | runtime | Written from a runtime registration |
ManifestHash(body) | The hash a manifest body is stored under: sha256 of its bytes, lowercase hex, the core’s weft.manifest.hash of the same bytes |
The playground’s command store
Section titled “The playground’s command store”CommandStore
Section titled “CommandStore”obsdb.CommandStore is a database’s optional playground-link capability: what Studio’s runtime server asked its runtimes to do, so a restarted Studio still knows.
- It holds four sets of rows: commands, run routes (what cancel, steer and the debugger’s verbs are routed by), each runtime’s breakpoint set, and runtime registrations.
- Both first-party backends implement it: SQLite migration 0007, ClickHouse migration 0008. It arrived in 0.15.0. A backend without it keeps the runtime server in memory only.
- The rows are Studio’s bookkeeping, not run data:
DeleteRun,DeleteSession,SweepandVacuumnever touch them, andPruneCommandsis their only retention.
| Method | Meaning |
|---|---|
PutCommand(ctx, c) | Upserts c whole under c.ID. A zero Created or Updated is stamped with the current time on every write, so carry the Created you read back. ErrInvalidCommand for an empty ID or a state outside the five |
Commands(ctx, q) | The rows q selects, newest Created first (ties by ID, descending); an empty query returns every row |
PutRoute(ctx, r) | Replaces the route of r.RunID. A zero Seen is stamped. ErrInvalidCommand for an empty RunID or RuntimeID |
Route(ctx, runID) | The route of runID; false when none is stored |
PutBreakpoints(ctx, runtimeID, tools) | Replaces the runtime’s breakpoint set whole; empty tools stores the empty set (a clear). ErrInvalidCommand for an empty runtime id |
Breakpoints(ctx, runtimeID) | The stored set, never nil when stored; false when none was ever stored, which is distinct from a stored empty set |
PutRuntime(ctx, r) | Upserts r whole under r.ID; zero Registered or LastSeen is stamped. ErrInvalidCommand for an empty ID |
Runtimes(ctx) | Every stored runtime, most recently seen first (ties by ID) |
DeleteRuntime(ctx, runtimeID) | Removes the runtime’s row and its breakpoint set: Studio’s “forget” of a runtime that is gone. Its commands and routes stay as history. An id with nothing stored is no error; ErrInvalidCommand for an empty id |
PruneCommands(ctx, before, keep) | Bounds the store by the rules below. Returns how many commands it deleted; on ClickHouse, how many it selected, which can count a command a racing put kept |
A backend may also implement BreakpointProvenanceStore, which keeps a breakpoint set with when and through which surface Studio delivered it, so a restarted Studio still says set by <surface> at <time>. PutBreakpointSet(ctx, runtimeID, set) and BreakpointSet(ctx, runtimeID) take and return a BreakpointSet {Tools, SetAt, SetBy}: SetBy is the Studio page that sent it (runtimes), else api. A clear keeps neither field. Both first-party backends implement it.
PruneCommands(ctx, before, keep) applies these rules:
- A terminal command whose
Updatedis beforebeforeis deleted. - Then, while more than
keepcommands remain, the oldest terminal ones byCreatedgo (keep≤ 0: no count bound). A queued or accepted command is never deleted. - A route goes when it names a command no longer stored, or when its
Seenis beforebeforeand no live command names its run. - A runtime goes when its
LastSeenis beforebefore, no live command is addressed to it and its breakpoint set is absent or empty. - An empty breakpoint set no runtime names goes when last written before
before. - On SQLite the terminal commands go in passes of
SweepBatch, each its own transaction. On ClickHouse the prune is not atomic with concurrent puts, so serialize it with your writes.
Command states
Section titled “Command states”| Constant | Value | Meaning |
|---|---|---|
CommandQueued | queued | Enqueued to a runtime, not yet acknowledged. Live |
CommandAccepted | accepted | The runtime acknowledged it and is running it. Live |
CommandRejected | rejected | The runtime refused it. Terminal |
CommandFinished | finished | It ran to an outcome. Terminal |
CommandLost | lost | Studio decided it lost (no ack in time, or an accepted command fell silent); never re-issued. Terminal |
StoredCommand
Section titled “StoredCommand”obsdb.StoredCommand is one command row. The indexed columns are what queries select by and what a restart decides from.
| Field | Meaning |
|---|---|
ID | The command id |
RuntimeID | The runtime the command was enqueued to |
Kind | The frame kind the caller names: "", run, cancel, approve, breakpoints or steer; stored verbatim, never interpreted |
State | One of the five states above |
RunID | The run an ack named; "" until one did |
PublicID | The public id the command is scoped to |
Fork | A thread=fork command: its runs are sessions the runtime owns |
Agent | The command’s agent, copied out of Body |
SourceRunID | The command’s source run, copied out of Body |
ExperimentID | The command’s experiment, copied out of Body |
Status | A finished command’s run outcome: succeeded or failed |
Error | Why, when there is a why: a rejection’s reason, a failed run’s error, what made it lost |
Created | When the row was first written |
Updated | When it was last written |
AcceptedAt | When the accepted ack arrived; zero when none did |
LastBeat | The last heartbeat (a repeated accepted ack); zero when none did. A restarted Studio decides a silent accepted command lost from these two |
Body | The whole wire command, verbatim |
Ack | The last ack the runtime posted, verbatim; nil reads back nil |
CommandQuery
Section titled “CommandQuery”obsdb.CommandQuery selects commands. Every set field must match; an empty query matches every row.
| Field | Meaning |
|---|---|
ID | One command by id |
RuntimeID | The commands enqueued to one runtime |
RunID | The commands whose ack named one run |
States | Any of these states; nil and empty both mean no filter |
Limit | At most this many rows; ≤ 0 returns every match |
RunRoute
Section titled “RunRoute”obsdb.RunRoute is one run → runtime route.
| Field | Meaning |
|---|---|
RunID | The run |
RuntimeID | The runtime an ack said started the run |
CommandID | The command whose ack named it last |
PublicID | The public id the command carried |
Fork | The command’s fork mark |
Seen | When an ack last named the run |
StoredRuntime
Section titled “StoredRuntime”obsdb.StoredRuntime is one runtime’s latest registration, so a restarted Studio can list what was registered before it.
| Field | Meaning |
|---|---|
ID | The runtime id (rt_…) |
Service | The app’s service name |
Host | The hostname the runtime reported: the app’s os.Hostname() |
Cwd | The app’s working directory when the registration carries one, else "" |
Pid | The app’s process id (os.Getpid()); Studio uses <id>-<pid> as the runtime id when another process holds the id |
Agents | The names of its registered agents |
Registered | When it registered |
LastSeen | When it was last heard from |
Body | The whole registration as the runtime posted it |
Best practices & gotchas
Section titled “Best practices & gotchas”- Never treat the live lane as durable. A slow subscriber’s channel closes when its queue fills; resume from the database, then subscribe with the last
Seq. (Source:obsdb/hub.go:120-155) - Do not expect deltas or heartbeats back.
Writecounts deltas and drops them, and heartbeats only move last-seen; the hub still carries deltas live. (Source:obsdb/doc.go:32-34) - Read a record’s
Contentbefore its body. Astrippedorderivedrequest record has no usable body, and atruncatedprompt or catalog is a prefix; show the badge, not a blank. (Source:obsdb/request.go:305-351) - Carry
Createdinto everyPutCommand. A zeroCreatedis stamped with now on each write and moves the command to the front of the newest-first order. (Source:CommandStore.PutCommandgodoc,obsdb/commands.go:34-44) - Carry
Registeredinto everyPutRuntime. A zeroRegisteredis overwritten with now, so the registration time is lost; the order is unaffected, sinceRuntimessorts byLastSeen. (Source:CommandStore.PutRuntime,Runtimesgodoc,obsdb/commands.go:60-67) - Serialize
PruneCommandswith your own puts on ClickHouse. Each rule decides from what it read; a racing put keeps its own row but may still be counted. (Source:obsdb/commands.go:34-137;obsdbtest.CommandsPruneRace)
See also
Section titled “See also”- obsdb: reading the observability database from Go
- Badges and holes
- The record contract
- Choose the observability database: SQLite or ClickHouse
Symbols used: obsdb.Batch · obsdb.Span · obsdb.Record · obsdb.Weft · obsdb.Hub · obsdb.Frame · obsdb.PosEvent · obsdb.TranscriptBatch · obsdb.Compaction · obsdb.StepMessages · obsdb.RequestRecord · obsdb.PromptRecord · obsdb.ToolsRecord · obsdb.RawRecord · obsdb.OtherLog · obsdb.Experiment · obsdb.ManifestStore · obsdb.CommandStore · obsdb.ErrStepMessages · obsdb.ErrInvalidCommand · obsdb.ErrInvalidManifest · obsdb.SweepBatch · obsdbtest.CommandsPruneRace