Limit HTML unescape to markup tool-call parsing

This commit is contained in:
CJACK. committed 2026-04-07 12:55:06 +08:00
1 parent 77a401fb19
commit da7c46b278
4 files changed
+41 -52

No files matched your search

+12
View File
@@ -703,3 +703,15 @@ func TestParseToolCallsUnescapesHTMLEntityArguments(t *testing.T) {
t.Fatalf("expected html entities to be unescaped in command, got %q", cmd)
}
}
func TestParseToolCallsJSONPayloadKeepsLiteralEntities(t *testing.T) {
text := `{"tool_calls":[{"name":"bash","input":{"command":"echo > literally"}}]}`
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 > literally" {
t.Fatalf("expected json payload to keep literal entities, got %q", cmd)
}
}