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§
- Filter
Tool Calls - Drops whole tool calls by tool name.
- Subagent
Filter - The transformer behind
SubagentVisibility. - Tool
Result ToState - Promotes a named tool’s result into a state event.
- Transformer
Chain - Transformers applied in sequence.
Enums§
- Subagent
Visibility - What a consumer sees of an agent’s subagents.
Traits§
- Stream
Transformer - Rewrites events on their way from an agent to the transport.