Skip to main content

Crate wabot_feature_tool

Crate wabot_feature_tool 

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

ToolDefinition
A tool the model can call: its schema plus a type-erased async body. #[tools] emits one of these per method.
ToolGate
Which tools are reachable in a given context.
ToolInvoker
Turns tool definitions into an LLM schema and dispatches calls.
ToolParameter
One parameter of a tool, as the model sees it.
ToolSchema
Provider-neutral tool description shipped to the LLM. Shared by mindsets and agents; the chat adapters know this type.

Enums§

ToolError
What a tool invocation can go wrong with.

Constants§

OPTIONAL_HINT
Told to the model for every optional argument. See normalize_optional_arguments for 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§

ToolInvokeFn
Deserialize + validate + dispatch + stringify, all inside the closure the macro emits.