TestToWireParseErrorArgsStayValidJSON: when resolve() stamps _parse_error for a truncated tool call and that assistant message round-trips into the next request, toWire must still emit VALID JSON for arguments. Otherwise every later turn re-sends corrupt JSON and the backend 400s forever (session po
(t *testing.T)
| 937 | } |
| 938 | |
| 939 | // TestChatRetriesTransient404: a proxy that hiccups (two 404s, then a clean |
| 940 | // stream) is retried transparently. The user sees one EventRetry per wait, |
| 941 | // then normal content - never an EventError. |
| 942 | func TestChatRetriesTransient404(t *testing.T) { |
| 943 | attempts := 0 |
| 944 | srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { |
| 945 | attempts++ |
| 946 | if attempts <= 2 { |
| 947 | w.WriteHeader(http.StatusNotFound) |
| 948 | fmt.Fprint(w, `{"detail":"Not Found"}`) |
| 949 | return |
| 950 | } |
| 951 | sseOK(w, []string{textDelta("ok"), completed(0, 0)}) |
| 952 | })) |
| 953 | defer srv.Close() |
| 954 | |
| 955 | c := New(srv.URL, "m", "") |