Skip to main content

SubagentFilter

Struct SubagentFilter 

Source
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

Source

pub fn new(mode: SubagentVisibility) -> Self

A filter for mode.

Source

pub fn mode(&self) -> SubagentVisibility

The mode this filter applies.

Trait Implementations§

Source§

impl Debug for SubagentFilter

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl StreamTransformer for SubagentFilter

Source§

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.

Source§

fn replay(&mut self, sent: &[Event])

What was sent is what a consumer holds, so the chunk streams it left open are the ones a consumer has open now.

Source§

fn transform(&mut self, event: Event) -> Vec<Event>

Rewrites one event into zero or more events.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more