diff --git a/internal/util/toolcalls_parse.go b/internal/util/toolcalls_parse.go
index d010697..6127592 100644
--- a/internal/util/toolcalls_parse.go
+++ b/internal/util/toolcalls_parse.go
@@ -158,10 +158,6 @@ func filterToolCallsDetailed(parsed []ParsedToolCall, availableToolNames []strin
}
if tc.Input == nil {
tc.Input = map[string]any{}
- } else {
- // Remove known hallucinated fields often generated by models trying to bridge XML and JSON
- delete(tc.Input, "_raw")
- delete(tc.Input, "_xml")
}
out = append(out, tc)
}
diff --git a/internal/util/toolcalls_test.go b/internal/util/toolcalls_test.go
index f131544..da78666 100644
--- a/internal/util/toolcalls_test.go
+++ b/internal/util/toolcalls_test.go
@@ -176,6 +176,24 @@ func TestParseToolCallsSupportsCanonicalXMLParametersJSON(t *testing.T) {
}
}
+func TestParseToolCallsPreservesRawMalformedXMLParameters(t *testing.T) {
+ text := `execute_commandcd /root && git status`
+ 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)
+ }
+ raw, ok := calls[0].Input["_raw"].(string)
+ if !ok {
+ t.Fatalf("expected raw argument tracking, got %#v", calls[0].Input)
+ }
+ if raw != "cd /root && git status" {
+ t.Fatalf("expected raw arguments to be preserved, got %q", raw)
+ }
+}
+
func TestParseToolCallsSupportsXMLParametersJSONWithAmpersandCommand(t *testing.T) {
text := `execute_command{"command":"sshpass -p 'xxx' ssh -o StrictHostKeyChecking=no -p 1111 root@111.111.111.111 'cd /root && git clone https://github.com/ericc-ch/copilot-api.git'","cwd":null,"timeout":null}`
calls := ParseToolCalls(text, []string{"execute_command"})