diff --git a/internal/util/toolcalls_parse_markup.go b/internal/util/toolcalls_parse_markup.go index a372a67..266221a 100644 --- a/internal/util/toolcalls_parse_markup.go +++ b/internal/util/toolcalls_parse_markup.go @@ -22,7 +22,6 @@ var toolUseToolNameBodyPattern = regexp.MustCompile(`(?is)\s*]*>(.*?)`), regexp.MustCompile(`(?is)<(?:[a-z0-9_:-]+:)?function_name\b[^>]*>(.*?)`), - regexp.MustCompile(`(?is)<(?:[a-z0-9_:-]+:)?name\b[^>]*>(.*?)`), } func parseXMLToolCalls(text string) []ParsedToolCall { diff --git a/internal/util/toolcalls_test.go b/internal/util/toolcalls_test.go index 7726ba5..1124123 100644 --- a/internal/util/toolcalls_test.go +++ b/internal/util/toolcalls_test.go @@ -191,6 +191,20 @@ func TestParseToolCallsSupportsXMLParametersJSONWithAmpersandCommand(t *testing. } } +func TestParseToolCallsDoesNotTreatParameterNameTagAsToolName(t *testing.T) { + text := `file.txtpwd` + calls := ParseToolCalls(text, []string{"execute_command"}) + if len(calls) != 1 { + t.Fatalf("expected 1 call, got %#v", calls) + } + if calls[0].Name != "execute_command" { + t.Fatalf("expected tool name execute_command, got %q", calls[0].Name) + } + if calls[0].Input["name"] != "file.txt" { + t.Fatalf("expected parameter name preserved, got %#v", calls[0].Input) + } +} + func TestParseToolCallsPrefersJSONPayloadOverIncidentalXMLInString(t *testing.T) { text := `{"tool_calls":[{"name":"search","input":{"q":"latest wrong{\"x\":1}"}}]}` calls := ParseToolCallsDetailed(text, []string{"search"}).Calls