pub fn select_tool(
output: &str,
tools: &[ToolDefinition],
) -> Result<ToolCall, ToolCallError>Expand description
Parse raw model output and extract the first tool call.
The parser looks for the <tool_call>…</tool_call> pattern emitted by the
model and validates:
- That a
namefield is present. - That the name appears in
tools(whentoolsis non-empty). - That the
argumentsvalue, if present, is a valid JSON object.
On success the returned ToolCall carries a freshly generated ID.
§Errors
ToolCallError::NoToolCallFound— no<tool_call>tag found.ToolCallError::UnknownTool— name not intoolsregistry.ToolCallError::MalformedArguments— argument payload is not valid JSON.