ADR 0022doc/{zh,en}/adr/0022-structured-run-progress.md

ADR 0022: Structured Run Progress

Status: accepted (the owner's TUI decisions of 2026-12-04, in the terminal UI design of PR #268, gap G1). Built in this change.

Status: accepted (the owner's TUI decisions of 2026-12-04, in the terminal UI design of PR #268, gap G1). Built in this change.

Context

A runtime reports progress as one string (RuntimeHost.Progress(ctx, text), input and output contract section 3). The agent composes it from the todo list, the streamed text and one line per tool call. A channel can only show that string, and the input contract deferred typed progress "until such an adapter exists". The terminal UI is that adapter: it draws the plan, each tool call with its state and result, the streamed text and token use, and it follows runs of the same person started on other channels. The Feishu progress card of the same design draws from the same facts.

Decision

  1. plugin.ProgressReporter, part of RuntimeHost. ProgressView(ctx, ProgressView) error reports a run's progress as data: todos, steps (key, tool, summary, state of running, ok, failed or note, result), text and usage (tokens_in, tokens_out, context_pct). Each report replaces the whole view. It sits beside Progress, which stays the text every channel shows. Process plugins call it as host/progress_view.
  2. Best effort and bounded. Losing a view is harmless, as with the text. The Host keeps a view within bounds: the last 50 steps, 50 todos, the last 8 KiB of text, and lines cut at 300 characters. A runtime that never reports one keeps working. A child run's view is dropped: its parent's step for the delegate call stands for it.
  3. Kept only while the run runs (owner, 2026-12-04). The Host holds the latest view of each running run in memory and stores nothing. A run that is not running, or whose runtime reports none, answers an empty view.
  4. Offered to the person's app clients. ClientHost gains RunActivity (the latest view of a run of the person; another's is run.unknown) and WatchActivity (the views of the person's running runs as they change, at most every 100 ms per run, latest first when a reader falls behind). httpapi serves them as GET /v1/runs/{id}/activity and as the stream event run.activity, which has no id and is not replayed.
  5. No channel branch. The text and its once-a-second channel delivery are unchanged. Channels that draw from the view use the same public contract.

Consequences

  • ◆The agent reports a view with every progress text: a tool call is a step from its start to its result, a notice such as "context compacted" is a note step, and usage follows each model call.
  • ◆RuntimeHost has one more method. Builtin runtimes get it from the Host; process plugins use the new RPC method. A runtime written before this change still works, since an empty view is valid.
  • ◆Views cost memory only while runs run, bounded per run. Nothing reaches the database, the fact log or the trace.
  • ◆The Feishu progress card can be drawn from the view in a later slice, without another Host change.