Fix tool-call HTML escaping and stabilize usage token mapping

This commit is contained in:
CJACK. committed 2026-04-07 12:35:50 +08:00
1 parent 80b88b37ff
commit 77a401fb19
6 files changed
+139 -1

No files matched your search

+12
View File
@@ -691,3 +691,15 @@ func TestRepairLooseJSONWithNestedObjects(t *testing.T) {
}
}
}
func TestParseToolCallsUnescapesHTMLEntityArguments(t *testing.T) {
text := `<tool_call><tool_name>Bash</tool_name><parameters>{"command":"echo a &gt; out.txt"}</parameters></tool_call>`
calls := ParseToolCalls(text, []string{"bash"})
if len(calls) != 1 {
t.Fatalf("expected one call, got %#v", calls)
}
cmd, _ := calls[0].Input["command"].(string)
if cmd != "echo a > out.txt" {
t.Fatalf("expected html entities to be unescaped in command, got %q", cmd)
}
}