mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-25 22:20:43 +00:00
* fix(anthropic): skip a stream data line that is not a JSON object An Anthropic-format upstream that sends a data line holding a JSON number, string, array or null (data: 5) failed /v1/chat/completions and /v1/responses with "'int' object has no attribute 'get'", and the agentic /v1/messages iterator sent an error event after message_stop. The shared stream parser now skips such a line the way SSE clients ignore an event they do not understand, so the /v1/messages logging path no longer needs its own copy of that check * test(anthropic): cover the /v1/messages log assembler skipping a data line that is not a JSON object The log assembler no longer has its own non-object check, so this pins that a tool use stream with such a line still assembles its text and tool call * fix(anthropic): skip a non-object stream line before decoding it and reset the agentic event name per data line * fix(anthropic): skip a non-object data line before decoding it when looking for a /v1/messages error event * fix(anthropic): skip a stream data line too deep or too long to decode on every Anthropic stream reader Chat, the agentic and native /v1/messages iterators, the /v1/messages log scans, guardrail SSE readers, and BaseModelResponseIterator (Snowflake Claude streams, Vertex streamRawPredict logging) now share one loads_json_object helper that returns None for a payload that is not a JSON object or that json.loads cannot finish (deep nesting, a number past the int digit limit) * test(snowflake): inject the HTTP client instead of patching HTTPHandler.post * fix(guardrails): refuse a /v1/messages stream event the guardrail cannot decode A JSON object line nested too deep, or holding a number over Python's digit limit, was skipped by the guardrail readers while a JavaScript client can still parse it and show its text. The unified guardrail now refuses such a stream before it runs, and the /v1/messages assembler returns nothing for it, so Presidio, Bedrock, tool permission and Model Armor refuse it too. Spend logging still skips the line * fix(guardrails): fail closed on unreadable Anthropic stream events in every scan mode The streaming scan key is now None when a data line holds an object the guardrail cannot decode, or when one SSE event carries more than one data line, so the scheduler can no longer skip that round as redundant and the refusal always runs The guardrail stream readers in the harness usage parser, the LLM Shield restorer, the blocked-usage helper and Presidio unmasking now skip a line that is nested too deep or holds a number too large to decode instead of raising, and PANW Prisma AIRS refuses such a text event instead of forwarding it unscanned * fix(guardrails): skip a deeply nested array line in PANW and read bytearray stream chunks * fix(guardrails): read guarded /v1/messages streams in whole frames and skip undecodable lines in more readers The unified guardrail now rejoins transport reads into whole SSE frames for every /v1/messages stream, not only when tool calls are held, so a text event split across two reads, or inside a UTF-8 character, is still checked The chat stream's JSON accumulator, the Rust router's /v1/messages usage reader and the Databricks invocation metrics filter now skip a line that is nested too deep or holds a number too long to decode instead of failing the stream The check for an undecodable object line now skips json.loads when a payload has too few brackets to hit the recursion limit and no digit run long enough to hit the int digit limit, which halves its cost per scan round * fix(guardrails): count sampled scan rounds by whole frames so split reads do not skip them * fix(anthropic): step over a number too long to convert in the chat stream joiner so the event after it is kept --------- Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com> |
||
|---|---|---|
| .. | ||
| agent | ||
| chat | ||
| decisions | ||
| messages | ||
| responses | ||
| __init__.py | ||
| test_databricks_common_utils.py | ||
| test_databricks_cost_calculator.py | ||
| test_databricks_partner_integration.py | ||
| test_databricks_streaming_utils.py | ||