Expand description
Tool surface.
AgentTool is the only contract the loop knows about. Tools own their
parameter schema, validation, and execution. The loop dispatches and
emits events.
Termination is a tool decision: a tool result with terminate: true
ends the run if every tool in the batch agrees (unanimous). One tool
wanting to stop does not stop the batch.
Re-exports§
pub use crate::types::ToolResultBlock;
Structs§
- Tool
Call - A tool call request emitted by the model.
- Tool
History Policy - Tool-authored context-retention hints for history transforms.
- Tool
Registry - Registry of available tools, keyed by name.
- Tool
Result - Result of a tool execution.
Enums§
- Execution
Mode - Loop-wide tool dispatch mode. Per-tool sequential dispatch is
requested via
AgentTool::requires_exclusive_sandbox; this enum is for pinning the whole loop (e.g. deterministic eval harness).
Constants§
- ARG_
PARSE_ ERROR_ MARKER - Reserved object key used to mark an argument value that the provider
stream layer could not parse as JSON. Tool args are always meant to be
JSON objects; when the model emits malformed JSON (e.g. trailing
comma, missing value) the provider wraps the failure in a sentinel
object carrying this key plus the raw payload, so the loop can emit
a structured “your JSON was malformed” error instead of the cryptic
“invalid type: string, expected struct …” that comes from
serde_json::from_valuerunning over aValue::Stringfallback. - ARG_
PARSE_ RAW_ MARKER - Companion to
ARG_PARSE_ERROR_MARKER: holds the raw JSON-ish payload the model sent, so the model can see exactly what it produced and fix the syntax in its next turn.
Traits§
- Agent
Tool - A tool the agent can call.
- Typed
Agent Tool - Implement this for tools whose argument shape is a typed Rust
struct/enum. The blanket
AgentToolimpl below derivesparameters_schemafromArgsvia schemars and centralizes theValue → Argsparse path. New tools should implementTypedAgentTool, notAgentTooldirectly; existing tools are migrated incrementally.
Functions§
- arg_
parse_ error_ value - Build a
Valuethat carries an argument-parse error for the loop to surface. Use from any provider stream layer that decoded a tool call whoseargumentsstring was not valid JSON. - detect_
arg_ parse_ error - If
argswas produced byarg_parse_error_value, return(error, raw). Otherwise returnNone.
Type Aliases§
- Tool
Update Sink - Sink the tool can use to publish partial progress while running.