Skip to main content

Module tool_dispatch

Module tool_dispatch 

Source
Expand description

Tool dispatch — routes tool calls from inference to the registry. Tool execution dispatch — sequential, parallel, and split-batch.

Routes tool calls from the inference loop to execution, handling approval flow, parallelization, and result recording.

§Dispatch flow

Model emits tool calls
  → Classify each call's effect (ReadOnly / LocalMutation / Destructive)
  → Split into read-only batch + mutation batch
  → Read-only tools: execute in parallel (tokio::join)
  → Mutation tools: execute sequentially with approval
  → Record results in DB + inject into conversation
  • crate::tools — tool definitions and ToolRegistry::execute()
  • crate::approval — approval mode and effect classification
  • sub_agent_dispatch.rsInvokeAgent handling (needs provider access)
  • approval_flow.rs — interactive approval UI flow

§Design (DESIGN.md)

  • Tool Dispatch: Match Statement (P2): Tools are dispatched via a match in ToolRegistry::execute(), not a HashMap<String, Box<dyn Tool>>. Rust’s exhaustive matching catches missing handlers at compile time.