litellm - 💡(How to fix) Fix [Bug]: /v1/messages passthrough to Bedrock InvokeModel fails with "context_management: Extra inputs are not permitted" — missing compact-2026-01-12 beta header injection [1 pull requests]

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…

Error Message

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

Root Cause

The root cause: LiteLLM's /v1/messages endpoint passes context_management through to Bedrock InvokeModel, but does not inject the required compact-2026-01-12 beta header into the request body's anthropic_beta array.

Fix Action

Fixed

Code Example

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

---

# config.yaml
model_list:
  - model_name: claude-sonnet-4-6
    litellm_params:
      model: bedrock/global.anthropic.claude-sonnet-4-6
      api_key: <BEDROCK_API_KEY>

general_settings:
  master_key: "sk-1234"

environment_variables:
  AWS_REGION_NAME: "us-west-2"

---

curl --location 'http://0.0.0.0:4000/v1/messages' \
  --header 'x-api-key: sk-1234' \
  --header 'content-type: application/json' \
  --data '{
    "model": "claude-sonnet-4-6",
    "max_tokens": 4096,
    "messages": [{"role": "user", "content": "Hi"}],
    "context_management": {
      "edits": [{"type": "compact_20260112"}]
    }
  }'

---

{"error":{"message":"{\"message\":\"context_management: Extra inputs are not permitted\"}"}}

---

# Add after the mcp_server_used check:
if optional_params and optional_params.get("context_management"):
    betas.append("compact-2026-01-12")

---

# With anthropic_beta + context_management → SUCCESS
body = {
    "anthropic_version": "bedrock-2023-05-31",
    "anthropic_beta": ["compact-2026-01-12"],
    "max_tokens": 64,
    "messages": [{"role": "user", "content": "Hi"}],
    "context_management": {
        "edits": [{"type": "compact_20260112", "trigger": {"type": "input_tokens", "value": 100000}}]
    }
}
# → 200 OK, works perfectly

# Without anthropic_beta → FAILS
body = {
    "anthropic_version": "bedrock-2023-05-31",
    "max_tokens": 64,
    "messages": [{"role": "user", "content": "Hi"}],
    "context_management": {
        "edits": [{"type": "compact_20260112", "trigger": {"type": "input_tokens", "value": 100000}}]
    }
}
# → 400 "context_management: Extra inputs are not permitted"

---

{"message":"context_management: Extra inputs are not permitted"}
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 via LiteLLM proxy with Bedrock InvokeModel (bedrock/ prefix), requests containing context_management (compaction) fail with:

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

The root cause: LiteLLM's /v1/messages endpoint passes context_management through to Bedrock InvokeModel, but does not inject the required compact-2026-01-12 beta header into the request body's anthropic_beta array.

Bedrock InvokeModel requires "anthropic_beta": ["compact-2026-01-12"] in the request body when context_management is present. Without it, Bedrock rejects the request.

Key findings

  1. Bedrock InvokeModel does support compaction — verified by direct HTTP call with Authorization: Bearer API key
  2. The anthropic_beta_headers_config.json already has "compact-2026-01-12": "compact-2026-01-12" for the bedrock provider
  3. However, get_anthropic_beta_list() in litellm/llms/anthropic/common_utils.py does NOT detect context_management and does NOT auto-inject compact-2026-01-12
  4. drop_params: true and extra_body do NOT help on the /v1/messages passthrough path
  5. LiteLLM docs incorrectly state compaction is "not supported on Bedrock (Invoke or Converse APIs)" — InvokeModel does support it, only Converse does not

Steps to Reproduce

# config.yaml
model_list:
  - model_name: claude-sonnet-4-6
    litellm_params:
      model: bedrock/global.anthropic.claude-sonnet-4-6
      api_key: <BEDROCK_API_KEY>

general_settings:
  master_key: "sk-1234"

environment_variables:
  AWS_REGION_NAME: "us-west-2"
curl --location 'http://0.0.0.0:4000/v1/messages' \
  --header 'x-api-key: sk-1234' \
  --header 'content-type: application/json' \
  --data '{
    "model": "claude-sonnet-4-6",
    "max_tokens": 4096,
    "messages": [{"role": "user", "content": "Hi"}],
    "context_management": {
      "edits": [{"type": "compact_20260112"}]
    }
  }'

Result:

{"error":{"message":"{\"message\":\"context_management: Extra inputs are not permitted\"}"}}

Expected behavior

LiteLLM should detect context_management in the request body and automatically inject "compact-2026-01-12" into the anthropic_beta array before forwarding to Bedrock InvokeModel, similar to how it auto-injects other beta headers (effort, computer-use, etc.).

Suggested fix

In litellm/llms/anthropic/common_utils.py, get_anthropic_beta_list():

# Add after the mcp_server_used check:
if optional_params and optional_params.get("context_management"):
    betas.append("compact-2026-01-12")

Also ensure the /v1/messages passthrough path calls this logic before forwarding to Bedrock.

Proof that Bedrock InvokeModel supports compaction

Direct HTTP call to Bedrock (no LiteLLM):

# With anthropic_beta + context_management → SUCCESS
body = {
    "anthropic_version": "bedrock-2023-05-31",
    "anthropic_beta": ["compact-2026-01-12"],
    "max_tokens": 64,
    "messages": [{"role": "user", "content": "Hi"}],
    "context_management": {
        "edits": [{"type": "compact_20260112", "trigger": {"type": "input_tokens", "value": 100000}}]
    }
}
# → 200 OK, works perfectly

# Without anthropic_beta → FAILS
body = {
    "anthropic_version": "bedrock-2023-05-31",
    "max_tokens": 64,
    "messages": [{"role": "user", "content": "Hi"}],
    "context_management": {
        "edits": [{"type": "compact_20260112", "trigger": {"type": "input_tokens", "value": 100000}}]
    }
}
# → 400 "context_management: Extra inputs are not permitted"

Additional context

  • This affects all Claude Code users connecting through LiteLLM to Bedrock
  • AWS docs confirm: "Compaction is currently not supported by the Converse API, however it is supported with InvokeModel"
  • LiteLLM docs page on compaction should be updated to reflect InvokeModel support

Relevant log output

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

What part of LiteLLM is this about?

Proxy

What LiteLLM version are you on ?

v1.83.10

Twitter / LinkedIn details

No response

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 detect context_management in the request body and automatically inject "compact-2026-01-12" into the anthropic_beta array before forwarding to Bedrock InvokeModel, similar to how it auto-injects other beta headers (effort, computer-use, etc.).

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 - 💡(How to fix) Fix [Bug]: /v1/messages passthrough to Bedrock InvokeModel fails with "context_management: Extra inputs are not permitted" — missing compact-2026-01-12 beta header injection [1 pull requests]