Expand description
Agents watch (POST /api/v1/agent/watch): replay the recent transcript of an agent, then tail it,
for a leader that supervises a worker without opening a pane
(docs/specs/SPEC_ALWAYS_AVAILABLE_AGENTS_2026_10_27.md §5.1). It reads the same output file a pane
reads, by the agent’s block, so an agent with no pane (parked, or stopped) can be watched too.
A call returns whole lines and next, a byte position. Pass next back as after to get what was
written since; with wait_seconds the call waits for a new line instead of answering empty. Without
after it is the replay: the last max_lines lines. The position is a byte offset into the file, so
a line being written is not returned until it is complete, and a read costs the new bytes, not the
whole transcript. If the file shrank (a fresh session) the answer says reset and replays.
Who may watch: the same as transcript for an agent on this host, any agent on this machine; the
call is not an action on the watched agent and is not audited.
Structs§
- Lines 🔒
- Whole lines read from a window of the file, and where the next read starts.
- Read 🔒
- What one read of the transcript gave.
- Source 🔒
- The transcript, whole in memory (an archived session) or read in spans from the file store the pane reads: the agent’s own zone in the global transcript store when it has content, else the block’s.
- Watch
Request 🔒
Constants§
- CHUNK_
BYTES 🔒 - The most one tail read takes.
- DEFAULT_
LINES 🔒 - MAX_
LINES 🔒 - MAX_
LINE_ 🔒CHARS - The longest a line is shown; a tool result can be much larger.
- MAX_
SCAN_ 🔒BYTES - The most searched for the end of one line before it is given up on.
- MAX_
WAIT_ 🔒SECONDS - The longest a call waits for a new line.
- OUTPUT_
FILE 🔒 - The zone’s file the transcript is.
- POLL_
EVERY 🔒 - READ_
ATTEMPTS 🔒 - Times a read starts again because the file was swapped while it was read.
- REPLAY_
BYTES 🔒 - The most a replay reads back from the end of the file.
Functions§
- counted_
gen 🔒 - The counted generation of the transcript file,
Nonewhen it has none. - handle_
agent_ 🔒watch - lines_
of 🔒 - The whole lines in
data, which starts at bytefromof the file.mid_line:frommay fall inside a line, so the first piece is dropped.from_end: keep the lastmaxlines (a replay) rather than the first (a tail). A last line with no newline yet is not returned andnextstays before it. - read_
from 🔒 - One read of an opened source.
- read_
lines 🔒 - The lines after
after, or the tail of the transcript whenafterisNoneor no longer valid. A line longer than a read is searched for its end, up toMAX_SCAN_BYTES, and a longer one is skipped with a marker line, so a cursor never stops in front of a line or lands inside one. - shown 🔒
- watch 🔒
- zone_
is_ 🔒live - Whether the agent’s zone is still the copy being written: false when the block’s own copy is clearly newer
(the zone stopped receiving lines), so a watch reads what the agent is writing now and agrees with
Agents transcript(TranscriptSource::resolve, the same rule), not hours-old lines from the zone.