Skip to main content

Module tool_dispatch

Module tool_dispatch 

Source
Expand description

Tool-invocation runtime callbacks.

Provides infrastructure for detecting, parsing, and dispatching tool calls produced by language models during generation.

§Overview

Different model families emit tool calls using different delimiter syntax:

  • LLaMA 3: <|tool_call|>{ ... }<|/tool_call|>
  • Qwen: <tool_call>{ ... }</tool_call>
  • Mistral: [TOOL_CALLS][ ... ]
  • Custom: user-supplied open/close delimiters

The ToolCallDetector accumulates token text, detects open/close delimiters, validates the JSON payload, and fires whenever a complete tool call is parsed.

Tool results can be queued for injection back into the generation stream via the engine’s injection queue mechanism.

Structs§

NoOpDispatcher
A no-op dispatcher that returns a stub Ok(null) for every tool call.
ToolCall
A fully-parsed tool call extracted from the model’s output stream.
ToolCallDetector
Incremental tool-call detector.

Enums§

ToolCallGrammar
Specifies the delimiter syntax used by a given model for tool calls.
ToolResult
Result of a tool invocation.

Traits§

ToolDispatcher
Dispatches tool calls to registered handler implementations.

Functions§

no_op_dispatcher
Create a no-op dispatcher wrapped in an Arc.