Skip to main content

Module transform

Module transform 

Source
Expand description

The one extension point: rewriting the event stream on its way out.

Everything that wants to observe, drop, rewrite or add events implements StreamTransformer. There is deliberately no second mechanism — an early draft of this crate also carried a builder of map_content / map_result / map_interrupt closures ported from the .NET SDK, which meant two ways to do the same thing and a pile of Box<dyn Fn>. Those hooks are built-in transformers now: see ToolResultToState. So is the compatibility knob for consumers that predate subagents: SubagentVisibility.

Transformers run in the order they were added, each seeing what the previous one produced, before the ordering verifier sees anything. That order is what makes FilterToolCalls safe: the verifier never sees the half of a tool call that was dropped.

let chain = TransformerChain::new()
    .with(FilterToolCalls::deny(["internal_debug"]))
    .with(ToolResultToState::snapshot("load_document").replacing());
assert_eq!(chain.len(), 2);

Structs§

FilterToolCalls
Drops whole tool calls by tool name.
SubagentFilter
The transformer behind SubagentVisibility.
ToolResultToState
Promotes a named tool’s result into a state event.
TransformerChain
Transformers applied in sequence.

Enums§

SubagentVisibility
What a consumer sees of an agent’s subagents.

Traits§

StreamTransformer
Rewrites events on their way from an agent to the transport.