Skip to main content

Module forward

Module forward 

Source
Expand description

Live subagent transcript forwarding (issue #6359, spec 068-subagent-transcript-forward; token-level intra-turn streaming, issue #6456, FR-002b).

Opt-in forwarding of a running subagent’s text/thinking output to the TUI runtime detail view and/or a --bare stdout sink, under the single forward_transcript config flag. Granularity depends on provider support: when the provider’s native streaming-with-tools path is available (agent_loop.rs drives it), text/thinking chunks are forwarded as partial deltas within a turn; otherwise (or when streaming fails) the full, untruncated text/thinking output of one completed LLM turn is forwarded once the turn completes (FR-002a, unchanged). Pipeline shape:

agent_loop.rs (sync, non-blocking) --try_send(RawChunk)--> per-task mpsc (cap 128)
    -> manager-owned per-task drain: sanitize (the ONE sanitize point) -> dispatch to sinks

RawChunk only ever travels on the ingress channel; SanitizedChunk is constructed exclusively by the drain’s sanitize step and is the only type any sink can receive (NFR-005 enforced structurally, not by convention).

§Design contract: deltas are ephemeral, display-only (FR-002b)

Every chunk sent through ForwardSender::send_text / ForwardSender::send_thinking — whether it carries a whole turn’s text or one streamed delta — travels on the same tail-drop mpsc and MUST be treated as display-only. A dropped chunk is a display gap, never a correctness error: the loop’s own accumulated response text (returned from run_agent_loop’s LLM call and pushed into messages) is assembled independently of whether any given delta was actually forwarded, and the guaranteed terminal chunk (see ForwardSender::send_terminal) marks the one point a consumer may treat as authoritative for “this run reached a terminal state”. No consumer (TUI ring buffer, --bare sink, a future sink) may reconstruct the subagent’s conversational state — let alone feed it back into the parent’s LLM context — by concatenating forwarded chunks; deltas never enter any LLM context, they exist purely for live human-facing display.

Structs§

ForwardSurfaces
Which consumer surfaces are active for this session, fixed at session start (session scope, not hot-swappable — a headless run does not gain a TUI mid-session).