Expand description
Plugin extension points.
All cross-cutting concerns plug into the loop through these traits.
No inline if special_case_X branches inside the loop; keep hook
discipline in explicit extension points.
Two families:
-
Capability traits (this module) —
BeforeToolCall,AfterToolCall,ContextTransform,EventObserver,SteeringSource,FollowUpSource. Each is narrow: a hook that needs the assistant message gets the assistant message, never a fat&mut LoopState. New capabilities add a new trait; they do not widen an existing one. -
Pluginmarker — a single registry entry that may implement one or more capability traits.AgentBuilderholds plugins asArc<dyn Plugin>and dispatches to whichever capabilities the plugin declares viaPlugin::capabilities.
Structs§
- After
Tool Call Context - Read-only context handed to an
AfterToolCallhook. - After
Tool Decision - Override returned by an
AfterToolCallhook. Each field is opt-in: omitted fields keep the original tool result. No deep merge. - Before
Tool Call Context - Read-only context handed to a
BeforeToolCallhook. - Before
Tool Decision - Decision returned by a
BeforeToolCallhook. - Channel
Steering tokio::sync::mpsc-backed steering source. Producer side (SteeringHandle) lets external code call.steer(message)from anywhere; consumer side implementsSteeringSourceand drains the channel each batch.- Plugin
Capabilities - Bitset of which extension points a plugin participates in.
- Steering
Handle - Tool
Gate Context - Read-only loop state handed to a
ToolGateso its decision is a pure function of observables, not of internal flag bookkeeping. New fields are additive — gates that don’t care can ignore them. - Transform
Context - Read-only context handed to a
ContextTransformhook.
Enums§
- Tool
Gate Class - How a tool gate should compose with explicit recovery owners.
Traits§
- After
Tool Call - Hook that runs after tool execution, before the result is appended to history. May override the result, flip the error flag, or vote to terminate.
- Before
Tool Call - Hook that runs after argument validation, before tool execution.
- Context
Transform - Hook that transforms the message slice before it’s converted to the LLM provider format.
- Event
Observer - Pure observation hook. Logs, telemetry, replay writers. Cannot change
loop state — the event sink (
crate::event::EventSink) is the formal channel; this trait exists so plugins can subscribe declaratively alongside their other hooks instead of wiring a separate sink. - Follow
UpSource - Source of “follow-up messages” — extra messages the loop should process after the agent would otherwise stop.
- Plugin
- A registered extension. Each plugin declares which capability traits
it implements via
PluginCapabilities. - Steering
Source - Source of “steering messages” — extra messages the user / harness wants to inject mid-run.
- Tool
Gate - Per-turn allowlist of tool names the model may invoke.