Skip to main content

Module subagent_watch

Module subagent_watch 

Source
Expand description

Watch journal: what a running subagent has shown so far, for clients that watch it in its own thread view.

A worker’s real message history only reaches SubagentState when its turn ends, so a live view can’t be built from it. Instead the worker’s event loop (tools/subagent/drive.rs) records every presentation event here, and clients page through it with SessionQuery::SubagentWatch (since = the next_seq of their previous page). The first page is the whole run so far; later pages are just what is new.

Bounded on purpose:

  • consecutive text / thinking / tool-output deltas coalesce into one entry — but only into an entry no reader has seen yet (sealed), so a client paging by seq never misses an append;
  • large tool inputs and results are capped per entry;
  • past JOURNAL_MAX_BYTES the oldest entries drop and readers asking for them get truncated: true.

Every entry is stamped with when it was recorded (ms on the journal’s own monotonic clock), and each page says what that clock read when it was taken (at_ms, now_ms). A client only applies a page when it polls — only while the view is focused, and the first page is the whole run so far — so its own arrival times say nothing about when a worker’s tool started or how long it ran. With the stamps it can place each event in its own clock and show the same running clock and └─ ok … Ns duration the main thread shows.

Raw provider error text never enters the journal (same rule as SubagentState::safe_fail): errors carry only their category label, and retry notices are not recorded.

Structs§

WatchJournal
Bounded, append-only record of a worker’s presentation events.
WatchPage
One page of a worker’s journal (SessionQuery::SubagentWatch reply).

Enums§

WatchEvent
One presentation event of a worker, in the shape the TUI’s transcript applies (stream_handler::apply_transcript_event).

Constants§

JOURNAL_MAX_BYTES
Total retained bytes per worker before the oldest entries drop.
PAGE_MAX_BYTES
Most bytes of events one page returns; the client pages on from next_seq.
TOOL_PAYLOAD_MAX_BYTES
Cap on one tool input (serialized) or one tool result.