Files
litellm/tests/test_litellm/integrations/websearch_interception
michelligabriele 4630793fb0 fix(websearch_interception): preserve thinking blocks in agentic loop follow-up messages
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'"
2026-02-19 21:51:00 +01:00
..