TestChatToolCallMalformedArgsPreservesMarker: on invalid `arguments` JSON (provider bug), the client surfaces a sentinel key rather than an empty args map, so the tool-result log names what went wrong.
(t *testing.T)
| 296 | // (provider bug), the client surfaces a sentinel key rather than an empty args |
| 297 | // map, so the tool-result log names what went wrong. |
| 298 | func TestChatToolCallMalformedArgsPreservesMarker(t *testing.T) { |
| 299 | srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { |
| 300 | sseOK(w, []string{ |
| 301 | `{"choices":[{"delta":{"tool_calls":[{"index":0,"id":"c1","function":{"name":"bash","arguments":"{not-json"}}]}}]}`, |
| 302 | `{"choices":[{"delta":{},"finish_reason":"tool_calls"}]}`, |
| 303 | }) |
| 304 | })) |
| 305 | defer srv.Close() |
| 306 | c := New(srv.URL, "m", "") |
| 307 | var got *chmctx.ToolCall |
| 308 | for _, e := range collect(c.Chat(context.Background(), nil, nil)) { |
| 309 | if e.Kind == EventToolCall { |
| 310 | got = e.ToolCall |
| 311 | } |
| 312 | } |
| 313 | if got == nil { |
| 314 | t.Fatal("tool call event missing") |
| 315 | } |
| 316 | if _, ok := got.Arguments["_parse_error"]; !ok { |
| 317 | t.Fatalf("_parse_error sentinel missing: %+v", got.Arguments) |
| 318 | } |
| 319 | } |
| 320 | |
| 321 | // TestToWireAlwaysSendsContent: silent tool results (empty stdout) must still |
| 322 | // serialize "content":"". Ollama's /v1 shim 400s if the field is absent or null. |