Event types
A run reports its progress as weft.Event values: agt.Stream yields them from Events(), and a weft.Tap sees the same values in the same order. This page lists the eleven event types, every field with its JSON name, and the rules that order a stream. Signatures stay on pkg.go.dev; how to consume a stream is in Stream a run’s events.
Event types at a glance
Section titled “Event types at a glance”In the order a run emits them:
| Event | Wire type | Seq | Emitted when |
|---|---|---|---|
RunStart | run_start | — | First event of every run |
StepStart | step_start | — | The model is being called for a step |
ReasoningDelta | reasoning_delta | — | An increment of provider reasoning |
TextDelta | text_delta | — | An increment of assistant text |
ToolArgsDelta | tool_args_delta | — | The model is still writing a tool call |
ToolStart | tool_start | ✓ | A tool call began |
Nested | nested | ✓ | One event of a subagent’s child run |
ToolFinish | tool_finish | ✓ | A tool call completed, successfully or not |
StepFinish | step_finish | — | The step’s model call and its tools are done |
Steered | steered | ✓ | The run’s steering source delivered messages |
RunFinish | run_finish | — | Last event of a successful run |
Every event except RunStart also carries RunID (run_id). A failed run has no RunFinish: its error is the last element Events() yields.
weft.Event is a sealed interface: the eleven types above implement it, and no type outside the package can. New event types may be added in later releases, additively, so a switch over events stays exhaustive and lintable. The type is an alias of core.Event (facade.go).
| Property | Rule |
|---|---|
| Discriminator | On the wire every event is one JSON object with a type field (table above); field names are snake_case |
RunID | On every event except RunStart, whose id is the run’s own. Concurrent runs on one agent interleave, and Seq is unique only within a run, so RunID attributes an event to its run. Added in 0.2.0: older recordings decode with an empty RunID |
| Snapshots | An event’s fields, including the Args byte slices and RunFinish.Pending, do not alias the run’s transcript. You may keep an event or write into it without changing the run (0.2.0) |
| Compatibility | Additive only: a field is added, never renamed or removed. An unknown type is an error when decoding, never a silent drop (ADR 0004) |
Ordering rules
Section titled “Ordering rules”The loop guarantees these orders; tests pin them (ADR 0004, rules 3 and 4).
| Rule | What holds |
|---|---|
| First and last | RunStart is first in every run; RunFinish is last in a successful run |
| One counter | ToolStart, ToolFinish, Nested and Steered take Seq from one per-run counter, assigned and emitted under one lock: the order you observe is the order of Seq |
No Seq needed | RunStart, StepStart, the three deltas, StepFinish and RunFinish come from the loop’s one goroutine, ordered by construction |
| Call order | ToolStart events arrive in call order under any parallelism; pair a ToolFinish with its ToolStart by CallID |
| Start before finish | Every ToolFinish follows its call’s ToolStart. A call cancelled before it got a slot emits neither |
| Parked calls | A call parked at the approval boundary has a ToolStart and no ToolFinish; it is listed on RunFinish.Pending |
| Resumed calls | Calls resumed with weft.Approve emit ToolStart and ToolFinish in the resuming run, before its first StepStart. Denied and resolved calls emit no tool events: their result joins the transcript directly |
| Truncated step | A step that finished max_tokens with tool calls emits no tool events: none of the calls ran |
| Arguments first | Every ToolArgsDelta precedes the ToolStart of the call it belongs to |
| Step end | StepFinish follows the step’s ToolFinish events and precedes the stop-condition check |
| Steering | Steered sits between a step’s StepFinish and the next StepStart |
| Children inside the call | A child run’s RunStart to RunFinish arrive, wrapped in Nested, inside the parent’s ToolStart…ToolFinish for the delegating call; none arrive after that ToolFinish |
| Cancellation | Once the run’s context is cancelled, nothing more is delivered, to Events() or to taps. The partial transcript on RunError.Result is the record |
A run with two tool calls in one step, the second a subagent, emits the stream below. The first tool, echo, is marked weft.Sequential(), a barrier, so it runs alone and finishes before the subagent starts; without it the two calls run in parallel and their events interleave in an order that can change from run to run (Seq still numbers whatever order occurred). The parent agent has weft.Instructions("Be terse.") and the child has none, which gives the two instructions_hash values. Each line is json.Marshal of one event; latency_ms and ttft_ms are measured and vary:
{"type":"run_start","id":"r1","model":{"provider":"wefttest","name":"script"},"agent":"parent","instructions_hash":"28c7339ead79c720e67160d2f681384ad23a59bf8514c3c2e01d09a4d701441f"}{"type":"step_start","run_id":"r1","index":0}{"type":"tool_start","run_id":"r1","seq":1,"call_id":"c1","name":"echo","args":{"q":"x"}}{"type":"tool_finish","run_id":"r1","seq":2,"call_id":"c1","name":"echo","content":"x","is_error":false}{"type":"tool_start","run_id":"r1","seq":3,"call_id":"c2","name":"research","args":{"prompt":"go"}}{"type":"nested","run_id":"r1","seq":4,"call_id":"c2","event":{"type":"run_start","id":"r1/0/c2","model":{"provider":"wefttest","name":"script"},"agent":"child","instructions_hash":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"}}{"type":"nested","run_id":"r1","seq":5,"call_id":"c2","event":{"type":"step_start","run_id":"r1/0/c2","index":0}}{"type":"nested","run_id":"r1","seq":6,"call_id":"c2","event":{"type":"text_delta","run_id":"r1/0/c2","text":"child done"}}{"type":"nested","run_id":"r1","seq":7,"call_id":"c2","event":{"type":"step_finish","run_id":"r1/0/c2","index":0,"reason":"stop","usage":{"input_tokens":10,"output_tokens":5},"latency_ms":1,"ttft_ms":1}}{"type":"nested","run_id":"r1","seq":8,"call_id":"c2","event":{"type":"run_finish","run_id":"r1/0/c2","usage":{"input_tokens":10,"output_tokens":5},"steps":1,"stopped_by":"final_answer"}}{"type":"tool_finish","run_id":"r1","seq":9,"call_id":"c2","name":"research","content":"child done","is_error":false}{"type":"step_finish","run_id":"r1","index":0,"reason":"tool_calls","usage":{"input_tokens":10,"output_tokens":5},"latency_ms":1}{"type":"step_start","run_id":"r1","index":1}{"type":"text_delta","run_id":"r1","text":"done"}{"type":"step_finish","run_id":"r1","index":1,"reason":"stop","usage":{"input_tokens":10,"output_tokens":5},"latency_ms":1,"ttft_ms":1}{"type":"run_finish","run_id":"r1","usage":{"input_tokens":30,"output_tokens":15},"steps":2,"stopped_by":"final_answer"}The child’s events keep their own run_id (r1/0/c2: parent run, step, call) while the Nested envelope carries the parent’s run_id and seq. The parent’s step_finish reports its own model call’s usage; run_finish totals the run, the child’s usage included. The first step_finish has no ttft_ms: a scripted bare tool call yields no text or argument delta to time.
RunStart
Section titled “RunStart”RunStart is always the first event of a run. It carries the run’s id and, when reported, the model’s identity and the agent’s name.
| Field | Type | Wire | Meaning |
|---|---|---|---|
ID | string | id | The run’s id, the same as Run.ID() and RunResult.ID; set it with weft.RunID. A subagent’s child run is <parent>/<step>/<call>, or <parent>/resume/<call> for a call run under Approve |
Model | ModelInfo | model | {provider, name} when the model implements Info() ModelInfo; the zero value otherwise |
Agent | string | agent, omitted when empty | The agent’s weft.Name |
InstructionsHash | string | instructions_hash, omitted when empty | Lowercase hex sha256 of the run’s raw configured instructions: the agent’s Instructions or the run’s override, before PrepareStep and before PromptSnippets are composed in |
The loop always sets InstructionsHash; a run with no instructions carries the hash of the empty string (e3b0c442… in the stream above). It is a hash, not content, so it survives weft.StripContent; an event built by hand may leave it empty. It was added in 0.10.0 and is mirrored as weft.instructions.hash on the run_start record and the invoke_agent span. The example ExampleRunStart_instructionsHash compares it with the sha256 of the configured prompt.
StepStart
Section titled “StepStart”StepStart reports that the model is being called for a step.
| Field | Type | Wire | Meaning |
|---|---|---|---|
RunID | string | run_id | The run this event belongs to |
Index | int | index | The step’s index, from 0 |
ReasoningDelta
Section titled “ReasoningDelta”ReasoningDelta is an increment of provider reasoning, in the order the model produced it relative to TextDelta. Signatures are not streamed: they are on the transcript’s ReasoningPart.
| Field | Type | Wire | Meaning |
|---|---|---|---|
RunID | string | run_id | The run this event belongs to |
Text | string | text | The reasoning text increment |
TextDelta
Section titled “TextDelta”TextDelta is an increment of assistant text.
| Field | Type | Wire | Meaning |
|---|---|---|---|
RunID | string | run_id | The run this event belongs to |
Text | string | text | The text increment |
ToolArgsDelta
Section titled “ToolArgsDelta”ToolArgsDelta reports an increment of a tool call’s arguments while the model is still writing the call. It is progress only: the call has not been made, and ToolStart still arrives when it executes. The OpenAI and Anthropic adapters stream argument fragments; Google’s calls arrive whole, so its runs emit none.
| Field | Type | Wire | Meaning |
|---|---|---|---|
RunID | string | run_id | The run this event belongs to |
Name | string | name | The best-known tool name so far; deltas of several calls interleave, told apart by name where the provider supplies one |
Args | string | args | A fragment of the arguments’ JSON, not a complete value |
ToolStart
Section titled “ToolStart”ToolStart reports that a tool invocation began. Events from tools running in parallel interleave: pair them by CallID and order them by Seq.
| Field | Type | Wire | Meaning |
|---|---|---|---|
RunID | string | run_id | The run this event belongs to |
Seq | int64 | seq | The run’s event counter at emission |
CallID | string | call_id | The model’s id for the call; the matching ToolFinish carries the same |
Name | string | name | The tool’s name |
Args | json.RawMessage | args | The call’s arguments as JSON. A nil Args marshals as null and decodes as json.RawMessage("null"); in a live run it is never nil |
A parked call has a ToolStart and no ToolFinish.
Nested
Section titled “Nested”Nested wraps one event of a child run started by a weft.Subagent tool. The envelope belongs to the parent run; the wrapped event belongs to the child.
| Field | Type | Wire | Meaning |
|---|---|---|---|
RunID | string | run_id | The parent run’s id |
Seq | int64 | seq | From the parent’s counter, so the parent stream stays totally ordered with the child’s events in place |
CallID | string | call_id | The parent’s tool call that owns the child run |
Event | Event | event | Any child event, with its own RunID and Seq; a grandchild’s event is a Nested inside a Nested |
Nested.UnmarshalJSON decodes the envelope and then the inner event through UnmarshalEvent, recursively; an unknown inner type fails as at the top level, wrapped as nested event: …. Usage a child reports after its call’s ToolFinish is dropped with its late events.
ToolFinish
Section titled “ToolFinish”ToolFinish reports that a tool invocation completed, successfully or not.
| Field | Type | Wire | Meaning |
|---|---|---|---|
RunID | string | run_id | The run this event belongs to |
Seq | int64 | seq | The run’s event counter at emission |
CallID | string | call_id | The call’s id, as on its ToolStart |
Name | string | name | The tool’s name |
Content | string | content | The tool’s output, or the failure text when IsError is set: the same value the model sees on the matching ToolResultPart |
IsError | bool | is_error | The call failed, for example: a handler error or a returned *weft.ToolError, a weft.ModelRetry (RETRY: result), a panic, a timeout, bad arguments or an unknown tool (tool errors are data) |
StepFinish
Section titled “StepFinish”StepFinish reports that a step is complete: the model call finished and, when it requested tools, they have run.
| Field | Type | Wire | Meaning |
|---|---|---|---|
RunID | string | run_id | The run this event belongs to |
Index | int | index | The step’s index, as on its StepStart |
Reason | StopReason | reason | stop, tool_calls or max_tokens |
Usage | Usage | usage | This step’s model call alone. Subagent usage rolls into RunResult.Usage and RunFinish.Usage, not here |
Raw | string | raw, omitted when empty | The provider’s own stop reason when Reason was approximated; empty when the mapping was exact |
LatencyMS | int64 | latency_ms, omitted when 0 | From the start of the model chain’s Stream to the stream’s ModelFinish |
TTFTMS | int64 | ttft_ms, omitted when 0 | From the same start to the first TextDelta or ToolArgsDelta; reasoning does not count |
LatencyMS and TTFTMS were added in 0.10.0. Both are whole milliseconds rounded up, so a measured interval is never 0, and 0 means not measured: a recording made before the fields existed, an event built by hand, or, for TTFTMS, a call that yielded no text and no argument delta. The timing spans the whole model chain, so a retry’s backoff and a fallback’s failed tries are inside it. Nothing in the loop reads them. Usage fields on the wire are input_tokens, output_tokens and, when non-zero, cached_input_tokens, cache_write_tokens and reasoning_tokens.
Steered
Section titled “Steered”Steered reports messages the run’s steering source (weft.Steering) delivered at a step’s drain point: after the tool batch, or at a final step whose steer redirected the run into one more step.
| Field | Type | Wire | Meaning |
|---|---|---|---|
RunID | string | run_id | The run this event belongs to |
Seq | int64 | seq | The run’s event counter at emission |
Step | int | step | The step whose drain point delivered the messages |
Messages | []Message | messages | The delivered messages, role user, as a snapshot; the transcript holds its own copy |
RunFinish
Section titled “RunFinish”RunFinish is always the final event of a successful run, a parked one included.
| Field | Type | Wire | Meaning |
|---|---|---|---|
RunID | string | run_id | The run this event belongs to |
Usage | Usage | usage | The run’s total, subagent runs included |
Steps | int | steps | The number of steps the run took |
Pending | []ToolCallPart | pending, omitted when empty | Mirrors RunResult.Pending: the calls the run ended on without executing, awaiting Approve, Deny or Resolve. Each had its ToolStart and no ToolFinish |
StoppedBy | string | stopped_by, omitted when empty | What ended the run, in the manifest’s stop_when vocabulary (below) |
StoppedBy values:
| Value | The run ended because |
|---|---|
final_answer | A step had no tool calls |
parked | Calls are pending at the approval boundary |
has_tool_call:<tool> | weft.HasToolCall fired; several names are joined with commas (has_tool_call:a,b) |
step_count_is:N | weft.StepCountIs(N) fired |
output_submitted | The structured-output tool received a valid call (weft.Output) |
a condition’s String() | A custom StopCondition that implements fmt.Stringer fired |
custom | A custom condition without a String() method fired |
The value is configuration, never content. The run’s invoke_agent span carries the same value as weft.run.stopped_by; a failed run has no RunFinish, so on a failed run only the span names what stopped it (How does a run stop?).
Unmarshal events
Section titled “Unmarshal events”A recorded stream decodes back into typed events with weft.UnmarshalEvent, one JSON object at a time. The package example ExampleUnmarshalEvent decodes a tool_start line and prints its name, call id, Seq and arguments:
input: {"type":"tool_start","seq":5,"call_id":"c1","name":"echo","args":{"m":"x"}}output: echo c1 5 {"m":"x"}Every event type has a MarshalJSON method that writes the type field first; json.Marshal on any event gives the wire form shown on this page.
UnmarshalEvent
Section titled “UnmarshalEvent”weft.UnmarshalEvent decodes one wire event, dispatching on its type. It returns the concrete type as a value (weft.ToolStart, not *weft.ToolStart), so a type switch or assertion names the value types.
| Input | Result |
|---|---|
A known type | The event, with every field the object carries; absent fields are zero |
No type, or "type":"" | Error event has no "type" field |
An unknown type | Error unknown event type "<type>", never a skipped event |
A nested object with a bad inner event | Error nested event: <inner error> |
| Bytes that are not a JSON object | The encoding/json error |
See also
Section titled “See also”- Stream a run’s events
- Delegate to another agent (subagents)
- The record contract: how events become
eventanddeltarecords - Glossary
- Package weft on pkg.go.dev