pub struct SubagentFilter { /* private fields */ }Expand description
The transformer behind SubagentVisibility.
Both modes keep the model of the stream a consumer expands chunks by — one
chunk stream per owner, ended by what AG-UI 1.0 says ends it — because a
*_CHUNK event that names no id is resolved through its attribution on
the consuming side, and stripping the attribution would send it to the
wrong stream. Such a chunk is given the id it resolves to before its tag
goes.
They keep that model twice: once for the stream the agent emits, and once
for the stream the filter sends, which is the one a consumer follows. The
two differ, because an event that leaves its subagent’s lane ends a chunk
stream in the lane it arrives in. Two subagents that stream at once take
turns ending each other’s stream once Inline
has put both in the parent’s lane, and the state a subagent publishes,
which Hidden keeps as the parent’s, ends
the parent’s. The agent’s stream is still open then, so its next chunk
says only what a continuation says, and on the consuming side that chunk
opens the item again. It is given what opens it, from what the agent
opened the stream with: toolCallName and parentMessageId for a tool
call, role and name for a message. A chunk whose stream the consumer
still holds is sent as it is.
Hidden additionally remembers what each
subagent owns — messages, tool calls, activities — for the rest of the
run, not only while they are open, so an untagged continuation, re-open,
patch or result for a subagent’s entity is dropped with the rest of it
rather than leaking into the parent’s stream. That is the owner-aware
verifier’s reading too: the first writer owns the id, and an absent tag
agrees with any owner. An entity the consumer has seen opened keeps that
visibility until it closes, whatever a snapshot says about its owner
meanwhile — a consumer must never be left with a message it saw opened
and never sees closed.
Implementations§
Source§impl SubagentFilter
impl SubagentFilter
Sourcepub fn new(mode: SubagentVisibility) -> Self
pub fn new(mode: SubagentVisibility) -> Self
A filter for mode.
Sourcepub fn mode(&self) -> SubagentVisibility
pub fn mode(&self) -> SubagentVisibility
The mode this filter applies.
Trait Implementations§
Source§impl Debug for SubagentFilter
impl Debug for SubagentFilter
Source§impl StreamTransformer for SubagentFilter
impl StreamTransformer for SubagentFilter
Source§fn seed(&mut self, history: &[Message])
fn seed(&mut self, history: &[Message])
History, as the RUN_STARTED echo would carry it: what a subagent
owned in an earlier run stays hidden in this one, echo or not.