litellm/tests/integration/messages_endpoint/providers
Mateo Wang 6088120e28
fix(anthropic): log 0 output tokens when an error frame follows message_start (#53914)
* fix(anthropic): log 0 output tokens when an error frame follows message_start

A /v1/messages stream that ended with an upstream error event right after
message_start logged the message_start placeholder as 1 output token on the
failed attempt, while the same stream cut by a dropped connection logged 0.
Assembly raised on the error event and fell back to usage-only parsing, which
copies the placeholder. The error events are now left out before assembly, so
both failure shapes report the same usage and cost

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(anthropic): leave out upstream error events from a stream already split into lines

The logging path for a stream that ran to its end hands assembly the SSE
lines one by one, with no blank lines between frames, so the frame scan
found no error event and returned the lines unchanged. The filter now
looks at each event it splits out, so both input shapes drop the error

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* refactor(anthropic): one loop per comprehension and no JSON parse for error-free streams

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-11-23 15:10:46 -08:00
..
anthropic fix(anthropic): log 0 output tokens when an error frame follows message_start (#53914) 2026-11-23 15:10:46 -08:00
bedrock test: bedrock claude prompt caching on /v1/messages reports and charges cache tokens (#49265) 2026-10-30 11:19:08 -07:00
databricks fix(databricks): use the native Anthropic route for Claude /v1/messages (#46091) 2026-10-18 02:44:38 +00:00
gemini fix(vertex_ai): build the cachedContents collection URL under a custom api_base (#44783) 2026-10-29 03:46:35 -07:00