Problem
When switching from Claude (with extended thinking) to non-Claude providers (Fireworks, Together) mid-task, the message history contains thinking_blocks that these providers reject.
Error
litellm.BadRequestError: Fireworks_aiException - {
"error": {
"type": "invalid_request_error",
"message": "Extra inputs are not permitted, field: 'messages[2].thinking_blocks'"
}
}
Scenario
- User starts task with Claude → Claude generates
thinking_blocks in responses
- User hits rate limit / runs out of credits
- User switches to Fireworks/Together provider
- Message history still contains
thinking_blocks from Claude turns
- Fireworks/Together API rejects the request
Root Cause
- Claude's extended thinking feature adds
thinking_blocks to assistant messages
- These blocks are preserved in conversation history
- Non-Claude providers don't support this field and reject it
- LiteLLM's
drop_params only drops request parameters, not message fields
Proposed Solution
Add a LiteLLM pre-request callback that:
- Checks provider capabilities (from
model-capabilities/*.yaml)
- If provider doesn't support thinking, converts
thinking_blocks to text content
- Preserves reasoning information in compatible format
Conversion
# Before (Claude format):
{
"role": "assistant",
"thinking_blocks": [{"type": "thinking", "thinking": "Let me analyze..."}]
}
# After (Compatible format):
{
"role": "assistant",
"content": [{"type": "text", "text": "[Reasoning] Let me analyze..."}]
}
Files to Create
litellm_callbacks/thinking_compat.py - Pre-request callback
- Update start scripts to register callback in LiteLLM config
Problem
When switching from Claude (with extended thinking) to non-Claude providers (Fireworks, Together) mid-task, the message history contains
thinking_blocksthat these providers reject.Error
Scenario
thinking_blocksin responsesthinking_blocksfrom Claude turnsRoot Cause
thinking_blocksto assistant messagesdrop_paramsonly drops request parameters, not message fieldsProposed Solution
Add a LiteLLM pre-request callback that:
model-capabilities/*.yaml)thinking_blocksto text contentConversion
Files to Create
litellm_callbacks/thinking_compat.py- Pre-request callback