You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
If an assistant message contains any thinking blocks, the first block must be thinking or redacted_thinking #738
raise e # it's already mapped
^^^^^^^
File "/Users/xingyaow/.cache/uv/archive-v0/7syNfyMibYRIdkqALTht7/lib/python3.12/site-packages/litellm/litellm_core_utils/exception_mapping_utils.py", line 290, in exception_type
extract_and_raise_litellm_exception(
File "/Users/xingyaow/.cache/uv/archive-v0/7syNfyMibYRIdkqALTht7/lib/python3.12/site-packages/litellm/litellm_core_utils/exception_mapping_utils.py", line 165, in extract_and_raise_litellm_exception
raise raised_exception_obj(
litellm.exceptions.BadRequestError: litellm.BadRequestError: Error code: 400 - {'error': {'message': 'litellm.BadRequestError: AnthropicException - {"type":"error","error":{"type":"invalid_request_error","message":"messages.5.content.0: If an assistant message contains any thinking blocks, the first block must be `thinking` or `redacted_thinking`. Found `tool_use`."},"request_id":"req_011CU7kqVmSUn8XEfzjx33MH"}No fallback model group found for original model_group=claude-sonnet-4-5-20250929. Fallbacks=[{\'qwen3-coder-480b\': [\'qwen3-coder-480b-or\']}, {\'glm-4.5\': [\'glm-4.5-or\']}]. Received Model Group=claude-sonnet-4-5-20250929\nAvailable Model Group Fallbacks=None\nError doing the fallback: litellm.BadRequestError: AnthropicException - {"type":"error","error":{"type":"invalid_request_error","message":"messages.5.content.0: If an assistant message contains any thinking blocks, the first block must be `thinking` or `redacted_thinking`. Found `tool_use`."},"request_id":"req_011CU7kqVmSUn8XEfzjx33MH"}No fallback model group found for original model_group=claude-sonnet-4-5-20250929. Fallbacks=[{\'qwen3-coder-480b\': [\'qwen3-coder-480b-or\']}, {\'glm-4.5\': [\'glm-4.5-or\']}] LiteLLM Retried: 1 times, LiteLLM Max Retries: 2', 'type': None, 'param': None, 'code': '400'}}
I think the root cause might be that interleaved thinking requires us to pass back previous thinking blocks, and in that trajectory when the condenser activated, there was a chat completion with a thinking block that broke into 4 consecutive action events, e.g. E44 to E47. Only E44 contains the thinking block, but the condenser eliminated all events up to E46, and when we pass back E47 only, the thinking block is missing and causes 400 error.
It might be a bit tricky to get it work reliably, one possible solution might be to copy the thinking block to all action events with the same completion id and filter duplicate when combining.
Way to repro: In the 14_context_condenser.py example, you can change max_size of the condenser from 10 to 14 and append the first task message with IMPORTANT: ALWAYS generate 3 ACTIONS at once to save interactions. -- then you can see it fails consistently after the first condensation request (about event 20).
Activity
ryanhoangt commentedon Oct 15, 2025
I think the root cause might be that interleaved thinking requires us to pass back previous thinking blocks, and in that trajectory when the condenser activated, there was a chat completion with a thinking block that broke into 4 consecutive action events, e.g. E44 to E47. Only E44 contains the thinking block, but the condenser eliminated all events up to E46, and when we pass back E47 only, the thinking block is missing and causes 400 error.
It might be a bit tricky to get it work reliably, one possible solution might be to copy the thinking block to all action events with the same completion id and filter duplicate when combining.
ryanhoangt commentedon Oct 17, 2025
Way to repro: In the
14_context_condenser.pyexample, you can changemax_sizeof the condenser from10to14and append the first task message withIMPORTANT: ALWAYS generate 3 ACTIONS at once to save interactions.-- then you can see it fails consistently after the first condensation request (about event 20).