pub fn extract_tool_calls(
message: &Message,
_native_function_calling: bool,
) -> Vec<ToolCall>Expand description
Extract tool calls from a returned assistant message.
Behaviour:
- If
message.tool_callsis present and non-empty, return those directly (the native path). - Otherwise, parse
message.contenttext for XML/JSON-formatted tool calls. This is the fallback path and runs even whennative_function_callingis true — some backends populate text despite the request flag. - The fallback also runs when
native_function_callingis false (the prompt-based path).
In all cases the returned ToolCall values are normalized OpenAI-style
objects (id/type/function) so downstream code never needs to distinguish.