tools: handle the case where a tool call sends "arguments" or "parameters" as a serialized json string (#12413)

This commit is contained in:
Gabe Goodhart
2025-09-25 15:37:39 -06:00
committed by GitHub
parent fbd82ba5bb
commit 2fba04b5fb
2 changed files with 28 additions and 0 deletions

View File

@@ -1274,6 +1274,22 @@ func TestFindArguments(t *testing.T) {
"items": []any{"{", "}", map[string]any{"key": "value"}},
},
},
{
name: "stringified arguments",
buffer: []byte(`{"name": "get_temperature", "arguments": "{\"format\": \"fahrenheit\", \"location\": \"San Francisco, CA\"}"}`),
want: map[string]any{
"format": "fahrenheit",
"location": "San Francisco, CA",
},
},
{
name: "stringified parameters",
buffer: []byte(`{"name": "get_temperature", "parameters": "{\"format\": \"fahrenheit\", \"location\": \"San Francisco, CA\"}"}`),
want: map[string]any{
"format": "fahrenheit",
"location": "San Francisco, CA",
},
},
}
for _, tt := range tests {