Expand description
§wabot-feature-tool
The tool runtime shared by mindsets (end-user chatbots) and
agents (driven programmatically). Port of
wabot-ts/src/feature/tool.
It was extracted from MindsetOperator when agents arrived and
needed the same machinery: turn a set of #[tools] types into the
schema an LLM sees (ToolInvoker::schema), and dispatch the
model’s function calls back into them (ToolInvoker::call) with
validation and gating.
§Gating
ToolGate is what makes mindset→agent delegation safe. A tool
set marked expose_to_mindsets = false is invisible to a mindset
unless the delegation allow-lists it explicitly, so a chatbot can
never reach a privileged agent tool by accident:
ToolInvoker::new(container, tools)
.with_gate(ToolGate::default().for_mindset().allow(["read_catalog"]))A blocked call doesn’t error — it returns TOOL_NOT_ALLOWED to the
model, which is a thing the model can read and act on, unlike an
exception.
Structs§
- Tool
Definition - A tool the model can call: its schema plus a type-erased async
body.
#[tools]emits one of these per method. - Tool
Gate - Which tools are reachable in a given context.
- Tool
Invoker - Turns tool definitions into an LLM schema and dispatches calls.
- Tool
Parameter - One parameter of a tool, as the model sees it.
- Tool
Schema - Provider-neutral tool description shipped to the LLM. Shared by mindsets and agents; the chat adapters know this type.
Enums§
- Tool
Error - What a tool invocation can go wrong with.
Constants§
- OPTIONAL_
HINT - Told to the model for every optional argument. See
normalize_optional_argumentsfor why an optional argument is presented as one the model must still answer.
Functions§
- normalize_
optional_ arguments - Drop optional arguments the model declined to fill in.
- parse_
tool_ arguments - Parse a tool’s JSON arguments into its args struct: normalize the optional ones, deserialize, then validate.
- schema_
from_ model_ info - Describe a
#[derive(Validate)]struct to a model as a tool. - type_
label
Type Aliases§
- Tool
Invoke Fn - Deserialize + validate + dispatch + stringify, all inside the closure the macro emits.