Skip to main content

Module plugin

Module plugin 

Source
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:

  1. 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.

  2. Plugin marker — a single registry entry that may implement one or more capability traits. AgentBuilder holds plugins as Arc<dyn Plugin> and dispatches to whichever capabilities the plugin declares via Plugin::capabilities.

Structs§

AfterToolCallContext
Read-only context handed to an AfterToolCall hook.
AfterToolDecision
Override returned by an AfterToolCall hook. Each field is opt-in: omitted fields keep the original tool result. No deep merge.
BeforeToolCallContext
Read-only context handed to a BeforeToolCall hook.
BeforeToolDecision
Decision returned by a BeforeToolCall hook.
ChannelSteering
tokio::sync::mpsc-backed steering source. Producer side (SteeringHandle) lets external code call .steer(message) from anywhere; consumer side implements SteeringSource and drains the channel each batch.
PluginCapabilities
Bitset of which extension points a plugin participates in.
SteeringHandle
ToolGateContext
Read-only loop state handed to a ToolGate so 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.
TransformContext
Read-only context handed to a ContextTransform hook.

Enums§

ToolGateClass
How a tool gate should compose with explicit recovery owners.

Traits§

AfterToolCall
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.
BeforeToolCall
Hook that runs after argument validation, before tool execution.
ContextTransform
Hook that transforms the message slice before it’s converted to the LLM provider format.
EventObserver
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.
FollowUpSource
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.
SteeringSource
Source of “steering messages” — extra messages the user / harness wants to inject mid-run.
ToolGate
Per-turn allowlist of tool names the model may invoke.