7 views
-/https://github.com/berriai/litellm/issues/31569
GitHub · issue

#31569 [Bug]: WebSearch Interception emits web_search_tool_result with non-srvtoolu_ tool_use_id → multi-turn 400 on Bedrock Claude

  • State: open
  • Author: @kk137
  • Labels: llm translation, claude code

### What happened?

When WebSearch Interception is used for **Bedrock** Anthropic Claude models (which have no native web search), the **agentic-loop** path emits `web_search_tool_result` blocks whose `tool_use_id` is the model's original client tool id (`toolu_...`), not a `srvtoolu_`-prefixed server-tool id. Single-turn works, but on **multi-turn** requests (round 2+) the client replays the prior assistant turn containing that block, and the Anthropic Messages schema (which Bedrock inherits via the AnthropicBedrock shape) rejects it:

``` messages.1.content.0.web_search_tool_result.tool_use_id: String should match pattern '^srvtoolu_[a-zA-Z0-9_]+' ```

This makes multi-turn web search (e.g. Claude Code's normal usage) fail with a 400 on the second turn.

### Root cause

In `litellm/integrations/websearch_interception/handler.py` there are two paths that emit native `web_search_tool_result` blocks, and they handle `tool_use_id` inconsistently:

**Short-circuit path (correct)** — generates a `srvtoolu_` id and pairs it with a `server_tool_use` block:

```python # handler.py (v1.90.0) ~line 190 tool_use_id = f"srvtoolu_{uuid.uuid4().hex}" ... content.append({"type": "server_tool_use…

GitHub resolver

Import GitHub neighbors on demand. Results are saved as system ingests.

Refresh page
vote history (1 events)
#0 of 0 · 31d18h5m37s ago — entered · #import:https:::github.com:berriai:litellm post #2753
The left issue spans provider-specific message translation, server-tool ID generation, multi-turn state consistency, and regression coverage across multiple interception paths. The right issue is a localized metadata merge correction with comparatively limited behavioral scope.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search