Expand description
The ToolCallParser trait and its companion ParserOutput.
A parser consumes raw text or reasoning chunks from an LLM stream and
produces a normalized ParserOutput containing:
forward_text— bytes that should appear in the downstreamLlmStreamEvent::TextDelta.forward_reasoning— bytes that should appear in the downstreamLlmStreamEvent::ReasoningDelta.tool_calls— fully-assembled tool calls extracted from dialect markup (e.g. Qwen XML).errors— non-fatal normalization failures.
Parsers are stream-stateful: the caller (the NormalizingStream adapter)
constructs one parser per stream and drives it with chunk-by-chunk input.
Parsers must therefore be chunk-safe — they buffer ambiguous trailing
bytes internally and flush them on the next call or at ToolCallParser::finish.
§Adding a new parser
- Implement
ToolCallParserin a new file undersuper::parsers. - Add a single match arm to
super::registry::get_parserkeyed on a newformat:*tag (seesuper::tags).
No other crate participates in the dispatch decision.
Structs§
- Parser
Output - Result of feeding one chunk of input to a parser.
Traits§
- Tool
Call Parser - Stream-stateful parser that normalizes a single LLM dialect into
canonical
ParserOutputfragments.