pub struct ToolRoundCtx<'a> {
pub context: &'a RunContext,
pub round: usize,
pub registry: &'a ToolRegistry,
pub state: &'a SharedState,
pub events: &'a Option<Arc<dyn EventChannel>>,
}Expand description
What a round policy gets handed to execute one tool round.
The agent constructs the context and passes it by value to your
ToolRoundExecutor::execute_round; you only read it, and execute
calls through run — the framework-owned per-call
mechanics (span, events, registry dispatch) stay out of your hands, so
a custom policy reorders / parallelizes / gates calls without
reimplementing any of that. See ToolRoundExecutor for a working
example.
Fields§
§context: &'a RunContextRun context (the run id is the correlation key carried by spans and events).
round: usizeThe current round number (carried into the tool span).
registry: &'a ToolRegistryThe tool registry (call dispatch + protected declarations).
state: &'a SharedStateShared state, injected into every tool call.
events: &'a Option<Arc<dyn EventChannel>>The observation channel (None when not attached).
Implementations§
Source§impl ToolRoundCtx<'_>
impl ToolRoundCtx<'_>
Sourcepub async fn run(&self, call: ToolCall) -> ToolCallOutcome
pub async fn run(&self, call: ToolCall) -> ToolCallOutcome
Dispatch one tool call with the framework’s standard mechanics and return its outcome.
Call this for each call your policy decides to run: the call is
dispatched to the registry (tool span + ToolStarted / ToolCompleted
events included), and the outcome carries immediate output text, a
registry error text, or an effect request. Tool failures are not
errors here; they ride along in content
and are fed back to the model.
Takes &self rather than &mut self: the mechanics are all shared
borrows, so a policy can hold multiple run futures concurrently
(see the parallel example on
with_tool_round_executor).