Available on crate feature
models only.Expand description
Text-based tool call parser for models that emit tool calls as text tags.
Some models emit tool calls as text tags instead of structured tool_calls
JSON when served through endpoints that don’t support native tool calling
(e.g., HuggingFace TGI without --enable-auto-tool-choice).
This module detects and parses these text-based tool calls, converting
them to proper Part::FunctionCall entries so the agent pipeline works
regardless of the serving backend.
§Supported Formats
- Qwen/Hermes:
<tool_call>{"name":"...", "arguments":{...}}</tool_call> - Qwen function tag:
<tool_call><function=NAME>ARGS</function></tool_call> - Llama:
<|python_tag|>{"name":"...", "parameters":{...}} - Mistral Nemo:
[TOOL_CALLS][{"name":"...", "arguments":{...}}] - DeepSeek:
```json\n{"name":"...","arguments":{...}}\n```with<|tool▁call▁end|> - Gemma 4:
<|tool_call>call:NAME{key:<|"|>value<|"|>}<tool_call|> - Action tags:
<|action_start|>JSON<|action_end|>
Structs§
- Tool
Call Buffer - Streaming buffer that accumulates tokens and detects tool call boundaries.
Enums§
- Buffer
Action - Action returned by
ToolCallBuffer::push().
Functions§
- contains_
tool_ call_ tag - Check if text contains a tool call tag that should be parsed.
- parse_
text_ tool_ calls - Parse text-based tool calls from model output.