mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-24 22:09:56 +00:00
* fix(token_counter): count an Anthropic fallback block as zero on every count route A client replays the fallback block from a server-side fallback in its history. The API does not render it, so it costs zero tokens, but /utils/token_counter answered 500 and /v1/messages/count_tokens answered 400 on it. The local counter now skips the block, the conversion guard accepts it, and provider counts send the fallback beta those APIs need to accept it. * fix(deepseek): count a history that echoes a fallback block the same as the history without it * fix(prompt_templates): leave an echoed fallback block's text out of a flattened content list * fix(token_counter): skip only fallback blocks when flattening and strip them from Bedrock counts Restore the old content-list flatten so a malformed part still raises instead of losing its text, skip a block only when its type is a string naming an unrendered block, and send Bedrock's count APIs the history without the fallback block, which Bedrock rejects * fix(token_counter): count the text a fallback block carries like a text block Restore the flattened content list to main's behavior, so any text a caller puts on a fallback block is sent and scanned exactly as before. The local token counter now counts that text like a text block, so what is counted matches what is sent, while a real fallback block with no text still counts as zero. The chat to Responses bridge skips a fallback block that carries no text instead of sending its repr as output text. * fix(token_counter): count a fallback block's text the way each route sends it DeepSeek counts send the text a fallback block carries as a text block, Bedrock counts keep a response tool call object they used to send, and the conversion guard still refuses a fallback block that carries text, since both conversions drop it --------- Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com> |
||
|---|---|---|
| .. | ||
| litellm_responses_transformation | ||
| __init__.py | ||
| test_litellm_responses_transformation_transformation.py | ||
| test_responses_bridge_provider_propagation.py | ||