Skip to main content

dispatch_tool

Function dispatch_tool 

Source
pub async fn dispatch_tool(
    tool_call: &ToolCall,
    user_tools: &HashMap<String, ToolHandler>,
    agent: &Prompty,
    parent_inputs: Option<&Value>,
) -> String
Expand description

Dispatch a tool call using 3-layer resolution.

Resolution order (matches TypeScript):

  1. user_tools — the TurnOptions.tools map (runtime-provided handlers)
  2. Global name registry — tools registered via register_tool()
  3. Kind handler — handlers registered via register_tool_handler() for the tool’s kind from agent.tools, with fallback to "*" wildcard

Before dispatching, resolves tool bindings from parent_inputs into args.

Returns an error message string (never throws) — the LLM can recover.