---
title: Event types
description: Every weft.Event a run emits — RunStart to RunFinish, eleven types — with each field, its wire name, and the rules that order a stream.
url: https://weftgo.dev/docs/reference/events/
type: reference
sources:
  - weft/core/events.go:8-26 (Event), 28-44 (RunStart), 46-50 (StepStart), 52-64 (TextDelta, ReasoningDelta), 66-90 (ToolStart, ToolArgsDelta), 92-103 (ToolFinish), 105-132 (StepFinish), 134-146 (Steered), 148-167 (RunFinish), 169-183 (Nested), 199-211 (wire discriminators), 325-350 (Nested.UnmarshalJSON), 352-405 (UnmarshalEvent)
  - weft/facade.go:696 (Event), 708-775 (the event aliases), 786 (Nested), 791 (UnmarshalEvent)
  - weft/core/model.go:20-26 (Usage), 42-49 (StopReason), 51-62 (ModelInfo), 274-282 (ModelToolCallDelta)
  - weft/core/loop.go:290 (RunFinish), 300 (RunStart), 482 (StepStart), 632-670 (deltas), 775-784 (StepFinish usage), 839 (Steered), 1245-1263 (Seq, Nested)
  - weft/core/subagent.go:166-182 (childRunID)
  - weft/core/observe.go:814-815 (final_answer, parked)
  - weft/core/manifest.go:233-241 (custom)
  - weft/core/agent.go:590 (has_tool_call), 600 (step_count_is)
  - weft/docs/adr/0004-event-ordering.md (Decision; amendments 2026-09-10, 2026-09-14, 2026-09-18, 2026-09-19)
  - weft/AGENTS.md:151-166 (block 3b), 677-684 (rules 3 and 4)
  - weft/CHANGELOG.md:2963 (InstructionsHash), 2972 (LatencyMS, TTFTMS), 6452 (StepFinish doc), 6554 (RunID), 6559 (snapshots)
  - weft/example_test.go:143 (ExampleUnmarshalEvent)
  - weft/core/request_test.go:918 (ExampleRunStart_instructionsHash)
  - the stream below was printed by json.Marshal over agt.Stream(...).Events() against weft v0.17.0 with wefttest.Script (echo with weft.Sequential(); identical across three runs apart from latency_ms and ttft_ms)
---

# Event types

A run reports its progress as [`weft.Event`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#Event) values: [`agt.Stream`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#Agent.Stream) yields them from `Events()`, and a [`weft.Tap`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#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](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2); how to consume a stream is in [Stream a run's events](https://weftgo.dev/docs/guides/streaming/).

## Event types at a glance

In the order a run emits them:

| Event | Wire `type` | `Seq` | Emitted when |
|---|---|---|---|
| [`RunStart`](#runstart) | `run_start` | — | First event of every run |
| [`StepStart`](#stepstart) | `step_start` | — | The model is being called for a step |
| [`ReasoningDelta`](#reasoningdelta) | `reasoning_delta` | — | An increment of provider reasoning |
| [`TextDelta`](#textdelta) | `text_delta` | — | An increment of assistant text |
| [`ToolArgsDelta`](#toolargsdelta) | `tool_args_delta` | — | The model is still writing a tool call |
| [`ToolStart`](#toolstart) | `tool_start` | ✓ | A tool call began |
| [`Nested`](#nested) | `nested` | ✓ | One event of a subagent's child run |
| [`ToolFinish`](#toolfinish) | `tool_finish` | ✓ | A tool call completed, successfully or not |
| [`StepFinish`](#stepfinish) | `step_finish` | — | The step's model call and its tools are done |
| [`Steered`](#steered) | `steered` | ✓ | The run's steering source delivered messages |
| [`RunFinish`](#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.

## Event

`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`](https://github.com/weftgo/weft/blob/v0.20.2/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](https://github.com/weftgo/weft/blob/v0.20.2/docs/adr/0004-event-ordering.md)) |

## Ordering rules

The loop guarantees these orders; tests pin them ([ADR 0004](https://github.com/weftgo/weft/blob/v0.20.2/docs/adr/0004-event-ordering.md), [rules 3 and 4](https://github.com/weftgo/weft/blob/v0.20.2/AGENTS.md#the-rules-do-not-break-these-tests-pin-them)).

| 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](https://weftgo.dev/docs/reference/glossary/#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:

```text
{"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

[`RunStart`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#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`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#RunStart.ID) | `string` | `id` | The run's id, the same as `Run.ID()` and `RunResult.ID`; set it with [`weft.RunID`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#RunID). A subagent's child run is `<parent>/<step>/<call>`, or `<parent>/resume/<call>` for a call run under `Approve` |
| [`Model`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#RunStart.Model) | [`ModelInfo`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#ModelInfo) | `model` | `{provider, name}` when the model implements `Info() ModelInfo`; the zero value otherwise |
| [`Agent`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#RunStart.Agent) | `string` | `agent`, omitted when empty | The agent's [`weft.Name`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#Name) |
| [`InstructionsHash`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#RunStart.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 `PromptSnippet`s 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`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#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`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#example-RunStart-InstructionsHash) compares it with the sha256 of the configured prompt.

## StepStart

[`StepStart`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#StepStart) reports that the model is being called for a [step](https://weftgo.dev/docs/reference/glossary/#step).

| Field | Type | Wire | Meaning |
|---|---|---|---|
| [`RunID`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#StepStart.RunID) | `string` | `run_id` | The run this event belongs to |
| [`Index`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#StepStart.Index) | `int` | `index` | The step's index, from 0 |

## ReasoningDelta

[`ReasoningDelta`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#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`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#ReasoningDelta.RunID) | `string` | `run_id` | The run this event belongs to |
| [`Text`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#ReasoningDelta.Text) | `string` | `text` | The reasoning text increment |

## TextDelta

[`TextDelta`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#TextDelta) is an increment of assistant text.

| Field | Type | Wire | Meaning |
|---|---|---|---|
| [`RunID`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#TextDelta.RunID) | `string` | `run_id` | The run this event belongs to |
| [`Text`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#TextDelta.Text) | `string` | `text` | The text increment |

## ToolArgsDelta

[`ToolArgsDelta`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#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`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#ToolArgsDelta.RunID) | `string` | `run_id` | The run this event belongs to |
| [`Name`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#ToolArgsDelta.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`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#ToolArgsDelta.Args) | `string` | `args` | A fragment of the arguments' JSON, not a complete value |

## ToolStart

[`ToolStart`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#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`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#ToolStart.RunID) | `string` | `run_id` | The run this event belongs to |
| [`Seq`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#ToolStart.Seq) | `int64` | `seq` | The run's event counter at emission |
| [`CallID`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#ToolStart.CallID) | `string` | `call_id` | The model's id for the call; the matching `ToolFinish` carries the same |
| [`Name`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#ToolStart.Name) | `string` | `name` | The tool's name |
| [`Args`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#ToolStart.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

[`Nested`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#Nested) wraps one event of a child run started by a [`weft.Subagent`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#Subagent) tool. The envelope belongs to the parent run; the wrapped event belongs to the child.

| Field | Type | Wire | Meaning |
|---|---|---|---|
| [`RunID`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#Nested.RunID) | `string` | `run_id` | The parent run's id |
| [`Seq`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#Nested.Seq) | `int64` | `seq` | From the parent's counter, so the parent stream stays totally ordered with the child's events in place |
| [`CallID`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#Nested.CallID) | `string` | `call_id` | The parent's tool call that owns the child run |
| [`Event`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#Nested.Event) | `Event` | `event` | Any child event, with its own `RunID` and `Seq`; a grandchild's event is a `Nested` inside a `Nested` |

[`Nested.UnmarshalJSON`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#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

[`ToolFinish`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#ToolFinish) reports that a tool invocation completed, successfully or not.

| Field | Type | Wire | Meaning |
|---|---|---|---|
| [`RunID`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#ToolFinish.RunID) | `string` | `run_id` | The run this event belongs to |
| [`Seq`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#ToolFinish.Seq) | `int64` | `seq` | The run's event counter at emission |
| [`CallID`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#ToolFinish.CallID) | `string` | `call_id` | The call's id, as on its `ToolStart` |
| [`Name`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#ToolFinish.Name) | `string` | `name` | The tool's name |
| [`Content`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#ToolFinish.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`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#ToolFinish.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](https://weftgo.dev/docs/concepts/errors/)) |

## StepFinish

[`StepFinish`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#StepFinish) reports that a step is complete: the model call finished and, when it requested tools, they have run.

| Field | Type | Wire | Meaning |
|---|---|---|---|
| [`RunID`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#StepFinish.RunID) | `string` | `run_id` | The run this event belongs to |
| [`Index`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#StepFinish.Index) | `int` | `index` | The step's index, as on its `StepStart` |
| [`Reason`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#StepFinish.Reason) | [`StopReason`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#StopReason) | `reason` | `stop`, `tool_calls` or `max_tokens` |
| [`Usage`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#StepFinish.Usage) | [`Usage`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#Usage) | `usage` | This step's model call alone. Subagent usage rolls into `RunResult.Usage` and `RunFinish.Usage`, not here |
| [`Raw`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#StepFinish.Raw) | `string` | `raw`, omitted when empty | The provider's own stop reason when `Reason` was approximated; empty when the mapping was exact |
| [`LatencyMS`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#StepFinish.LatencyMS) | `int64` | `latency_ms`, omitted when 0 | From the start of the model chain's `Stream` to the stream's `ModelFinish` |
| [`TTFTMS`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#StepFinish.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

[`Steered`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#Steered) reports messages the run's steering source ([`weft.Steering`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#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`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#Steered.RunID) | `string` | `run_id` | The run this event belongs to |
| [`Seq`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#Steered.Seq) | `int64` | `seq` | The run's event counter at emission |
| [`Step`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#Steered.Step) | `int` | `step` | The step whose drain point delivered the messages |
| [`Messages`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#Steered.Messages) | `[]Message` | `messages` | The delivered messages, role `user`, as a snapshot; the transcript holds its own copy |

## RunFinish

[`RunFinish`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#RunFinish) is always the final event of a successful run, a parked one included.

| Field | Type | Wire | Meaning |
|---|---|---|---|
| [`RunID`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#RunFinish.RunID) | `string` | `run_id` | The run this event belongs to |
| [`Usage`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#RunFinish.Usage) | [`Usage`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#Usage) | `usage` | The run's total, subagent runs included |
| [`Steps`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#RunFinish.Steps) | `int` | `steps` | The number of steps the run took |
| [`Pending`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#RunFinish.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`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#RunFinish.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](https://weftgo.dev/docs/reference/glossary/#approval-boundary) |
| `has_tool_call:<tool>` | [`weft.HasToolCall`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#HasToolCall) fired; several names are joined with commas (`has_tool_call:a,b`) |
| `step_count_is:N` | [`weft.StepCountIs(N)`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#StepCountIs) fired |
| `output_submitted` | The structured-output tool received a valid call ([`weft.Output`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#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?](https://weftgo.dev/docs/concepts/budgets-and-stopping/)).

## Unmarshal events

A recorded stream decodes back into typed events with `weft.UnmarshalEvent`, one JSON object at a time. The package example [`ExampleUnmarshalEvent`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#example-UnmarshalEvent) decodes a `tool_start` line and prints its name, call id, `Seq` and arguments:

```text
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

[`weft.UnmarshalEvent`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#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

- [Stream a run's events](https://weftgo.dev/docs/guides/streaming/)
- [Delegate to another agent (subagents)](https://weftgo.dev/docs/guides/subagents/)
- [The record contract](https://weftgo.dev/docs/reference/record-contract/): how events become `event` and `delta` records
- [Glossary](https://weftgo.dev/docs/reference/glossary/)
- [Package weft on pkg.go.dev](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2)
