litellm - ✅(Solved) Fix [Bug]: websearch_interception agentic loop not triggered for Bedrock via /chat/completions [1 pull requests, 1 comments, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
BerriAI/litellm#25191Fetched 2026-04-08 02:53:12
View on GitHub
Comments
1
Participants
1
Timeline
3
Reactions
0
Author
Participants
Timeline (top)
commented ×1cross-referenced ×1labeled ×1

Fix Action

Fixed

PR fix notes

PR #25202: fix(bedrock): trigger websearch_interception agentic loop for /chat/completions

Description (problem / solution / changelog)

Relevant issues

Fixes #25191

<!-- e.g. "Fixes #000" -->

Pre-Submission checklist

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

  • I have Added testing in the tests/test_litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem
  • I have requested a Greptile review by commenting @greptileai and received a Confidence Score of at least 4/5 before requesting a maintainer review

Type

<!-- Select the type of Pull Request --> <!-- Keep only the necessary ones -->

🐛 Bug Fix

Changes

BedrockConverseLLM.async_completion() returned the transformed response directly without calling agentic chat completion hooks. This meant websearch_interception worked via /v1/messages (which goes through llm_http_handler) but not via /chat/completions for Bedrock.

Added _call_agentic_chat_completion_hooks() to BedrockConverseLLM and call it after _transform_response() in async_completion(), matching the pattern used by base llm http handler and open AI chat.

Changed files

  • litellm/llms/bedrock/chat/converse_handler.py (modified, +95/-5)
  • tests/test_litellm/integrations/websearch_interception/test_websearch_chat_completion.py (modified, +212/-0)

Code Example

model_list:
  - model_name: claude-sonnet-4-6
    litellm_params:
      model: bedrock/us.anthropic.claude-sonnet-4-6
      aws_region_name: us-east-1

litellm_settings:
  callbacks:
    - websearch_interception
  websearch_interception_params:
    enabled_providers:
      - bedrock
    search_tool_name: google-search

search_tools:
  - search_tool_name: google-search
    litellm_params:
      search_provider: google_pse
      api_key: os.environ/GOOGLE_PSE_API_KEY
      engine_id: os.environ/GOOGLE_PSE_ENGINE_ID

---

[ec2-user@awsdti gemini]$ curl --location 'http://0.0.0.0:4000/chat/completions' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <your token>' \
--data '{
  "model": "claude-sonnet-4-6",
  "messages": [
    {
      "role": "user",
      "content": "Wie wird das Wetter morgen in Singen am Hohentwiel?"
    }
  ],
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "litellm_web_search",
        "description": "Search the web for current information",
        "parameters": {
          "type": "object",
          "properties": {
            "query": {"type": "string"}
          },
          "required": ["query"]
        }
      }
    }
  ]
}'
{"id":"chatcmpl-ac5029cc-4b39-4ca3-abf5-9d56eb023a3c","created":1775404891,"model":"claude-sonnet-4-6","object":"chat.completion","choices":[{"finish_reason":"tool_calls","index":0,"message":{"content":"","role":"assistant","tool_calls":[{"index":0,"function":{"arguments":"{\"query\": \"Wetter morgen Singen am Hohentwiel\"}","name":"litellm_web_search"},"id":"tooluse_I8ehiUVjTtGArUT8p1O6xr","type":"function"}]}}],"usage":{"completion_tokens":71,"prompt_tokens":611,"total_tokens":682,"completion_tokens_details":{"reasoning_tokens":0,"text_tokens":71},"prompt_tokens_details":{"cached_tokens":0,"cache_creation_tokens":0},"cache_creation_input_tokens":0,"cache_read_input_tokens":0}}[ec2-user@awsdti gemini]$ ^C

---
RAW_BUFFERClick to expand / collapse

Check for existing issues

  • I have searched the existing issues and checked that my issue is not a duplicate.

What happened?

A bug happened! when using websearch_interception with AWS Bedrock and the /chat/completions endpoint, the agentic loop is not executed. The model correctly returns a tool_calls response with litellm_web_search, but LiteLLM does not intercept it and execute the search automatically.

The same setup works correctly when using the /v1/messages (Anthropic Messages API) endpoint.

LiteLLM should automatically intercept the litellm_web_search tool call, execute the search via the configured search provider, and return the final answer — just like it does for /v1/messages.

Configuration:

model_list:
  - model_name: claude-sonnet-4-6
    litellm_params:
      model: bedrock/us.anthropic.claude-sonnet-4-6
      aws_region_name: us-east-1

litellm_settings:
  callbacks:
    - websearch_interception
  websearch_interception_params:
    enabled_providers:
      - bedrock
    search_tool_name: google-search

search_tools:
  - search_tool_name: google-search
    litellm_params:
      search_provider: google_pse
      api_key: os.environ/GOOGLE_PSE_API_KEY
      engine_id: os.environ/GOOGLE_PSE_ENGINE_ID

Steps to Reproduce

[ec2-user@awsdti gemini]$ curl --location 'http://0.0.0.0:4000/chat/completions' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <your token>' \
--data '{
  "model": "claude-sonnet-4-6",
  "messages": [
    {
      "role": "user",
      "content": "Wie wird das Wetter morgen in Singen am Hohentwiel?"
    }
  ],
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "litellm_web_search",
        "description": "Search the web for current information",
        "parameters": {
          "type": "object",
          "properties": {
            "query": {"type": "string"}
          },
          "required": ["query"]
        }
      }
    }
  ]
}'
{"id":"chatcmpl-ac5029cc-4b39-4ca3-abf5-9d56eb023a3c","created":1775404891,"model":"claude-sonnet-4-6","object":"chat.completion","choices":[{"finish_reason":"tool_calls","index":0,"message":{"content":"","role":"assistant","tool_calls":[{"index":0,"function":{"arguments":"{\"query\": \"Wetter morgen Singen am Hohentwiel\"}","name":"litellm_web_search"},"id":"tooluse_I8ehiUVjTtGArUT8p1O6xr","type":"function"}]}}],"usage":{"completion_tokens":71,"prompt_tokens":611,"total_tokens":682,"completion_tokens_details":{"reasoning_tokens":0,"text_tokens":71},"prompt_tokens_details":{"cached_tokens":0,"cache_creation_tokens":0},"cache_creation_input_tokens":0,"cache_read_input_tokens":0}}[ec2-user@awsdti gemini]$ ^C

Relevant log output

What part of LiteLLM is this about?

Proxy

What LiteLLM version are you on ?

v.1.82.3

Twitter / LinkedIn details

No response

extent analysis

TL;DR

The issue with websearch_interception not executing the agentic loop when using the /chat/completions endpoint may be related to the specific configuration or implementation of the LiteLLM proxy.

Guidance

  • Verify that the websearch_interception callback is correctly configured and enabled for the /chat/completions endpoint.
  • Check if there are any differences in the request or response formats between the /chat/completions and /v1/messages endpoints that could affect the websearch_interception behavior.
  • Review the LiteLLM documentation to ensure that the websearch_interception feature is supported for the /chat/completions endpoint.
  • Test the websearch_interception feature with a different endpoint or configuration to isolate the issue.

Notes

The issue may be specific to the LiteLLM version (v.1.82.3) or the AWS Bedrock configuration, and further investigation is needed to determine the root cause.

Recommendation

Apply workaround: Try using the /v1/messages endpoint instead of /chat/completions to see if the websearch_interception feature works as expected. This can help isolate the issue and determine if it's specific to the /chat/completions endpoint.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING