litellm - ✅(Solved) Fix additional_drop_params ignored for POST /v1/messages — Anthropic pass-through handler forwards unsupported fields to Bedrock [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#25931Fetched 2026-04-17 08:28:05
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
0
Author
Participants
Timeline (top)
labeled ×2subscribed ×1

Claude Code v2.1+ enables the context-management-2025-06-27 Anthropic beta, which adds a context_management field to Messages API request bodies. This field is valid against Anthropic's direct API but is rejected by Bedrock with "context_management: Extra inputs are not permitted".

Setting additional_drop_params: ["context_management"] in litellm_settings or in a model's litellm_params has no effect on this code path — the field is forwarded to Bedrock and the 400 is returned to the client.


Error Message

API Error: 400 {"error":{"message":"{"message":"context_management: Extra inputs are not permitted"} . Received Model Group=us.anthropic.claude-sonnet-4-6\nAvailable Model Group Fallbacks=None"}}

Root Cause

POST /v1/messages routes through experimental_pass_through/messages/handler.pyasync_anthropic_messages_handler. This code path never consults drop_params or additional_drop_params. It passes request_body directly to sign_request(), which serialises and AWS-signs the body including the offending field. The drop_params logic only runs in the /v1/chat/completions path.


Fix Action

Workaround

Insert before the sign_request() call in async_anthropic_messages_handler (llm_http_handler.py):

# Strip Anthropic-only fields Bedrock rejects — additional_drop_params
# is not consulted in this code path.
for _f in ("context_management",):
    request_body.pop(_f, None)

PR fix notes

PR #25963: fix(proxy): ensure additional_drop_params are respected in Anthropic pass-through endpoints

Description (problem / solution / changelog)

Relevant issues

Fixes #25931

Pre-Submission checklist

  • I have Added testing in the tests/test_litellm/ directory, Adding at least 1 test is a hard requirement
  • 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

Screenshots / Proof of Fix

Before Fix

AssertionError: assert 'context_management' not in {'context_management': {'enabled': True}, ...}
The proxy was forwarding unsupported Anthropic beta fields to Bedrock even when defined in additional_drop_params.

After Fix

uv run pytest tests/test_litellm/proxy/pass_through_endpoints/test_pass_through_endpoints.py -k test_pass_through_request_does_not_drop_context_management -v
PASSED

Type

  • 🐛 Bug Fix
  • ✅ Test

Changes

  • Updated pass_through_request in litellm/proxy/pass_through_endpoints/pass_through_endpoints.py to strip parameters found in additional_drop_params from the request body.
  • Imported and utilized delete_nested_value and is_nested_path to support both flat and nested parameter removal via dot notation.
  • Added regression test in tests/test_litellm/proxy/pass_through_endpoints/test_pass_through_endpoints.py to verify context_management is correctly dropped.

Changed files

  • litellm/proxy/pass_through_endpoints/pass_through_endpoints.py (modified, +15/-0)
  • tests/test_litellm/proxy/pass_through_endpoints/test_pass_through_endpoints.py (modified, +119/-25)
  • uv.lock (modified, +942/-1168)

Code Example

litellm_settings:
  drop_params: true
  additional_drop_params: ["context_management"]  # no effect on /v1/messages path

model_list:
  - model_name: us.anthropic.claude-sonnet-4-6
    litellm_params:
      model: bedrock/us.anthropic.claude-sonnet-4-6
      drop_params: true
      additional_drop_params: ["context_management"]  # also no effect

---

API Error: 400 {"error":{"message":"{\"message\":\"context_management: Extra inputs are not permitted\"}
. Received Model Group=us.anthropic.claude-sonnet-4-6\nAvailable Model Group Fallbacks=None"}}

---

litellm/proxy/anthropic_endpoints/endpoints.py:53  anthropic_response()
litellm/llms/anthropic/experimental_pass_through/messages/handler.py:286  anthropic_messages()
litellm/llms/custom_httpx/llm_http_handler.py:2025  async_anthropic_messages_handler()
litellm/llms/custom_httpx/llm_http_handler.py:1878  _async_post_anthropic_messages_with_http_error_retry()
litellm/llms/custom_httpx/llm_http_handler.py:1840  async_httpx_client.post()

MaskedHTTPStatusError: 400 Bad Request
  url: https://bedrock-runtime.us-west-2.amazonaws.com/model/us.anthropic.claude-sonnet-4-6/invoke-with-response-stream

BaseLLMException: {"message":"context_management: Extra inputs are not permitted"}

---

# Strip Anthropic-only fields Bedrock rejects — additional_drop_params
# is not consulted in this code path.
for _f in ("context_management",):
    request_body.pop(_f, None)
RAW_BUFFERClick to expand / collapse

Bug: additional_drop_params ignored on POST /v1/messages — Bedrock rejects unsupported fields

Environment

  • LiteLLM version: 1.83.9 (also reproduced on 1.83.3)
  • Python: 3.11 / RHEL 9 / systemd proxy, 4 workers
  • Provider: AWS Bedrock — bedrock/us.anthropic.claude-sonnet-4-6
  • Client: Claude Code v2.1.112
  • Endpoint: POST /v1/messages?beta=true

Summary

Claude Code v2.1+ enables the context-management-2025-06-27 Anthropic beta, which adds a context_management field to Messages API request bodies. This field is valid against Anthropic's direct API but is rejected by Bedrock with "context_management: Extra inputs are not permitted".

Setting additional_drop_params: ["context_management"] in litellm_settings or in a model's litellm_params has no effect on this code path — the field is forwarded to Bedrock and the 400 is returned to the client.


Config attempted (does not fix the issue)

litellm_settings:
  drop_params: true
  additional_drop_params: ["context_management"]  # no effect on /v1/messages path

model_list:
  - model_name: us.anthropic.claude-sonnet-4-6
    litellm_params:
      model: bedrock/us.anthropic.claude-sonnet-4-6
      drop_params: true
      additional_drop_params: ["context_management"]  # also no effect

Error returned to client

API Error: 400 {"error":{"message":"{\"message\":\"context_management: Extra inputs are not permitted\"}
. Received Model Group=us.anthropic.claude-sonnet-4-6\nAvailable Model Group Fallbacks=None"}}

Key traceback frames

litellm/proxy/anthropic_endpoints/endpoints.py:53  anthropic_response()
litellm/llms/anthropic/experimental_pass_through/messages/handler.py:286  anthropic_messages()
litellm/llms/custom_httpx/llm_http_handler.py:2025  async_anthropic_messages_handler()
litellm/llms/custom_httpx/llm_http_handler.py:1878  _async_post_anthropic_messages_with_http_error_retry()
litellm/llms/custom_httpx/llm_http_handler.py:1840  async_httpx_client.post()

MaskedHTTPStatusError: 400 Bad Request
  url: https://bedrock-runtime.us-west-2.amazonaws.com/model/us.anthropic.claude-sonnet-4-6/invoke-with-response-stream

BaseLLMException: {"message":"context_management: Extra inputs are not permitted"}

Root cause

POST /v1/messages routes through experimental_pass_through/messages/handler.pyasync_anthropic_messages_handler. This code path never consults drop_params or additional_drop_params. It passes request_body directly to sign_request(), which serialises and AWS-signs the body including the offending field. The drop_params logic only runs in the /v1/chat/completions path.


Workaround

Insert before the sign_request() call in async_anthropic_messages_handler (llm_http_handler.py):

# Strip Anthropic-only fields Bedrock rejects — additional_drop_params
# is not consulted in this code path.
for _f in ("context_management",):
    request_body.pop(_f, None)

Expected behaviour

additional_drop_params set in litellm_settings or a model's litellm_params should apply to all outbound provider requests regardless of whether they arrived via /v1/chat/completions or /v1/messages.

extent analysis

TL;DR

The most likely fix is to modify the async_anthropic_messages_handler function to strip rejected fields like context_management before signing the request.

Guidance

  • Identify the code path in experimental_pass_through/messages/handler.py that bypasses the drop_params logic and modify it to apply the additional_drop_params filtering.
  • Verify that the request_body is correctly updated before being passed to sign_request() by adding logging or debugging statements.
  • Consider refactoring the code to apply the drop_params logic consistently across all relevant endpoints, including /v1/messages.
  • Test the modified code with different input scenarios to ensure the fix does not introduce new issues.

Example

# Modified async_anthropic_messages_handler function
def async_anthropic_messages_handler(...):
    # ...
    for field in additional_drop_params:
        request_body.pop(field, None)
    # ...
    sign_request(request_body)

Notes

The provided workaround suggests modifying the async_anthropic_messages_handler function to strip the context_management field. However, a more comprehensive solution would involve applying the drop_params logic consistently across all relevant endpoints.

Recommendation

Apply the workaround by modifying the async_anthropic_messages_handler function to strip rejected fields, as it is a targeted fix for the identified issue.

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

litellm - ✅(Solved) Fix additional_drop_params ignored for POST /v1/messages — Anthropic pass-through handler forwards unsupported fields to Bedrock [1 pull requests, 1 participants]