Skip to main content

Module tool_call

Module tool_call 

Source
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Β§

GeneratedToolCall πŸ”’
Parameter πŸ”’
ParsedToolCallOutput πŸ”’
RawParameter πŸ”’
RawToolCall πŸ”’
RegionParser πŸ”’
Terminal πŸ”’
Tool πŸ”’
ToolCallOutputContract πŸ”’
Parameter names and declared types gathered from the request’s tool schemas. Guidance only: schemas never validate the whole call.
ToolCallOutputDecoder πŸ”’
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.
ToolCallParseDiagnostics πŸ”’
WireToolCall πŸ”’
Server-minted wire shape for one decoded model tool call.

EnumsΒ§

Disposition πŸ”’
FallbackReason πŸ”’
JsonValueKind πŸ”’

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 type keyword.
compile_schema_types πŸ”’
Compile the type set from a property schema’s type, anyOf, or oneOf.
encode_json_string πŸ”’
fallback πŸ”’
is_ws πŸ”’
json_number_is_integer πŸ”’
1e5 is 100000; 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 πŸ”’