litellm - ✅(Solved) Fix [Bug]: `websearch_interception` Anthropic follow-up call passes duplicate Claude Code params (`context_management`, `output_config`) and breaks server-side web search [1 pull requests, 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#26163Fetched 2026-04-22 07:46:09
View on GitHub
Comments
0
Participants
1
Timeline
5
Reactions
0
Author
Participants
Timeline (top)
labeled ×4cross-referenced ×1

Error Message

Actual behavior

LiteLLM detects litellm_web_search, executes the search successfully, then fails during the follow-up request.

Observed log sequence:

WebSearchInterception: Search completed for 'latest developments ongoing event 2025 2026', got 7257 chars WebSearchInterception: Making follow-up request with search results TypeError: litellm.anthropic_interface.messages.acreate() got multiple values for keyword argument 'context_management'

After locally hotfixing that duplication, the next failure becomes:

TypeError: litellm.anthropic_interface.messages.acreate() got multiple values for keyword argument 'output_config'

Claude Code then falls back to saying web search is unavailable.

Expected behavior

LiteLLM should complete the full agentic loop:

  1. intercept native web search
  2. execute configured search provider
  3. make Anthropic follow-up request with search results
  4. return final answer to Claude Code

No duplicate keyword arguments should be passed to anthropic_messages.acreate().

Root cause

In litellm/integrations/websearch_interception/handler.py, _execute_agentic_loop() builds the follow-up call like this:

final_response = await anthropic_messages.acreate( max_tokens=max_tokens, messages=follow_up_messages, model=full_model_name, **optional_params_without_max_tokens, **kwargs_for_followup, )

But _prepare_followup_kwargs() currently only filters:

_internal_keys = {"litellm_logging_obj"}

Claude Code requests include fields such as context_management and output_config, and these can exist in both:

  • anthropic_messages_optional_request_params
  • kwargs

So the follow-up call receives duplicate kwargs and crashes.

Root Cause

In litellm/integrations/websearch_interception/handler.py, _execute_agentic_loop() builds the follow-up call like this:

final_response = await anthropic_messages.acreate( max_tokens=max_tokens, messages=follow_up_messages, model=full_model_name, **optional_params_without_max_tokens, **kwargs_for_followup, )

But _prepare_followup_kwargs() currently only filters:

_internal_keys = {"litellm_logging_obj"}

Claude Code requests include fields such as context_management and output_config, and these can exist in both:

  • anthropic_messages_optional_request_params
  • kwargs

So the follow-up call receives duplicate kwargs and crashes.

Fix Action

Fix / Workaround

  1. got multiple values for keyword argument 'context_management'
  2. after locally hotfixing that, the next failure was got multiple values for keyword argument 'output_config'

Minimal local hotfix that worked

After locally hotfixing that duplication, the next failure becomes:

PR fix notes

PR #26166: fix(websearch_interception): dedupe follow-up kwargs against optional params

Description (problem / solution / changelog)

Problem

When using Claude Code through LiteLLM's Anthropic /v1/messages endpoint with websearch_interception enabled, the follow-up Anthropic request crashes with:

TypeError: got multiple values for keyword argument 'context_management'

(and subsequently output_config after hotfixing the first one).

The web search itself succeeds, but the follow-up call fails silently, making web search appear broken to the end user.

Root Cause

In _execute_agentic_loop, anthropic_messages.acreate() receives both:

**optional_params_without_max_tokens,  # contains context_management, output_config
**kwargs_for_followup,                  # also contains context_management, output_config

_prepare_followup_kwargs() only strips litellm_logging_obj and internal _websearch_interception* keys. Claude Code-specific params like context_management and output_config pass through and collide with the same keys from the optional params dict.

Fix

After building kwargs_for_followup, filter out any key already present in optional_params_without_max_tokens to prevent duplicate keyword arguments. This is generic — any future Claude Code params will also be handled correctly without hardcoding individual field names.

Fixes #26163

Changed files

  • litellm/integrations/websearch_interception/handler.py (modified, +10/-0)

Code Example

litellm_settings:
  master_key: os.environ/LITELLM_MASTER_KEY
  callbacks:
    - websearch_interception
  websearch_interception_params:
    enabled_providers:
      - anthropic
    search_tool_name: searxng-local

search_tools:
  - search_tool_name: searxng-local
    litellm_params:
      search_provider: searxng

---

_internal_keys = {
    "litellm_logging_obj",
    "context_management",
    "output_config",
}

---

kwargs_for_followup = {
    k: v for k, v in kwargs.items()
    if k not in anthropic_messages_optional_request_params
    and ...
}

---

## Actual behavior

LiteLLM detects `litellm_web_search`, executes the search successfully, then fails during the follow-up request.

Observed log sequence:


WebSearchInterception: Search completed for 'latest developments ongoing event 2025 2026', got 7257 chars
WebSearchInterception: Making follow-up request with search results
TypeError: litellm.anthropic_interface.messages.acreate() got multiple values for keyword argument 'context_management'


After locally hotfixing that duplication, the next failure becomes:


TypeError: litellm.anthropic_interface.messages.acreate() got multiple values for keyword argument 'output_config'


Claude Code then falls back to saying web search is unavailable.

## Expected behavior

LiteLLM should complete the full agentic loop:

1. intercept native web search
2. execute configured search provider
3. make Anthropic follow-up request with search results
4. return final answer to Claude Code

No duplicate keyword arguments should be passed to `anthropic_messages.acreate()`.

## Root cause

In `litellm/integrations/websearch_interception/handler.py`, `_execute_agentic_loop()` builds the follow-up call like this:


final_response = await anthropic_messages.acreate(
    max_tokens=max_tokens,
    messages=follow_up_messages,
    model=full_model_name,
    **optional_params_without_max_tokens,
    **kwargs_for_followup,
)


But `_prepare_followup_kwargs()` currently only filters:


_internal_keys = {"litellm_logging_obj"}


Claude Code requests include fields such as `context_management` and `output_config`, and these can exist in both:

- `anthropic_messages_optional_request_params`
- `kwargs`

So the follow-up call receives duplicate kwargs and crashes.
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?

When using Claude Code through LiteLLM's Anthropic /v1/messages endpoint with websearch_interception enabled, the initial web search interception works, the search provider is called successfully, but the follow-up Anthropic request crashes inside LiteLLM because duplicate keyword arguments are passed to anthropic_messages.acreate().

In my case, the search itself completed successfully, but the agentic follow-up failed with:

  1. got multiple values for keyword argument 'context_management'
  2. after locally hotfixing that, the next failure was got multiple values for keyword argument 'output_config'

As a result, Claude Code sees web search as unavailable / unusable even though LiteLLM did perform the search.

Environment

  • LiteLLM: v1.83.9-nightly
  • Release commit: 850fe59
  • Claude Code: 2.1.116
  • Endpoint used by Claude Code: LiteLLM unified Anthropic endpoint /v1/messages
  • Search provider: SearXNG
  • Upstream model provider: Anthropic-compatible third-party endpoint
  • Reproduced on: April 21, 2026

Relevant config

litellm_settings:
  master_key: os.environ/LITELLM_MASTER_KEY
  callbacks:
    - websearch_interception
  websearch_interception_params:
    enabled_providers:
      - anthropic
    search_tool_name: searxng-local

search_tools:
  - search_tool_name: searxng-local
    litellm_params:
      search_provider: searxng

The request payload from Claude Code includes fields like:

  • context_management
  • output_config
  • thinking
  • stream

Minimal local hotfix that worked

I mounted an override and changed _prepare_followup_kwargs() to exclude duplicate Claude Code params:

_internal_keys = {
    "litellm_logging_obj",
    "context_management",
    "output_config",
}

This fixed the first two crashes I hit. It suggests the real fix should probably be more generic than just hardcoding individual field names.

Suggested fix

Instead of only excluding litellm_logging_obj, filter out any key already present in anthropic_messages_optional_request_params before expanding kwargs_for_followup, i.e. dedupe follow-up kwargs against the explicit optional params dict.

Something conceptually like:

kwargs_for_followup = {
    k: v for k, v in kwargs.items()
    if k not in anthropic_messages_optional_request_params
    and ...
}

This would prevent future duplicates for other Claude Code-specific fields as well.

Why this matters

This breaks the exact scenario documented by LiteLLM for Claude Code web search interception:

  • Claude Code uses /v1/messages
  • LiteLLM intercepts web search
  • search provider works
  • but final answer never returns because the follow-up request crashes internally

So web search appears broken to the end user even though the search itself succeeded.

Steps to Reproduce

  1. Start LiteLLM v1.83.9-nightly
  2. Configure Claude Code to use LiteLLM unified endpoint:
    • ANTHROPIC_BASE_URL=http://<litellm-host>:4000
  3. Enable websearch_interception for anthropic
  4. Configure a working search tool, for example SearXNG
  5. Ask Claude Code a question that triggers web search, for example:
    • What are the latest developments in this ongoing event?

Relevant log output

## Actual behavior

LiteLLM detects `litellm_web_search`, executes the search successfully, then fails during the follow-up request.

Observed log sequence:


WebSearchInterception: Search completed for 'latest developments ongoing event 2025 2026', got 7257 chars
WebSearchInterception: Making follow-up request with search results
TypeError: litellm.anthropic_interface.messages.acreate() got multiple values for keyword argument 'context_management'


After locally hotfixing that duplication, the next failure becomes:


TypeError: litellm.anthropic_interface.messages.acreate() got multiple values for keyword argument 'output_config'


Claude Code then falls back to saying web search is unavailable.

## Expected behavior

LiteLLM should complete the full agentic loop:

1. intercept native web search
2. execute configured search provider
3. make Anthropic follow-up request with search results
4. return final answer to Claude Code

No duplicate keyword arguments should be passed to `anthropic_messages.acreate()`.

## Root cause

In `litellm/integrations/websearch_interception/handler.py`, `_execute_agentic_loop()` builds the follow-up call like this:


final_response = await anthropic_messages.acreate(
    max_tokens=max_tokens,
    messages=follow_up_messages,
    model=full_model_name,
    **optional_params_without_max_tokens,
    **kwargs_for_followup,
)


But `_prepare_followup_kwargs()` currently only filters:


_internal_keys = {"litellm_logging_obj"}


Claude Code requests include fields such as `context_management` and `output_config`, and these can exist in both:

- `anthropic_messages_optional_request_params`
- `kwargs`

So the follow-up call receives duplicate kwargs and crashes.

What part of LiteLLM is this about?

Proxy

What LiteLLM version are you on ?

v1.83.9-nightly

Twitter / LinkedIn details

No response

extent analysis

TL;DR

Filter out duplicate keyword arguments in _prepare_followup_kwargs() by checking against anthropic_messages_optional_request_params to prevent crashes in the Anthropic follow-up request.

Guidance

  • Identify the source of duplicate keyword arguments in the follow-up request, specifically context_management and output_config, which are present in both anthropic_messages_optional_request_params and kwargs.
  • Modify _prepare_followup_kwargs() to exclude any key already present in anthropic_messages_optional_request_params before expanding kwargs_for_followup.
  • Use a dictionary comprehension to filter out duplicate kwargs, such as: kwargs_for_followup = {k: v for k, v in kwargs.items() if k not in anthropic_messages_optional_request_params}.
  • Verify that the modified _prepare_followup_kwargs() function correctly filters out duplicate keyword arguments and prevents crashes in the Anthropic follow-up request.

Example

kwargs_for_followup = {
    k: v for k, v in kwargs.items()
    if k not in anthropic_messages_optional_request_params
}

Notes

  • The provided local hotfix suggests that filtering out duplicate keyword arguments can resolve the issue, but a more generic solution is needed to prevent future crashes.
  • The anthropic_messages_optional_request_params dictionary should be consulted to determine which keyword arguments are optional and can be safely excluded from the follow-up request.

Recommendation

Apply the suggested fix by modifying _prepare_followup_kwargs() to filter out duplicate keyword arguments against anthropic_messages_optional_request_params, as this will prevent crashes in the Anthropic follow-up request and ensure the correct functioning of the web search interception feature.

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…

FAQ

Expected behavior

LiteLLM should complete the full agentic loop:

  1. intercept native web search
  2. execute configured search provider
  3. make Anthropic follow-up request with search results
  4. return final answer to Claude Code

No duplicate keyword arguments should be passed to anthropic_messages.acreate().

Still need to ship something?

×6

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

Back to top recommendations

TRENDING

litellm - ✅(Solved) Fix [Bug]: `websearch_interception` Anthropic follow-up call passes duplicate Claude Code params (`context_management`, `output_config`) and breaks server-side web search [1 pull requests, 1 participants]