Skip to main content

parse_function_xml_body

Function parse_function_xml_body 

Source
fn parse_function_xml_body(
    body: &str,
    mint_id: &mut impl FnMut() -> String,
) -> Option<Vec<ToolCall>>
Expand description

Try to interpret body as one or more back-to-back Hermes/Qwen3 inner-XML tool calls: <function=NAME><parameter=KEY>VALUE</parameter>...</function>, repeated.

Whitespace between tags is tolerated. Each parameter value is parsed as JSON when it looks like a JSON literal ({, [, quoted string, number, true/false/null); otherwise it is forwarded as a string after trimming surrounding whitespace — see parse_param_value’s doc comment for the coercion’s known limitation.

Returns None (not Some(vec![])) when body doesn’t open with <function= at all or the very first block is malformed, so the caller can fall through to a “no dialect matched” error. A body that opens correctly but has a malformed later block currently stops at that point and returns None for the whole body, discarding any calls already parsed — the same fail-shut behaviour the single-call parser always had.