mirror of
https://github.com/tiennm99/litellm.git
synced 2026-07-03 21:08:09 +00:00
4630793fb0
When extended thinking is enabled, the websearch interception agentic loop builds a follow-up assistant message with only tool_use blocks. Anthropic's API requires assistant messages to start with thinking/redacted_thinking blocks when thinking is enabled, causing a 400 Bad Request. Extract thinking blocks from the model's initial response, thread them through the agentic loop, and prepend them to the follow-up assistant message — matching the pattern used by anthropic_messages_pt in factory.py. Fixes the error: "Expected 'thinking' or 'redacted_thinking', but found 'tool_use'"