Skip to content

fix(responses): backport Claude tool search replay to lts/1.108.x - #50472

Closed
mateo-berri wants to merge 17 commits into
lts/1.108.xfrom
litellm_backport_claude_tool_search_replay_lts_1_108_x
Closed

mateo-berri wants to merge 17 commits into
lts/1.108.xfrom
litellm_backport_claude_tool_search_replay_lts_1_108_x

Conversation

@mateo-berri

@mateo-berri mateo-berri commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

On the 1.108 LTS line, Claude's tool search through /v1/responses is lost on the next turn, and a follow-up without a tool the search loaded fails with Anthropic's 400

This brings the same fix as #50821 to the line

Original

TLDR

Problem this solves:

  • Turn 1 has no tool_search_output for Claude's search
  • store: false follow-ups drop Claude's search
  • Follow-ups without a loaded tool get Anthropic's 400

How it solves it:

  • Builds tool_search_output from the request's tools and their names, streamed and not
  • Replays the search on store: false turns that still send a search tool
  • Drops loaded tools a follow-up no longer sends, and the whole search when none remain
  • Sends Bedrock's tool search beta when the history holds a search
  • Shows every tool_search_call's arguments to guardrails and Purview DLP

Intentional product change: a replayed search keeps only the loaded tools a follow-up still sends, where Anthropic answered 400, and is left out when none remain, on /v1/chat/completions too

Backport checklist

Relevant issues

Part of #50104, the search record lost on later turns

User Flow

Before: a developer using OpenAI tool search on Claude through /v1/responses loses the search on later turns, and a changed tool list fails

  1. They send POST https://litellm-domain/v1/responses with tools holding {"type": "tool_search"} plus deferred get_weather and get_local_time, asking for the weather in Paris
  2. The reply has tool_search_call then function_call get_weather, but no tool_search_output naming the loaded tools, streamed or not
  3. They send turn 2 with "store": false, replaying every turn 1 item plus a function_call_output, and Claude says it ran no tool search
  4. They send turn 2 with previous_response_id and without a tool the search loaded, and get HTTP 400 "Tool reference '' not found in available tools"

After: turn 1 returns the search result, Claude remembers its search on turn 2, and a changed tool list still answers 200

  1. They send the same turn 1
  2. The reply now also has tool_search_output listing the loaded tools, streamed or not
  3. They send the same "store": false turn 2, and Claude lists the tool search it ran and what it found
  4. They send the same previous_response_id turn 2 and get HTTP 200, and Claude's search keeps every loaded tool still sent

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. uv run pytest tests/unit/<your_test_file>.py -v. Leave the suites (make test-unit-*, make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • Every automated review on my PR's latest commit has finished, and I have addressed or replied to each of its findings before requesting a maintainer review

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

Screenshots / Proof of Fix

Each leg ran the curl scripts on Anthropic claude-sonnet-5-5 and Vertex AI, and the reporter's Agents SDK client on Bedrock Sonnet 5.5 and Opus 5, against one proxy with Postgres and one worker, since --reload ignores --num_workers on this line

Proxy command, config.yaml, and env var names
python litellm/proxy/proxy_cli.py --config config.yaml --port <random free port> --num_workers 2 --detailed_debug --reload --use_v2_migration_resolver
model_list:
  - model_name: claude-sonnet-5-5
    litellm_params:
      model: anthropic/claude-sonnet-5-5
      api_key: os.environ/ANTHROPIC_API_KEY
  - model_name: bedrock-claude-sonnet-5-5
    litellm_params:
      model: bedrock/invoke/us.anthropic.claude-sonnet-5-5
      aws_region_name: us-east-1
  - model_name: bedrock-claude-opus-5
    litellm_params:
      model: bedrock/invoke/us.anthropic.claude-opus-5
      aws_region_name: us-east-1
  - model_name: vertex-claude-sonnet-5-5
    litellm_params:
      model: vertex_ai/claude-sonnet-5-5
      vertex_project: os.environ/VERTEXAI_PROJECT
      vertex_location: global
      vertex_credentials: os.environ/GOOGLE_APPLICATION_CREDENTIALS
general_settings:
  master_key: os.environ/LITELLM_MASTER_KEY
  database_url: os.environ/DATABASE_URL
  store_model_in_db: false
  store_prompts_in_spend_logs: true
litellm_settings:
  callbacks: []

The proxy reads ANTHROPIC_API_KEY, GOOGLE_APPLICATION_CREDENTIALS (a service account key file), VERTEXAI_PROJECT, LITELLM_MASTER_KEY, DATABASE_URL (a fresh Postgres database per leg), LITELLM_LOCAL_MODEL_COST_MAP=True, and LITELLM_PRISMA_COMMAND_TIMEOUT=600. Bedrock calls use the default AWS profile, an SSO role with Bedrock inference, and no AWS env vars. The scripts read INTEGRATION_PROXY_URL and INTEGRATION_MASTER_KEY. agents_qa.py runs on openai-agents==0.24.0

qa.sh (cases 1 to 5), qa-bm25.sh (cases 6 to 8), qa-nosearch.sh (cases 9 and 10), and agents_qa.py
#!/usr/bin/env bash
set -u
URL=$INTEGRATION_PROXY_URL
KEY=$INTEGRATION_MASTER_KEY
OUT=${QA_OUT:-/tmp/qa-tsreplay-$(git rev-parse --short HEAD)}
mkdir -p "$OUT" && cd "$OUT"
echo "commit $(git -C "$OLDPWD" rev-parse --short HEAD), proxy $URL"

cat > tools.json <<'EOF'
[
  {"type": "tool_search"},
  {"type": "function", "name": "get_weather", "description": "Get the current weather for a city", "defer_loading": true,
   "parameters": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]}},
  {"type": "function", "name": "get_local_time", "description": "Get the current local time in a city", "defer_loading": true,
   "parameters": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]}}
]
EOF
ASK='What is the weather in Paris right now? Find the right tool and call it.'
RECALL='Before you answer, list every tool call you made in this conversation in order, including any tool search, and say what the search returned. Then give the weather.'
WEATHER='{"temp_c": 14, "conditions": "light rain"}'

post() { curl -s -o "$1" -w '%{http_code}' "$URL$2" -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d @"$3"; }
items() { jq -c '[.output[] | {type, name, tools: (if .tools then [.tools[].name] else null end)}]' "$1"; }
answer() { jq -r '(.output[]? | select(.type == "message") | .content[0].text), (.error.message // empty)' "$1" | head -c 600; echo; }

echo; echo "### case 1: turn 1, not streamed"
jq -n --slurpfile t tools.json --arg q "$ASK" '{model: "claude-sonnet-5-5", tools: $t[0], input: $q}' > t1.req.json
echo "POST $URL/v1/responses -> HTTP $(post t1.json /v1/responses t1.req.json)"
items t1.json
CID=$(jq -r '.output[] | select(.type == "function_call") | .call_id' t1.json)

echo; echo "### case 2: turn 1, streamed"
jq -c '. + {stream: true}' t1.req.json > t1s.req.json
curl -sN "$URL/v1/responses" -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d @t1s.req.json > t1s.sse
grep '^data: {' t1s.sse | sed 's/^data: //' | jq -c 'select(.type == "response.output_item.done") | {output_index, type: .item.type, name: .item.name, tools: (if .item.tools then [.item.tools[].name] else null end)}'

echo; echo "### case 3: turn 2 with store false, replaying every turn 1 item"
jq -n --slurpfile t tools.json --slurpfile r1 t1.json --arg q "$ASK" --arg cid "$CID" --arg w "$WEATHER" --arg recall "$RECALL" \
  '{model: "claude-sonnet-5-5", tools: $t[0], store: false, input: ([{role: "user", content: $q}] + $r1[0].output + [{type: "function_call_output", call_id: $cid, output: $w}, {role: "user", content: $recall}])}' > t2x.req.json
echo "POST $URL/v1/responses -> HTTP $(post t2x.json /v1/responses t2x.req.json)"
answer t2x.json

for variant in same_tools without_get_weather no_tools; do
  post t1.$variant.json /v1/responses t1.req.json > /dev/null
done
echo; echo "(sent a fresh turn 1 per case 4 variant, waiting 30 s for them to be stored)"; sleep 30
for variant in same_tools without_get_weather no_tools; do
  echo; echo "### case 4: turn 2 with previous_response_id, $variant"
  RID=$(jq -r .id t1.$variant.json)
  VCID=$(jq -r '.output[] | select(.type == "function_call") | .call_id' t1.$variant.json)
  echo "its turn 1: $(items t1.$variant.json)"
  case $variant in
    same_tools) TOOLS=$(jq -c . tools.json); FOLLOW=$RECALL ;;
    without_get_weather) TOOLS=$(jq -c '[.[0], .[2]]' tools.json); FOLLOW='Thanks. Summarize the weather in one sentence.' ;;
    no_tools) TOOLS=null; FOLLOW='Thanks. Summarize the weather in one sentence.' ;;
  esac
  jq -n --argjson t "$TOOLS" --arg rid "$RID" --arg cid "$VCID" --arg w "$WEATHER" --arg f "$FOLLOW" \
    '{model: "claude-sonnet-5-5", previous_response_id: $rid, input: [{type: "function_call_output", call_id: $cid, output: $w}, {role: "user", content: $f}]} + (if $t then {tools: $t} else {} end)' > t2.$variant.req.json
  echo "POST $URL/v1/responses -> HTTP $(post t2.$variant.json /v1/responses t2.$variant.req.json)"
  answer t2.$variant.json
done

echo; echo "### case 5: /v1/chat/completions, turn 2 replays the assistant message without get_weather"
jq -n --arg q "$ASK" '{model: "claude-sonnet-5-5", messages: [{role: "user", content: $q}], tools: [
  {type: "tool_search_tool_regex_20251119", name: "tool_search_tool_regex"},
  {type: "function", defer_loading: true, function: {name: "get_weather", description: "Get the current weather for a city", parameters: {type: "object", properties: {city: {type: "string"}}, required: ["city"]}}},
  {type: "function", defer_loading: true, function: {name: "get_local_time", description: "Get the current local time in a city", parameters: {type: "object", properties: {city: {type: "string"}}, required: ["city"]}}}]}' > c1.req.json
echo "POST $URL/v1/chat/completions -> HTTP $(post c1.json /v1/chat/completions c1.req.json)"
jq -c '.choices[0].message | {tool_calls: [.tool_calls[]? | .function.name], has_provider_specific_fields: (.provider_specific_fields != null)}' c1.json
CCID=$(jq -r '[.choices[0].message.tool_calls[]? | select(.function.name == "get_weather") | .id][0]' c1.json)
jq --arg cid "$CCID" --arg w "$WEATHER" '{model, tools: [.tools[0], .tools[2]], messages: (.messages + [$m[0]] + [{role: "tool", tool_call_id: $cid, content: $w}, {role: "user", content: "Thanks. Summarize the weather in one sentence."}])}' \
  --slurpfile m <(jq '.choices[0].message' c1.json) c1.req.json > c2.req.json
echo "POST $URL/v1/chat/completions -> HTTP $(post c2.json /v1/chat/completions c2.req.json)"
jq -r '.choices[0].message.content // .error.message' c2.json | head -c 600; echo
#!/usr/bin/env bash
set -u
URL=$INTEGRATION_PROXY_URL
KEY=$INTEGRATION_MASTER_KEY
OUT=${QA_OUT:-/tmp/qa-tsreplay-bm25-$(git rev-parse --short HEAD)}
mkdir -p "$OUT" && cd "$OUT"
echo "commit $(git -C "$OLDPWD" rev-parse --short HEAD), proxy $URL"

cat > tools.json <<'EOF'
[
  {"type": "tool_search"},
  {"type": "tool_search_tool_bm25_20251119", "name": "tool_search_tool_bm25"},
  {"type": "function", "name": "get_weather", "description": "Get the current weather for a city", "defer_loading": true,
   "parameters": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]}},
  {"type": "function", "name": "get_local_time", "description": "Get the current local time in a city", "defer_loading": true,
   "parameters": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]}}
]
EOF
ASK='What is the weather in Paris right now? Find the right tool and call it.'
RECALL='Before you answer, name every tool you called in this conversation in order, with the exact tool name and input of any search. Then give the weather.'
WEATHER='{"temp_c": 14, "conditions": "light rain"}'
post() { curl -s -o "$1" -w '%{http_code}' "$URL$2" -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d @"$3"; }

echo; echo "### case 6: turn 1 with tool_search and Anthropic's BM25 search tool"
jq -n --slurpfile t tools.json --arg q "$ASK" '{model: "claude-sonnet-5-5", tools: $t[0], input: $q}' > b1.req.json
echo "POST $URL/v1/responses -> HTTP $(post b1.json /v1/responses b1.req.json)"
jq -c '[.output[] | {type, arguments, tools: (if .tools then [.tools[].name] else null end)}]' b1.json
CID=$(jq -r '.output[] | select(.type == "function_call") | .call_id' b1.json)

echo; echo "### case 7: turn 2 with store false, replaying every turn 1 item"
jq -n --slurpfile t tools.json --slurpfile r1 b1.json --arg q "$ASK" --arg cid "$CID" --arg w "$WEATHER" --arg recall "$RECALL" \
  '{model: "claude-sonnet-5-5", tools: $t[0], store: false, input: ([{role: "user", content: $q}] + $r1[0].output + [{type: "function_call_output", call_id: $cid, output: $w}, {role: "user", content: $recall}])}' > b2.req.json
echo "POST $URL/v1/responses -> HTTP $(post b2.json /v1/responses b2.req.json)"
jq -r '(.output[]? | select(.type == "message") | .content[0].text), (.error.message // empty)' b2.json | head -c 700; echo

echo; echo "### case 8: turn 2 with previous_response_id after case 6, without get_local_time"
echo "(waiting 30 s for case 6 to be stored)"; sleep 30
jq -n --slurpfile t tools.json --arg rid "$(jq -r .id b1.json)" --arg cid "$CID" --arg w "$WEATHER" --arg recall "$RECALL" \
  '{model: "claude-sonnet-5-5", previous_response_id: $rid, tools: [$t[0][0], $t[0][1], $t[0][2]], input: [{type: "function_call_output", call_id: $cid, output: $w}, {role: "user", content: $recall}]}' > b3.req.json
echo "tools sent: $(jq -c '[.tools[] | .name // .type]' b3.req.json)"
echo "POST $URL/v1/responses -> HTTP $(post b3.json /v1/responses b3.req.json)"
jq -r '(.output[]? | select(.type == "message") | .content[0].text), (.error.message // empty)' b3.json | head -c 700; echo
#!/usr/bin/env bash
set -u
URL=$INTEGRATION_PROXY_URL
KEY=$INTEGRATION_MASTER_KEY
OUT=${QA_OUT:-/tmp/qa-nosearch-$(git rev-parse --short HEAD)}
mkdir -p "$OUT" && cd "$OUT"
echo "commit $(git -C "$OLDPWD" rev-parse --short HEAD), proxy $URL"

cat > tools.json <<'JSON'
[
  {"type": "tool_search"},
  {"type": "function", "name": "get_weather", "description": "Get the current weather for a city", "defer_loading": true,
   "parameters": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]}}
]
JSON
jq -c '[.[1] | del(.defer_loading)]' tools.json > plain.json
ASK='What is the weather in Paris right now? Find the right tool and call it.'
RECALL='Before you answer, list every tool call you made in this conversation in order, including any tool search, and say what the search returned. Then give the weather.'
WEATHER='{"temp_c": 14, "conditions": "light rain"}'

post() { curl -s -o "$1" -w '%{http_code}' "$URL$2" -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d @"$3"; }
answer() { jq -r '(.output[]? | select(.type == "message") | .content[0].text), (.error.message // empty)' "$1" | head -c 600; echo; }

echo; echo "### case 9: turn 2 with store false that sends get_weather without the search tool"
jq -n --slurpfile t tools.json --arg q "$ASK" '{model: "claude-sonnet-5-5", tools: $t[0], input: $q}' > t1.req.json
echo "POST $URL/v1/responses (turn 1) -> HTTP $(post t1.json /v1/responses t1.req.json)"
jq -c '[.output[].type]' t1.json
CID=$(jq -r '.output[] | select(.type == "function_call") | .call_id' t1.json)
jq -n --slurpfile t plain.json --slurpfile r1 t1.json --arg q "$ASK" --arg cid "$CID" --arg w "$WEATHER" --arg recall "$RECALL" \
  '{model: "claude-sonnet-5-5", tools: $t[0], store: false, input: ([{role: "user", content: $q}] + $r1[0].output + [{type: "function_call_output", call_id: $cid, output: $w}, {role: "user", content: $recall}])}' > t2.req.json
echo "turn 2 tools: $(jq -c '[.tools[] | .name // .type]' t2.req.json)"
echo "POST $URL/v1/responses (turn 2) -> HTTP $(post t2.json /v1/responses t2.req.json)"
answer t2.json

echo; echo "### case 10: turn 2 with previous_response_id that sends get_weather without the search tool"
echo "POST $URL/v1/responses (turn 1) -> HTTP $(post s1.json /v1/responses t1.req.json)"
jq -c '[.output[].type]' s1.json
echo "(waiting 30 s for turn 1 to be stored)"; sleep 30
SCID=$(jq -r '.output[] | select(.type == "function_call") | .call_id' s1.json)
jq -n --slurpfile t plain.json --arg rid "$(jq -r .id s1.json)" --arg cid "$SCID" --arg w "$WEATHER" --arg recall "$RECALL" \
  '{model: "claude-sonnet-5-5", previous_response_id: $rid, tools: $t[0], input: [{type: "function_call_output", call_id: $cid, output: $w}, {role: "user", content: $recall}]}' > s2.req.json
echo "turn 2 tools: $(jq -c '[.tools[] | .name // .type]' s2.req.json)"
echo "POST $URL/v1/responses (turn 2) -> HTTP $(post s2.json /v1/responses s2.req.json)"
answer s2.json
import asyncio
import json
import os

from openai import AsyncOpenAI
from agents import (
    Agent,
    ModelSettings,
    OpenAIResponsesModel,
    Runner,
    ToolSearchTool,
    function_tool,
    set_tracing_disabled,
    tool_namespace,
)

set_tracing_disabled(True)
MODEL = os.environ.get("QA_AGENTS_MODEL", "bedrock-claude-sonnet-5-5")
client = AsyncOpenAI(base_url=os.environ["INTEGRATION_PROXY_URL"] + "/v1", api_key=os.environ["INTEGRATION_MASTER_KEY"])


@function_tool(defer_loading=True)
def get_weather(city: str) -> str:
    """Get the current weather for a city."""
    return json.dumps({"temp_c": 14, "conditions": "light rain"})


@function_tool(defer_loading=True)
def get_local_time(city: str) -> str:
    """Get the local time in a city."""
    return json.dumps({"time": "15:04"})


def agent(tools):
    return Agent(
        name="assistant",
        instructions="Find the tools you need with tool search, then answer.",
        model=OpenAIResponsesModel(model=MODEL, openai_client=client),
        model_settings=ModelSettings(store=False),
        tools=[*tools, ToolSearchTool()],
    )


def item_types(result):
    return [item.type for response in result.raw_responses for item in response.output]


async def run(label, tools):
    print(f"### agents sdk, {label}, model {MODEL}, store false")
    a = agent(tools)
    try:
        first = await Runner.run(a, "What is the weather in Paris right now?")
    except Exception as error:
        print(f"turn 1 raised {type(error).__name__}: {error}")
        return
    print("turn 1 output items:", item_types(first))
    print("turn 1 answer:", first.final_output)
    follow_up = first.to_input_list() + [
        {"role": "user", "content": "List every tool call you made so far, in order, including any tool search, and what each one returned."}
    ]
    try:
        second = await Runner.run(a, follow_up)
    except Exception as error:
        print(f"turn 2 raised {type(error).__name__}: {error}")
        return
    print("turn 2 answer:", second.final_output)


async def main():
    await run("tools in a tool_namespace", tool_namespace(name="ops", description="City weather and time tools", tools=[get_weather, get_local_time]))
    print()
    await run("top-level deferred tools", [get_weather, get_local_time])


asyncio.run(main())

The Vertex AI runs use qa.sh and qa-nosearch.sh with vertex-claude-sonnet-5-5 in place of claude-sonnet-5-5

Case Before After
1, turn 1 items no search result tool_search_output
2, turn 1 streamed no search result tool_search_output at index 1, in order
3, store: false turn 2 Claude: no search ran Claude lists its search
4, stored turn 2, get_weather or every tool gone 400 200
5, chat completions, get_weather gone 400 200
6, BM25 turn 1 items no search result tool_search_output
7, BM25 store: false turn 2 Claude: no search ran Claude names tool_search_tool_bm25
8, BM25 stored turn 2, get_local_time gone 400 200, search keeps get_weather
10 smoke, stored turn 2 with no search tool Anthropic 200, Bedrock Sonnet 4.5 400 both 200, search recalled
11 smoke, chat search-only turn, dotted names names weather_get same as before
13 smoke, dotted names, turn 1 no search result lists weather.get
13 smoke, store: false turn 2 no search recalled search recalled
Agents SDK, Bedrock Sonnet 5.5 and Opus 5, tool_namespace tools Claude: no search ran Claude lists its search
Vertex AI, cases 1 to 5 and 10 same as Anthropic same as Anthropic

Before (831a14c)

Raw, unedited output of each script above, agents_qa.py once per model

qa.sh

commit 831a14c8f48, proxy http://127.0.0.1:25001

### case 1: turn 1, not streamed
POST http://127.0.0.1:25001/v1/responses -> HTTP 200
[{"type":"tool_search_call","name":null,"tools":null},{"type":"function_call","name":"get_weather","tools":null}]

### case 2: turn 1, streamed
{"output_index":0,"type":"tool_search_call","name":null,"tools":null}
{"output_index":1,"type":"function_call","name":"get_weather","tools":null}

### case 3: turn 2 with store false, replaying every turn 1 item
POST http://127.0.0.1:25001/v1/responses -> HTTP 200
I made one tool call in this conversation, and I didn't run a tool search.

1. `get_weather` with `city: "Paris"`. It returned `{"temp_c": 14, "conditions": "light rain"}`.

I skipped the search step you asked for. The only tool I had been given was `tool_search_tool_regex`, and `get_weather` wasn't in my list. I should have searched first to confirm it existed and check its parameters. I called it directly and guessed at the name and the `city` parameter. The call did return a result, but I didn't verify the tool beforehand.

**Weather in Paris:** 14 °C with light rain, according to that res

(sent a fresh turn 1 per case 4 variant, waiting 30 s for them to be stored)

### case 4: turn 2 with previous_response_id, same_tools
its turn 1: [{"type":"tool_search_call","name":null,"tools":null},{"type":"function_call","name":"get_weather","tools":null}]
POST http://127.0.0.1:25001/v1/responses -> HTTP 200
Here are the tool calls I made, in order:

1. **`tool_search_tool_regex`** with the pattern `weather`. It returned one tool, `get_weather`. That tool gets the current weather for a city and takes a required string parameter, `city`.
2. **`get_weather`** with `city` set to `Paris`. It returned `{"temp_c": 14, "conditions": "light rain"}`.

**Weather in Paris right now:** It's 14 °C (about 57 °F) with light rain.


### case 4: turn 2 with previous_response_id, without_get_weather
its turn 1: [{"type":"tool_search_call","name":null,"tools":null},{"type":"function_call","name":"get_weather","tools":null}]
POST http://127.0.0.1:25001/v1/responses -> HTTP 400
litellm.BadRequestError: AnthropicException - {"type":"error","error":{"type":"invalid_request_error","message":"Tool reference 'get_weather' not found in available tools"},"request_id":"req_011CgouG5T8gdoLCz2Sv9mmo"}

LiteLLM: model group 'claude-sonnet-5-5' failed with the error above. No fallback was attempted.


### case 4: turn 2 with previous_response_id, no_tools
its turn 1: [{"type":"tool_search_call","name":null,"tools":null},{"type":"function_call","name":"get_weather","tools":null}]
POST http://127.0.0.1:25001/v1/responses -> HTTP 400
litellm.BadRequestError: AnthropicException - {"type":"error","error":{"type":"invalid_request_error","message":"Tool reference 'get_weather' not found in available tools"},"request_id":"req_011CgouGAoM4x7nBY3MeyEpo"}

LiteLLM: model group 'claude-sonnet-5-5' failed with the error above. No fallback was attempted.


### case 5: /v1/chat/completions, turn 2 replays the assistant message without get_weather
POST http://127.0.0.1:25001/v1/chat/completions -> HTTP 200
{"tool_calls":["tool_search_tool_regex","get_weather"],"has_provider_specific_fields":true}
POST http://127.0.0.1:25001/v1/chat/completions -> HTTP 400
litellm.BadRequestError: AnthropicException - {"type":"error","error":{"type":"invalid_request_error","message":"Tool reference 'get_weather' not found in available tools"},"request_id":"req_011CgouGLnrsyEFjK9pZzC5y"}

LiteLLM: model group 'claude-sonnet-5-5' failed with the error above. No fallback was attempted.

qa-bm25.sh

commit 831a14c8f48, proxy http://127.0.0.1:25001

### case 6: turn 1 with tool_search and Anthropic's BM25 search tool
POST http://127.0.0.1:25001/v1/responses -> HTTP 200
[{"type":"tool_search_call","arguments":{"query":"current weather in a city"},"tools":null},{"type":"function_call","arguments":"{\"city\": \"Paris\"}","tools":null}]

### case 7: turn 2 with store false, replaying every turn 1 item
POST http://127.0.0.1:25001/v1/responses -> HTTP 200
I called one tool in this conversation:

1. `get_weather` with the input `{"city": "Paris"}`

I didn't call `tool_search_tool_bm25`, so there is no search input to report. You asked me to find the right tool, and I skipped that step. `get_weather` wasn't in the tool list I was given. Only the search tool was. I called `get_weather` anyway, on the assumption that it existed, when I should have searched first. The call did return a result, but I can't verify where it came from.

The result said it's 14°C in Paris with light rain.


### case 8: turn 2 with previous_response_id after case 6, without get_local_time
(waiting 30 s for case 6 to be stored)
tools sent: ["tool_search","tool_search_tool_bm25","get_weather"]
POST http://127.0.0.1:25001/v1/responses -> HTTP 400
litellm.BadRequestError: AnthropicException - {"type":"error","error":{"type":"invalid_request_error","message":"Tool reference 'get_local_time' not found in available tools"},"request_id":"req_011CgouK1CEv311awr2AnGgQ"}

LiteLLM: model group 'claude-sonnet-5-5' failed with the error above. No fallback was attempted.

qa-nosearch.sh

commit 831a14c8f48, proxy http://127.0.0.1:25001

### case 9: turn 2 with store false that sends get_weather without the search tool
POST http://127.0.0.1:25001/v1/responses (turn 1) -> HTTP 200
["tool_search_call","function_call"]
turn 2 tools: ["get_weather"]
POST http://127.0.0.1:25001/v1/responses (turn 2) -> HTTP 200
**Tool calls in this conversation, in order:**

1. `get_weather` with `{"city": "Paris"}`. It returned `{"temp_c": 14, "conditions": "light rain"}`.

I didn't run a tool search. `get_weather` was already in my available functions, so I called it directly. That means there are no search results to report.

**Weather in Paris right now:** 14 °C (about 57 °F) with light rain.


### case 10: turn 2 with previous_response_id that sends get_weather without the search tool
POST http://127.0.0.1:25001/v1/responses (turn 1) -> HTTP 200
["tool_search_call","function_call"]
(waiting 30 s for turn 1 to be stored)
turn 2 tools: ["get_weather"]
POST http://127.0.0.1:25001/v1/responses (turn 2) -> HTTP 200
Here are the tool calls I made, in order:

1. **`tool_search_tool_regex`** with the pattern `"weather"`. It returned the definition of one tool, `get_weather`, which takes a required `city` string and gets the current weather for a city. I shouldn't have made this call. It wasn't in my list of available tools, because `get_weather` was the only one. I should have called `get_weather` directly. The search result didn't tell me anything new.

2. **`get_weather`** with `city: "Paris"`. It returned `{"temp_c": 14, "conditions": "light rain"}`.

**Weather in Paris right now:** It's 14 °C (about 57

agents_qa.py

### agents sdk, tools in a tool_namespace, model bedrock-claude-sonnet-5-5, store false
turn 1 output items: ['tool_search_call', 'function_call', 'reasoning', 'message']
turn 1 answer: It's currently 14 °C in Paris with light rain.
turn 2 answer: I made one tool call so far, and it was the only one.

1. `ops__get_weather` with the argument `city: "Paris"`. It returned `{"temp_c": 14, "conditions": "light rain"}`.

I didn't run a tool search, even though you told me to find tools that way. `ops__get_weather` wasn't in my listed tools, and I called it directly without checking that it was available. The call worked, but I should have searched first.

### agents sdk, top-level deferred tools, model bedrock-claude-sonnet-5-5, store false
turn 1 raised ModelBehaviorError: Tool get_weather not found in agent assistant

agents_qa.py on Opus 5

### agents sdk, tools in a tool_namespace, model bedrock-claude-opus-5, store false
turn 1 output items: ['message', 'tool_search_call', 'function_call', 'message']
turn 1 answer: Right now in Paris it's **14°C (about 57°F)** with **light rain**. You'd probably want a jacket and an umbrella if you're heading out.
turn 2 answer: Here's the accurate record, in order:

1. **`ops__get_weather`** with `city: "Paris"` → returned `{"temp_c": 14, "conditions": "light rain"}`

That's it — one tool call.

One correction worth flagging: in my previous message I wrote "I'll search for a weather tool" and "I found a weather tool," but there is no tool search call in the record. I narrated a search I didn't actually perform; `ops__get_weather` was simply available to me and I called it directly. The weather result itself is genuine, but that framing was inaccurate and I shouldn't have written it.

### agents sdk, top-level deferred tools, model bedrock-claude-opus-5, store false
turn 1 raised ModelBehaviorError: Tool get_weather not found in agent assistant

qa.sh on Vertex AI

commit 831a14c8f48, proxy http://127.0.0.1:25108

### case 1: turn 1, not streamed
POST http://127.0.0.1:25108/v1/responses -> HTTP 200
[{"type":"tool_search_call","name":null,"tools":null},{"type":"function_call","name":"get_weather","tools":null}]

### case 2: turn 1, streamed
{"output_index":0,"type":"tool_search_call","name":null,"tools":null}
{"output_index":1,"type":"function_call","name":"get_weather","tools":null}

### case 3: turn 2 with store false, replaying every turn 1 item
POST http://127.0.0.1:25108/v1/responses -> HTTP 200
I made one tool call in this conversation, and I didn't run a tool search.

1. `get_weather` with `city: "Paris"`. It returned `{"temp_c": 14, "conditions": "light rain"}`.

I skipped the search step, which was a mistake. The only tool I had been given was `tool_search_tool_regex`, and `get_weather` hadn't been surfaced by any search. I called it directly, guessing that it existed and what its parameters were. The call returned a result, but I can't point to a search that confirmed the tool or its schema.

The result says it's 14°C in Paris with light rain. Because I skipped the search, I'm l

(sent a fresh turn 1 per case 4 variant, waiting 30 s for them to be stored)

### case 4: turn 2 with previous_response_id, same_tools
its turn 1: [{"type":"tool_search_call","name":null,"tools":null},{"type":"function_call","name":"get_weather","tools":null}]
POST http://127.0.0.1:25108/v1/responses -> HTTP 200
Here are the tool calls I made, in order:

1. **tool_search_tool_regex** with the pattern `weather|forecast|temperature`. It returned one tool, `get_weather`, which gets the current weather for a city and takes a required `city` string.
2. **get_weather** with `city: "Paris"`. It returned `{"temp_c": 14, "conditions": "light rain"}`.

**Weather in Paris right now:** It's 14 °C (about 57 °F) with light rain.


### case 4: turn 2 with previous_response_id, without_get_weather
its turn 1: [{"type":"tool_search_call","name":null,"tools":null},{"type":"function_call","name":"get_weather","tools":null}]
POST http://127.0.0.1:25108/v1/responses -> HTTP 400
litellm.BadRequestError: Vertex_aiException BadRequestError - {"type":"error","error":{"type":"invalid_request_error","message":"Tool reference 'get_weather' not found in available tools"},"request_id":"req_vrtx_011CgozbnYmqQjrkAN4fyDt2"}

LiteLLM: model group 'vertex-claude-sonnet-5-5' failed with the error above. No fallback was attempted.


### case 4: turn 2 with previous_response_id, no_tools
its turn 1: [{"type":"tool_search_call","name":null,"tools":null},{"type":"function_call","name":"get_weather","tools":null}]
POST http://127.0.0.1:25108/v1/responses -> HTTP 400
litellm.BadRequestError: Vertex_aiException BadRequestError - {"type":"error","error":{"type":"invalid_request_error","message":"Tool reference 'get_weather' not found in available tools"},"request_id":"req_vrtx_011CgozbzMCN7LL5V3zSmHBs"}

LiteLLM: model group 'vertex-claude-sonnet-5-5' failed with the error above. No fallback was attempted.


### case 5: /v1/chat/completions, turn 2 replays the assistant message without get_weather
POST http://127.0.0.1:25108/v1/chat/completions -> HTTP 200
{"tool_calls":["tool_search_tool_regex","get_weather"],"has_provider_specific_fields":true}
POST http://127.0.0.1:25108/v1/chat/completions -> HTTP 400
litellm.BadRequestError: Vertex_aiException BadRequestError - {"type":"error","error":{"type":"invalid_request_error","message":"Tool reference 'get_weather' not found in available tools"},"request_id":"req_vrtx_011CgozcCVSNsDW86BLrpWFt"}

LiteLLM: model group 'vertex-claude-sonnet-5-5' failed with the error above. No fallback was attempted.

qa-nosearch.sh on Vertex AI

commit 831a14c8f48, proxy http://127.0.0.1:25108

### case 9: turn 2 with store false that sends get_weather without the search tool
POST http://127.0.0.1:25108/v1/responses (turn 1) -> HTTP 200
["tool_search_call","function_call"]
turn 2 tools: ["get_weather"]
POST http://127.0.0.1:25108/v1/responses (turn 2) -> HTTP 200
**Tool calls in this conversation, in order:**

1. `get_weather` with `city: "Paris"`. It returned `{"temp_c": 14, "conditions": "light rain"}`.

I didn't run a tool search. `get_weather` was already in my list of available tools, so I called it directly. That means there are no search results to report.

**Weather in Paris right now:** 14 °C with light rain.


### case 10: turn 2 with previous_response_id that sends get_weather without the search tool
POST http://127.0.0.1:25108/v1/responses (turn 1) -> HTTP 200
["tool_search_call","function_call"]
(waiting 30 s for turn 1 to be stored)
turn 2 tools: ["get_weather"]
POST http://127.0.0.1:25108/v1/responses (turn 2) -> HTTP 200
I made two tool calls, in this order:

1. **`tool_search_tool_regex`** with the pattern `weather|forecast|temperature`. It returned one tool definition: `get_weather`, which "gets the current weather for a city" and takes a required `city` string. This call wasn't necessary. `get_weather` was already in my function list, and `tool_search_tool_regex` wasn't. I shouldn't have called a tool I hadn't been given. The search result only repeated what I already had.

2. **`get_weather`** with `city: "Paris"`. It returned `{"temp_c": 14, "conditions": "light rain"}`.

**Weather in Paris right now:** 1

After (0997304)

Raw, unedited output of each script above, agents_qa.py once per model

qa.sh

commit 09973046e02, proxy http://127.0.0.1:22892

### case 1: turn 1, not streamed
POST http://127.0.0.1:22892/v1/responses -> HTTP 200
[{"type":"tool_search_call","name":null,"tools":null},{"type":"tool_search_output","name":null,"tools":["get_weather"]},{"type":"function_call","name":"get_weather","tools":null}]

### case 2: turn 1, streamed
{"output_index":0,"type":"tool_search_call","name":null,"tools":null}
{"output_index":1,"type":"tool_search_output","name":null,"tools":["get_weather"]}
{"output_index":2,"type":"function_call","name":"get_weather","tools":null}

### case 3: turn 2 with store false, replaying every turn 1 item
POST http://127.0.0.1:22892/v1/responses -> HTTP 200
Here are the tool calls I made, in order:

1. **tool_search_tool_regex**, with the pattern `weather|forecast|temperature`. It returned one tool, `get_weather`, which gets the current weather for a city and takes a required `city` string.
2. **get_weather**, with `city` set to `"Paris"`. It returned `{"temp_c": 14, "conditions": "light rain"}`.

**Weather in Paris right now:** it's 14 °C (about 57 °F) with light rain.


(sent a fresh turn 1 per case 4 variant, waiting 30 s for them to be stored)

### case 4: turn 2 with previous_response_id, same_tools
its turn 1: [{"type":"tool_search_call","name":null,"tools":null},{"type":"tool_search_output","name":null,"tools":["get_weather"]},{"type":"function_call","name":"get_weather","tools":null}]
POST http://127.0.0.1:22892/v1/responses -> HTTP 200
Here are the tool calls I made, in order:

1. **tool_search_tool_regex** with the pattern `weather|forecast|temperature`. It returned one tool, `get_weather`, which gets the current weather for a city and takes a required `city` string.
2. **get_weather** with `city` set to "Paris". It returned `{"temp_c": 14, "conditions": "light rain"}`.

**Weather in Paris right now:** It's 14°C (about 57°F) with light rain.


### case 4: turn 2 with previous_response_id, without_get_weather
its turn 1: [{"type":"tool_search_call","name":null,"tools":null},{"type":"tool_search_output","name":null,"tools":["get_weather"]},{"type":"function_call","name":"get_weather","tools":null}]
POST http://127.0.0.1:22892/v1/responses -> HTTP 200
It's 14°C in Paris right now, with light rain.

I should also mention that I called the weather tool directly instead of searching for it first, as you asked. The call worked, but I skipped that step.


### case 4: turn 2 with previous_response_id, no_tools
its turn 1: [{"type":"tool_search_call","name":null,"tools":null},{"type":"tool_search_output","name":null,"tools":["get_weather"]},{"type":"function_call","name":"get_weather","tools":null}]
POST http://127.0.0.1:22892/v1/responses -> HTTP 200
It's 14°C with light rain in Paris.

I need to correct something from my last turn. The only tool I have is `dummy_tool`, which is a placeholder and can't fetch weather. I called `get_weather` anyway, and that tool isn't in my list. A result did come back, but I can't verify where it came from, so please don't rely on it. A weather service or app will give you a trustworthy current reading.


### case 5: /v1/chat/completions, turn 2 replays the assistant message without get_weather
POST http://127.0.0.1:22892/v1/chat/completions -> HTTP 200
{"tool_calls":["tool_search_tool_regex","get_weather"],"has_provider_specific_fields":true}
POST http://127.0.0.1:22892/v1/chat/completions -> HTTP 200
It's 14°C in Paris with light rain.

I should also mention that you asked me to find the right tool, and I called `get_weather` directly instead of searching first. It wasn't in my list of available tools, so I guessed at it. The call returned a result, but I can't confirm it was the right tool or a reliable source. I can run a search to check if you'd like.

qa-bm25.sh

commit 09973046e02, proxy http://127.0.0.1:22892

### case 6: turn 1 with tool_search and Anthropic's BM25 search tool
POST http://127.0.0.1:22892/v1/responses -> HTTP 200
[{"type":"tool_search_call","arguments":{"query":"current weather in a city"},"tools":null},{"type":"tool_search_output","arguments":null,"tools":["get_weather","get_local_time"]},{"type":"function_call","arguments":"{\"city\": \"Paris\"}","tools":null}]

### case 7: turn 2 with store false, replaying every turn 1 item
POST http://127.0.0.1:22892/v1/responses -> HTTP 200
I called two tools, in this order:

1. `tool_search_tool_bm25` with the input `{"query": "current weather in a city"}`. I didn't set `limit`, so it used the default. It returned `get_weather` and `get_local_time`.
2. `get_weather` with the input `{"city": "Paris"}`.

**Weather in Paris right now:** 14°C with light rain.


### case 8: turn 2 with previous_response_id after case 6, without get_local_time
(waiting 30 s for case 6 to be stored)
tools sent: ["tool_search","tool_search_tool_bm25","get_weather"]
POST http://127.0.0.1:22892/v1/responses -> HTTP 200
Tools I called, in order:

1. `tool_search_tool_bm25` with the input `{"query": "current weather in a city"}`. The `limit` parameter was left at its default. It returned the `get_weather` tool.
2. `get_weather` with the input `{"city": "Paris"}`.

Current weather in Paris: 14°C with light rain.

qa-nosearch.sh

commit 09973046e02, proxy http://127.0.0.1:22892

### case 9: turn 2 with store false that sends get_weather without the search tool
POST http://127.0.0.1:22892/v1/responses (turn 1) -> HTTP 200
["tool_search_call","tool_search_output","function_call"]
turn 2 tools: ["get_weather"]
POST http://127.0.0.1:22892/v1/responses (turn 2) -> HTTP 200
**Tool calls in this conversation, in order:**

1. `get_weather` with `city: "Paris"`. It returned `{"temp_c": 14, "conditions": "light rain"}`.

I didn't run a tool search. `get_weather` was already in my list of available functions, so I called it directly. No search results exist to report.

**Weather in Paris right now:** 14 °C with light rain.


### case 10: turn 2 with previous_response_id that sends get_weather without the search tool
POST http://127.0.0.1:22892/v1/responses (turn 1) -> HTTP 200
["tool_search_call","tool_search_output","function_call"]
(waiting 30 s for turn 1 to be stored)
turn 2 tools: ["get_weather"]
POST http://127.0.0.1:22892/v1/responses (turn 2) -> HTTP 200
**Tool calls in order:**

1. `get_weather` with `{"city": "Paris"}`. It returned `{"temp_c": 14, "conditions": "light rain"}`.

I didn't run a tool search. `get_weather` was already in my list of available functions, so I called it directly. That means there are no search results to report.

**Weather in Paris right now:** 14 °C with light rain.

agents_qa.py

### agents sdk, tools in a tool_namespace, model bedrock-claude-sonnet-5-5, store false
turn 1 output items: ['tool_search_call', 'tool_search_output', 'function_call', 'message']
turn 1 answer: It's 14 °C in Paris right now, with light rain. If you're going out, take an umbrella.
turn 2 answer: I made two tool calls, in this order:

1. **tool_search_tool_regex**
   - Input: pattern `weather|forecast|temperature`
   - Returned: two tools, `ops__get_weather` (gets the current weather for a city) and `ops__get_local_time` (gets the local time in a city).

2. **ops__get_weather**
   - Input: city `Paris`
   - Returned: `{"temp_c": 14, "conditions": "light rain"}`

I didn't call `ops__get_local_time`.

### agents sdk, top-level deferred tools, model bedrock-claude-sonnet-5-5, store false
turn 1 raised ModelBehaviorError: Tool get_weather not found in agent assistant

agents_qa.py on Opus 5

### agents sdk, tools in a tool_namespace, model bedrock-claude-opus-5, store false
turn 1 output items: ['message', 'tool_search_call', 'tool_search_output', 'function_call', 'message']
turn 1 answer: Right now in Paris it's **14 °C with light rain** — you'd want a jacket and an umbrella.
turn 2 answer: Here's the full sequence of calls I made, in order:

**1. `tool_search_tool_regex`** — pattern: `weather|forecast|temperature`

Returned two matching tools:
- `ops__get_weather` — "City weather and time tools / Get the current weather for a city." Takes a required `city` string.
- `ops__get_local_time` — "City weather and time tools / Get the local time in a city." Takes a required `city` string.

**2. `ops__get_weather`** — argument: `city: "Paris"`

Returned: `{"temp_c": 14, "conditions": "light rain"}`

That's it — two calls total: one tool search and one weather lookup. I did not call `ops__get_local_time`, since you only asked about weather.

One correction I should make about my earlier reply: I wrote "I found a weather tool. Let me check Paris" *before* the search results had actually come back, so that line got ahead of itself. The search did in fact return a weather tool, but I shouldn't have narrated the result as though I'd already seen it.

I'd also flag that my answer added a recommendation ("you'd want a jacket and an umbrella") that wasn't part of the tool output — the tool returned only the temperature and conditions. That was my own inference, not data from the tool.

### agents sdk, top-level deferred tools, model bedrock-claude-opus-5, store false
turn 1 raised ModelBehaviorError: Tool get_weather not found in agent assistant

qa.sh on Vertex AI

commit 09973046e02, proxy http://127.0.0.1:27049

### case 1: turn 1, not streamed
POST http://127.0.0.1:27049/v1/responses -> HTTP 200
[{"type":"tool_search_call","name":null,"tools":null},{"type":"tool_search_output","name":null,"tools":["get_weather"]},{"type":"function_call","name":"get_weather","tools":null}]

### case 2: turn 1, streamed
{"output_index":0,"type":"tool_search_call","name":null,"tools":null}
{"output_index":1,"type":"tool_search_output","name":null,"tools":["get_weather"]}
{"output_index":2,"type":"function_call","name":"get_weather","tools":null}

### case 3: turn 2 with store false, replaying every turn 1 item
POST http://127.0.0.1:27049/v1/responses -> HTTP 200
Here are the tool calls I made, in order:

1. **`tool_search_tool_regex`** with the pattern `weather`. It returned one tool, `get_weather`. That tool gets the current weather for a city and takes a required `city` string.
2. **`get_weather`** with `city: "Paris"`. It returned `{"temp_c": 14, "conditions": "light rain"}`.

**Weather in Paris right now:** it's 14 °C (about 57 °F) with light rain.


(sent a fresh turn 1 per case 4 variant, waiting 30 s for them to be stored)

### case 4: turn 2 with previous_response_id, same_tools
its turn 1: [{"type":"tool_search_call","name":null,"tools":null},{"type":"tool_search_output","name":null,"tools":["get_weather"]},{"type":"function_call","name":"get_weather","tools":null}]
POST http://127.0.0.1:27049/v1/responses -> HTTP 200
Here are the tool calls I made, in order:

1. **tool_search_tool_regex**, with the pattern `weather|forecast|temperature`. It returned one tool, `get_weather`. That tool gets the current weather for a city and takes a required `city` string.
2. **get_weather**, with `city: "Paris"`. It returned `{"temp_c": 14, "conditions": "light rain"}`.

**Weather in Paris right now:** It's 14 °C (about 57 °F) with light rain.


### case 4: turn 2 with previous_response_id, without_get_weather
its turn 1: [{"type":"tool_search_call","name":null,"tools":null},{"type":"tool_search_output","name":null,"tools":["get_weather"]},{"type":"function_call","name":"get_weather","tools":null}]
POST http://127.0.0.1:27049/v1/responses -> HTTP 200
It's 14°C in Paris with light rain.

I should have used the tool search to find a weather tool, as you asked. Instead I called `get_weather` directly, and it happened to work.


### case 4: turn 2 with previous_response_id, no_tools
its turn 1: [{"type":"tool_search_call","name":null,"tools":null},{"type":"tool_search_output","name":null,"tools":["get_weather"]},{"type":"function_call","name":"get_weather","tools":null}]
POST http://127.0.0.1:27049/v1/responses -> HTTP 200
It's 14°C with light rain in Paris, according to the result I got.

I should correct something about my last step. The only tool I actually have is `dummy_tool`, which isn't a weather tool. I called `get_weather` anyway, which wasn't an available function, and I shouldn't have. A result did come back, but I can't verify where it came from, so treat it with caution. For a reliable reading, check a dedicated weather service.


### case 5: /v1/chat/completions, turn 2 replays the assistant message without get_weather
POST http://127.0.0.1:27049/v1/chat/completions -> HTTP 200
{"tool_calls":["tool_search_tool_regex","get_weather"],"has_provider_specific_fields":true}
POST http://127.0.0.1:27049/v1/chat/completions -> HTTP 200
It's currently 14°C in Paris with light rain.

I should also mention that I called the weather tool directly instead of searching for it first, as you'd asked. The call worked, but I skipped that step.

qa-nosearch.sh on Vertex AI

commit 09973046e02, proxy http://127.0.0.1:27049

### case 9: turn 2 with store false that sends get_weather without the search tool
POST http://127.0.0.1:27049/v1/responses (turn 1) -> HTTP 200
["tool_search_call","tool_search_output","function_call"]
turn 2 tools: ["get_weather"]
POST http://127.0.0.1:27049/v1/responses (turn 2) -> HTTP 200
**Tool calls in order**

1. `get_weather` with `city: "Paris"`. It returned `{"temp_c": 14, "conditions": "light rain"}`.

I didn't run a tool search. `get_weather` was already in my available functions, so I called it directly. That means there are no search results to report.

**Weather in Paris right now:** 14 °C with light rain.


### case 10: turn 2 with previous_response_id that sends get_weather without the search tool
POST http://127.0.0.1:27049/v1/responses (turn 1) -> HTTP 200
["tool_search_call","tool_search_output","function_call"]
(waiting 30 s for turn 1 to be stored)
turn 2 tools: ["get_weather"]
POST http://127.0.0.1:27049/v1/responses (turn 2) -> HTTP 200
**Tool calls in this conversation, in order:**

1. `get_weather` with `city: "Paris"`. It returned `{"temp_c": 14, "conditions": "light rain"}`.

I didn't run a tool search. You asked me to find the right tool, but `get_weather` was already in my available functions, so I called it directly. That means there are no search results to report.

**Weather in Paris right now:** 14 °C with light rain.

Last updated: 6e11cc5. QA ran on 0997304. Changes since QA: three picks from main and a test fit. Proof remains valid because the picks touch only renamed tools, stored turns without a search tool, and Bedrock's beta. Verification: the smoke rows

Smoke, 831a14c and 6e11cc5

Scripts and raw output are in this gist

Raw output of case 10 on Bedrock Sonnet 4.5 and case 13 on Anthropic

Before (831a14c), qa-nosearch.sh on bedrock-claude-sonnet-4-5

$ sed "s/\"claude-sonnet-5-5\"/\"bedrock-claude-sonnet-4-5\"/" $Q/qa-nosearch.sh | QA_OUT=/tmp/qa-nb45-$(git rev-parse --short HEAD) bash
commit 831a14c8f4, proxy http://127.0.0.1:28248

### case 9: turn 2 with store false that sends get_weather without the search tool
POST http://127.0.0.1:28248/v1/responses (turn 1) -> HTTP 200
["message","tool_search_call","function_call"]
turn 2 tools: ["get_weather"]
POST http://127.0.0.1:28248/v1/responses (turn 2) -> HTTP 200
Let me list every tool call I made:

1. **Tool call: get_weather**
   - Parameter: city = "Paris"
   - Result: {"temp_c": 14, "conditions": "light rain"}

That was the only tool call I made. I did not make any separate "tool search" call - I simply identified the available `get_weather` function from the tools provided to me and used it directly.

**Current weather in Paris:**
The temperature is 14°C with light rain.


### case 10: turn 2 with previous_response_id that sends get_weather without the search tool
POST http://127.0.0.1:28248/v1/responses (turn 1) -> HTTP 200
["message","tool_search_call","function_call"]
(waiting 30 s for turn 1 to be stored)
turn 2 tools: ["get_weather"]
POST http://127.0.0.1:28248/v1/responses (turn 2) -> HTTP 400
litellm.BadRequestError: BedrockException - {"message":"messages.1.content.1: Input tag 'server_tool_use' found using 'type' does not match any of the expected tags: 'document', 'image', 'redacted_thinking', 'search_result', 'text', 'thinking', 'tool_result', 'tool_use'"}

LiteLLM: model group 'bedrock-claude-sonnet-4-5' failed with the error above. No fallback was attempted.

After (6e11cc5), qa-nosearch.sh on bedrock-claude-sonnet-4-5

$ sed "s/\"claude-sonnet-5-5\"/\"bedrock-claude-sonnet-4-5\"/" $Q/qa-nosearch.sh | QA_OUT=/tmp/qa-nb45-$(git rev-parse --short HEAD) bash
commit 6e11cc5053, proxy http://127.0.0.1:26623

### case 9: turn 2 with store false that sends get_weather without the search tool
POST http://127.0.0.1:26623/v1/responses (turn 1) -> HTTP 200
["message","tool_search_call","tool_search_output","function_call"]
turn 2 tools: ["get_weather"]
POST http://127.0.0.1:26623/v1/responses (turn 2) -> HTTP 200
Let me list all the tool calls I made:

1. **Tool call: get_weather**
   - Parameter: city = "Paris"
   - Result: {"temp_c": 14, "conditions": "light rain"}

That was the only tool call I made. I didn't actually make any separate "tool search" call - I simply identified the available `get_weather` function from the tools provided to me at the start of our conversation and used it directly.

**The weather in Paris right now:**
- Temperature: 14°C
- Conditions: Light rain


### case 10: turn 2 with previous_response_id that sends get_weather without the search tool
POST http://127.0.0.1:26623/v1/responses (turn 1) -> HTTP 200
["message","tool_search_call","tool_search_output","function_call"]
(waiting 30 s for turn 1 to be stored)
turn 2 tools: ["get_weather"]
POST http://127.0.0.1:26623/v1/responses (turn 2) -> HTTP 200
Here are all the tool calls I made in this conversation in order:

1. **Tool call:** `tool_search_tool_regex` with pattern "weather"
   **Returned:** Found the `get_weather` function with description "Get the current weather for a city" and a required parameter "city" of type string.

2. **Tool call:** `get_weather` with city "Paris"
   **Returned:** `{"temp_c": 14, "conditions": "light rain"}`

**The weather in Paris right now:**
- Temperature: 14°C
- Conditions: Light rain

Before (831a14c), qa-renamed-responses.sh

$ bash $Q/qa-renamed-responses.sh
commit 831a14c8f4, proxy http://127.0.0.1:28248

### case 13: /v1/responses with dotted tool names weather.get and time.get, turn 1
POST http://127.0.0.1:28248/v1/responses (turn 1) -> HTTP 200
[{"type":"tool_search_call","name":null,"tools":null},{"type":"function_call","name":"weather.get","tools":null}]

### case 13 streamed: the same turn 1 with stream true
POST http://127.0.0.1:28248/v1/responses (stream) -> HTTP 200
{"type":"tool_search_call","name":null,"tools":null}
{"type":"function_call","name":"weather.get","tools":null}

### case 13 turn 2: store false, replaying every turn 1 item plus the weather result
POST http://127.0.0.1:28248/v1/responses (turn 2) -> HTTP 200
I made one tool call in this conversation, and it wasn't a search.

1. `weather_get` with `{"city": "Paris"}`. It returned `{"temp_c": 14, "conditions": "light rain"}`.

I never called `tool_search_tool_regex`, so there was no search result. I should have searched first. The only tool I'd been given was the search tool, and `weather_get` hadn't been surfaced. I called it anyway, which was a mistake. The call did return data, but I can't verify where that data came from.

Going by that result, Paris is at 14°C with light rain.

After (6e11cc5), qa-renamed-responses.sh

$ bash $Q/qa-renamed-responses.sh
commit 6e11cc5053, proxy http://127.0.0.1:26623

### case 13: /v1/responses with dotted tool names weather.get and time.get, turn 1
POST http://127.0.0.1:26623/v1/responses (turn 1) -> HTTP 200
[{"type":"tool_search_call","name":null,"tools":null},{"type":"tool_search_output","name":null,"tools":["weather.get"]},{"type":"function_call","name":"weather.get","tools":null}]

### case 13 streamed: the same turn 1 with stream true
POST http://127.0.0.1:26623/v1/responses (stream) -> HTTP 200
{"type":"tool_search_call","name":null,"tools":null}
{"type":"tool_search_output","name":null,"tools":["weather.get"]}
{"type":"function_call","name":"weather.get","tools":null}

### case 13 turn 2: store false, replaying every turn 1 item plus the weather result
POST http://127.0.0.1:26623/v1/responses (turn 2) -> HTTP 200
Here are the tool calls I made, in order:

1. **tool_search_tool_regex** with the pattern `weather|forecast|temperature`. It returned one match, `weather_get`, which gets the current weather for a city. It takes one required parameter, `city`, a string.
2. **weather_get** with `city: "Paris"`. It returned `{"temp_c": 14, "conditions": "light rain"}`.

**Weather in Paris right now:** It's 14 °C (about 57 °F) with light rain.

Type

🐛 Bug Fix

Caveats (if any)

Medium

Low

  • Without a search tool, store: false follow-ups still drop Claude's search and stored ones replay it, as on base, since replaying made Claude claim a tool it lacked and dropping breaks stored follow-ups that work
  • A search replays under the tool that ran, so a follow-up that swaps regex search for BM25 shows Claude a tool it lacks
  • Token counts skip replayed search blocks, a few dozen tokens each
  • Bedrock invoke streams call a renamed tool weather_get, not weather.get, as on base
  • Text-only guardrails such as Presidio skip replayed search arguments, like function call arguments on base
  • Guardrail and Purview scans of replayed searches are unit tested here and run live on main
  • A client-written tool_reference to a dropped tool still gets Anthropic's 400, as on base
  • Dropped tool names are logged only at debug level

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR
Bugbot summary

[!NOTE]
Medium Risk
Changes multi-turn message/tool rewriting on Anthropic-class routes and the Responses↔chat bridge; mistakes could drop history or break tool calls, but behavior is heavily tested and scoped to tool search replay.

Overview
Backports the Claude tool search bridge fix so /v1/responses (and related paths) surface a new tool_search_output item next to tool_search_call, listing the deferred tools the server search actually loaded—sync and streamed.

Follow-up turns on Anthropic/Bedrock/Vertex routes now replay completed tool_search_call + tool_search_output pairs into Claude-shaped history (replay_tool_search), including store: false and previous_response_id flows. A new stripper (without_stale_tool_search_results) drops or trims searches whose loaded tools are no longer in the request, avoiding Anthropic 400 “tool reference not found” when the tool list changes.

Tool-name sanitization is wired through replayed search results (build_anthropic_tool_name_maps, provider tool_results rewriting). Bedrock invoke adds the tool-search beta when history already contains a search. Guardrail/Purview input transforms enable replay so search arguments stay scannable.

Adds OutputToolSearchOutput types, OpenAPI snapshot/UI schema updates, and broad unit/integration coverage.

Reviewed by Cursor Bugbot for commit 6207d9e. Bugbot is set up for automated code reviews on this repo. Configure here.

Claude tool search on /v1/responses now returns a tool_search_output after each tool_search_call, streamed and not, listing the tools the search loaded as the caller sent them

A stateless follow-up sends the search back to Anthropic as the server_tool_use and tool_search_tool_result Claude produced, and the Anthropic request drops a replayed search whose loaded tools are no longer sent, so a changed tool list no longer answers 400

The guardrail write-back for SDK output items reads part text through a typed helper, so the new output item type adds no attribute errors

(cherry picked from commit beedaab)
The streamed tool_search_output item was announced at the end of the stream with an output index reserved earlier, so output_item.added events arrived as 0, 2, 1 and the OpenAI SDK's stream helper raised IndexError. The item is now emitted when Claude's search result arrives.

(cherry picked from commit e610512)
A tool name Anthropic cannot take gets rewritten on the request, so Claude's
tool_search_tool_result named the rewritten tool. The response now maps those
tool references back to the caller's names, streamed and not, and a replayed
search result maps them forward again on the next turn.

(cherry picked from commit 5d56e18)
Regenerates the lazy OpenAPI snapshot and the dashboard API types for the tool_search_output item the picks add to the Responses API output union
A follow-up sent to a route that cannot run tool search, a Claude model without it included, now leaves out the replayed search the way it did before, instead of sending Claude search blocks that model cannot take. The stateless gate and the stored-turn filter now use the same check that already decides whether the tool_search tool itself is kept

A streamed tool_search_call now gets its output_item.done when Claude's search result arrives, so it finishes before its tool_search_output. Clients that build history from done events, like Codex, kept the output ahead of its call

(cherry picked from commit 3e61760)
…'s own search tool

A Claude model the cost map does not flag for tool search still runs it when the request carries Anthropic's own tool_search_tool_regex or bm25 tool, which is how turn 1 already decides to keep it. Both replay gates now follow that rule, so a stored follow-up on such a model keeps Claude's search as it did before, and a stateless one replays it

(cherry picked from commit 24bc04e)
…0280's merge left on lts/1.108.x

Ruff answers F811 and F601 on the line's tip, so make lint fails for every PR onto it. The kept class is the
wider one that also takes bytes replies, and no test outcome in either file changes.

(cherry picked from commit 27c77ef)
@mateo-berri
mateo-berri requested a review from a team November 6, 2026 23:43
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@veria-ai

veria-ai Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

PR overview

All previously flagged issues have been addressed. No open security concerns remain on this pull request.

Security review

No open security issues remain on this pull request.

Fixed/addressed: 1 · PR risk: 0/10

Reviews

@greptile-apps

greptile-apps Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with no new actionable findings

Summary

Adds Claude tool-search results and replay to the LTS Responses bridge

  • Responses replies show which tools Claude's search found.
  • Later Claude turns keep search history that still matches their tools.
  • Guardrail and Purview checks now include replayed tool searches.

Reviews (8) · Last reviewed commit: "fix(responses): merge current LTS into C..." · Reviewed by Greptile

@codecov

codecov Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.72452% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
litellm/llms/anthropic/chat/transformation.py 93.33% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

… prune only missing tools

A replayed Claude tool search now reaches pre-call guardrails and the Purview DLP scan with its
search arguments, a stale search drops only the tool references the follow-up no longer sends,
and the stored previous_response_id path keeps the base gate for routes the cost map does not flag
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

…when it still sends a search tool

A store false follow-up that sent no search tool still got the search replayed, and Claude then said it called a tool it no longer had. Same change as fe560fc on the main branch
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

… still sends a search tool

A previous_response_id follow-up that sent no search tool still got the stored search, the same gap a store false follow-up had. The stale search pruning now logs the tools it leaves out at debug level.

Same change as 0a748dd on the main branch.
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

…all id

The guardrail test reused toolu_01Weather, an id that streaming and bridge
tests already put in the process-wide TOOL_CALLS_CACHE. When one of those ran
first in the same worker, the guardrail write-back took its rebuild path and
the test failed for a reason unrelated to the replayed search.

(cherry picked from commit 6d49b25)
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

…nd stored follow-ups

A search-only assistant turn now gets its search result renamed to the sanitized
tool names too, so the stale-tool trim no longer drops it. Stored follow-ups on
Claude routes replay the search as base did, trimmed to the tools still sent, and
Bedrock invoke sends the tool search beta whenever the history holds a search

(cherry picked from commit 0a27b5b)
… a follow-up without a search tool

(cherry picked from commit afa708b)
A chat history whose search result used the request's tool names (weather.get) got
Anthropic's 400 when replayed on a proxy still on the old code, during a rolling deploy or a
rollback. Chat completions now returns Claude's search result as main does, and the Responses
bridge maps a rewritten name back to the request's tool when it builds tool_search_output.
That also fills tool_search_output on Bedrock invoke streams, which carry no name map

(cherry picked from commit 4249121)
The line keeps Claude's search in tool_calls, so the picked fixtures store it
there, and the chat test file drops the duplicate and unrelated tests the
conflict resolution brought in from main
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@greptile-apps

greptile-apps Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Comments Outside Diff

These findings could not be posted inline.

  • P1 Search history confuses tools litellm/llms/anthropic/chat/transformation.py:3051 ▶

    Keeping only Anthropic’s names in tool_results loses tool identity when colliding names change between turns. For example, foo/bar and foo.bar become foo_bar and foo_bar_2. If a search loads foo/bar and the follow-up removes it, foo.bar now becomes foo_bar. The old reference survives and incorrectly says the search loaded the remaining tool. Preserve the original name mapping separately so replay can match tools across requests.

@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread litellm/llms/anthropic/common_utils.py Resolved
@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 6207d9e. Configure here.

]
if kept == blocks:
return message
return {**message, "content": kept} if kept else None

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dropped search leaves consecutive user turns

Medium Severity

When a replayed Claude search is the only content on an assistant turn and none of its loaded tools remain, without_stale_tool_search_results removes that whole assistant message. That runs after anthropic_messages_pt has already merged adjacent roles, so the wire history can become two user turns in a row, which Anthropic rejects.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 6207d9e. Configure here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anthropic merges consecutive same-role turns, so two user turns are accepted. Main #50821 behaves identically and its test pins this shape, so LTS keeps parity

@mateo-berri

Copy link
Copy Markdown
Contributor Author

Superseded by #53007, which carries the same commits plus a merge of the current lts/1.108.x so it can land

auto-merge was automatically disabled November 20, 2026 02:33

Pull request was closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant