Support toolCall XML tags and XML child arguments in DetectToolCalls

This commit is contained in:
Luxferre
2026-09-07 14:45:51 +03:00
parent 16c4ed1e91
commit e505f44f4a
2 changed files with 55 additions and 0 deletions
+16
View File
@@ -670,6 +670,22 @@ Some postamble.`
if rem4 != "" {
t.Errorf("expected empty remaining, got %q", rem4)
}
// 5. XML toolCall with child tags
xmlChildTags := "```xml\n<toolCall>\n <name>get_weather</name>\n <arguments>\n <loc>Paris</loc>\n </arguments>\n</toolCall>\n```"
calls5, rem5, ok5 := DetectToolCalls(xmlChildTags)
if !ok5 || len(calls5) != 1 {
t.Fatalf("expected 1 call from xmlChildTags, got %d", len(calls5))
}
if calls5[0].Function.Name != "get_weather" {
t.Errorf("expected get_weather, got %q", calls5[0].Function.Name)
}
if !strings.Contains(calls5[0].Function.Arguments, `"Paris"`) {
t.Errorf("expected Paris in arguments, got %s", calls5[0].Function.Arguments)
}
if rem5 != "" {
t.Errorf("expected empty remaining, got %q", rem5)
}
}
func TestUniversalStreamToolCallFilterVariants(t *testing.T) {