Expand description
Qwen tool-call output parsing.
The model emits each call as XML-style markup: an outer tool marker, a function element carrying the name, and one parameter element per argument. Argument text is untyped; a terminal contract built from the requestβs tool schemas normalizes it into JSON values. A type mismatch stays a structured call for consumer validation; only a structure or identity failure returns the whole marker region to ordinary content.
StructsΒ§
- Generated
Tool πCall - Parameter π
- Parsed
Tool πCall Output - RawParameter π
- RawTool
Call π - Region
Parser π - Terminal π
- Tool π
- Tool
Call πOutput Contract - Parameter names and declared types gathered from the requestβs tool schemas. Guidance only: schemas never validate the whole call.
- Tool
Call πOutput Decoder - Incrementally publishes bytes that are provably outside a possible terminal Qwen tool-call suffix. Bytes that could belong to a marker are held back; at terminal time, valid calls are retained structurally and malformed output is restored verbatim.
- Tool
Call πParse Diagnostics - Wire
Tool πCall - Server-minted wire shape for one decoded model tool call.
EnumsΒ§
- Disposition π
- Fallback
Reason π - Json
Value πKind
ConstantsΒ§
- FUNCTION_
CLOSE π - FUNCTION_
OPEN π - MAX_
TOOL_ πNAME_ LENGTH - Upper bound on model-emitted function names. Request-side names use a shorter grammar on the wire.
- PARAM_
CLOSE π - PARAM_
OPEN π - TOOL_
CLOSE π - TOOL_
OPEN π - T_ARRAY π
- T_
BOOLEAN π - T_
INTEGER π - T_NULL π
- T_
NUMBER π - T_
OBJECT π - T_
STRING π
FunctionsΒ§
- admits_
value π - classify_
json_ πvalue - compile_
direct_ πtypes - Record the supported top-level types from a
typekeyword. - compile_
schema_ πtypes - Compile the type set from a property schemaβs
type,anyOf, oroneOf. - encode_
json_ πstring - fallback π
- is_ws π
- json_
number_ πis_ integer 1e5is100000; integer classification must respect the exponent.- normalize_
declared_ πparameter - normalize_
parameter π - normalize_
raw_ πtool_ call - parse_
qwen_ πtool_ call_ output - Parse the Qwen XML-like tool-call format. Content before the first marker is retained as ordinary text; a malformed marker region falls back to the whole input, marker included. Tolerant mode recovers complete calls from a truncated or suffixed region.
- same_
tool π - schema_
bit π - skip_ws π
- starts_
at π - strip_
parameter_ πframing - Parameter values are framed by newlines; a string-typed parameter keeps them, other types trim.
- trim_ws π
- valid_
function_ πname