pub trait Tool: Send + Sync {
// Required methods
fn meta(&self) -> &ToolMeta;
fn invoke(&self, call: &ToolCall) -> Result<ToolOutcome, AxError>;
// Provided methods
fn subject(&self, _call: &ToolCall) -> Result<GateSubject, AxError> { ... }
fn writes(&self, _call: &ToolCall) -> Writes { ... }
}Expand description
The tool port. Adapters: runtime L0 three, browser, protocol; second adapter: citysim scripted tools.
Send, because a bench of tools is driven on a pool thread rather
than on the thread that built it (crates/sprawling/Spec.lean §8-44). A tool that
holds something a thread cannot give up has no place on a bench.
Sync, and invoke takes &self, because the read-only calls at
the head of a wave run at the same time (crates/runtime/Spec.lean §8-3), so one
tool can be inside invoke on several threads at once. A tool with
state of its own keeps that state behind its own lock.
Required Methods§
Provided Methods§
Sourcefn subject(&self, _call: &ToolCall) -> Result<GateSubject, AxError>
fn subject(&self, _call: &ToolCall) -> Result<GateSubject, AxError>
What this call is about, read by the grammar this tool already parses its arguments with.
The default is GateSubject::None rather than an inference: a
bench that guessed a subject from an argument name has already
been wrong once. None says the tool read the call and it names
none; a door then judges it against this machine, never skips it.
§Errors
Refuses arguments this tool cannot read - the same refusal its
invoke would produce.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".