fix(agent): parse tool-call tag variants in XML dispatcher
(cherry picked from commit b7c0a6d6b2)
This commit is contained in:
parent
c993ee80c7
commit
ff64980599
@ -33,7 +33,18 @@ impl XmlToolDispatcher {
|
||||
fn parse_xml_tool_calls(response: &str) -> (String, Vec<ParsedToolCall>) {
|
||||
let mut text_parts = Vec::new();
|
||||
let mut calls = Vec::new();
|
||||
let mut remaining = response;
|
||||
// Normalize tag variants produced by some models/channels so the parser is consistent.
|
||||
// The dispatcher expects <tool_call>...</tool_call>, but other parts of the system accept
|
||||
// <toolcall>, <tool-call>, and <invoke>. Normalize them here.
|
||||
let normalized = response
|
||||
.replace("<toolcall>", "<tool_call>")
|
||||
.replace("</toolcall>", "</tool_call>")
|
||||
.replace("<tool-call>", "<tool_call>")
|
||||
.replace("</tool-call>", "</tool_call>")
|
||||
.replace("<invoke>", "<tool_call>")
|
||||
.replace("</invoke>", "</tool_call>");
|
||||
|
||||
let mut remaining = normalized.as_str();
|
||||
|
||||
while let Some(start) = remaining.find("<tool_call>") {
|
||||
let before = &remaining[..start];
|
||||
|
||||
Loading…
Reference in New Issue
Block a user