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§
- NoOp
Dispatcher - A no-op dispatcher that returns a stub
Ok(null)for every tool call. - Tool
Call - A fully-parsed tool call extracted from the model’s output stream.
- Tool
Call Detector - Incremental tool-call detector.
Enums§
- Tool
Call Grammar - Specifies the delimiter syntax used by a given model for tool calls.
- Tool
Result - Result of a tool invocation.
Traits§
- Tool
Dispatcher - Dispatches tool calls to registered handler implementations.
Functions§
- no_
op_ dispatcher - Create a no-op dispatcher wrapped in an
Arc.