Repository navigation
Conversation
…input window moonshotai.kimi-k2.5, qwen.qwen3-coder-next, qwen.qwen3-next-80b-a3b and nvidia.nemotron-nano-3-30b said 256000 while their bedrock/ and regional rows and Bedrock itself allow 262144, so router pre-call checks refused prompts Bedrock accepts. Adds a test that a bare Bedrock row is never narrower than its bedrock/ rows.
[Medium impact] The PR changes prompt limits and overflow handling for Bedrock model requests. The PR still needs the older-proxy rollout issue addressed and the recovery fix from main included before merging FindingsSummaryThis PR widens ten Bedrock input limits in both cost maps and maps more overflow errors to The latest change keeps Mantle's original overflow details while adding “prompt is too long”. It also shares the prefix helper with the Bedrock path and adds a test assertion for the preserved token count No new findings were accepted in this review
Reviews (8) · Last reviewed commit: "fix(bedrock): keep the Mantle model's ov..." · Reviewed by Greptile |
Merging this PR will not alter performance1 warning
Comparing |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…owExceededError and raise three same-model rows to 262144
… on a served model's Mantle overflow Mantle's Qwen3 235B, Qwen3 Coder 30B and Qwen3 32B rows were narrower than their Converse rows, and Mantle took the longer prompts live. A Mantle overflow carrying the served model's own text now gets the same prompt is too long message as Mantle's other overflow shapes, so Claude Code compacts
| "output_cost_per_token_flex": 4.4e-07, | ||
| "litellm_provider": "bedrock_mantle", | ||
| "max_input_tokens": 256000, | ||
| "max_input_tokens": 262144, |
There was a problem hiding this comment.
Older proxies fetch these wider limits from main without receiving the new overflow mapping. Prompts that previously triggered context_window_fallbacks can instead reach Bedrock and return a plain 400, skipping the configured fallback
The repository requires resurfacing this caveat rather than treating its inclusion in the description as approval. Stage the remote-map rollout so older installations keep their fallback behavior
Rule Used: What: do not treat the caveats mentioned in the PR description as acceptable tradeoffs that some human has read and signed off on. Why: almost every time, the PR description is AI-generated, and in fact, many times, the PR description is very long. ... (source)
Bedrock and Mantle overflow errors that map to ContextWindowExceededError now carry "prompt is too long" once, so Claude Code reads them as an overflow and compacts instead of showing a raw API error
| or "prompt is too long" in error_str | ||
| or "prompt: length: 1.." in error_str | ||
| or "Too many input tokens" in error_str | ||
| or ExceptionCheckers.is_error_str_context_window_exceeded(error_str) |
There was a problem hiding this comment.
Overflow skips working deployments
If a group relies on order-based or weighted failover, these newly mapped ContextWindowExceededError errors skip both paths. Requests can fail instead of reaching a working deployment. Repository rules require resurfacing this caveat. Preserve recovery or move affected deployments into context_window_fallbacks
Rule Used: What: do not treat the caveats mentioned in the PR description as acceptable tradeoffs that some human has read and signed off on. Why: almost every time, the PR description is AI-generated, and in fact, many times, the PR description is very long. ... (source)
Knowledge Base Used: Fallbacks, retries, and failure handling
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
Main's #49779 keeps order and weighted failover when the group has no context_window_fallbacks entry. Merged with main, a live Bedrock order group answered 200
|
Squash merge applies this branch onto current main, which already has #49779. Merged with main, the live Bedrock order group failed over and answered 200 |
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 71943a7. Configure here.
|
Closed to free an open-PR slot. Branch kept. Reopen with |
Ten Bedrock cost map rows for eight models said 256,000 or 32,000 tokens, while Bedrock serves 262,144 or 32,768, so a proxy with pre-call checks refused prompts Bedrock takes
This widens the rows in both cost maps and turns Bedrock's overflow 400 into a context window error that says "prompt is too long", so fallbacks and Claude Code still handle it. It has one severe caveat, for older releases
/stupid: What the PR adds
/stupid: What breaks
Original
TLDR
Problem this solves:
How it solves it:
User Flow
Before: a long prompt to Kimi K2.5 on Bedrock gets a 400 from the proxy, though Bedrock takes it
bedrock/converse/moonshotai.kimi-k2.5withenable_pre_call_checks: truemax_tokens(or /v1/messages and /v1/responses)ContextWindowExceededError ... Max Input Tokens=256000, Got=257620and never calls Bedrockmax_input_tokens: 256000After: the same request reaches Bedrock and comes back with an answer
bedrock/converse/moonshotai.kimi-k2.5withenable_pre_call_checks: truemax_tokens(or /v1/messages and /v1/responses)usagemax_input_tokens: 262144Relevant issues
Follow-up to #46197, from a customer report (Pylon #10062)
Affected release
Regression in v1.103.7's bundled map, and on the default remote cost map since the Sep 21 Bedrock price sync (#42254 and #42279)
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
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 moreDecisions
bedrock/rowsbedrock/rows say 262144max_tokensandmax_output_tokensstay as they are, since nothing here showed them wrongmoonshot.kimi-k2-thinkingtomoonshotai.kimi-k2-thinkingorbedrock_mantle/qwen.qwen3-32btoqwen.qwen3-32b-v1:0context_window_fallbacksvalidation_error, in a 400 or in a streamed error eventfallbackswhen nocontext_window_fallbacksis set. A plain 400 already did under the defaultfallback_on_unsupported_params, so only proxies that turned it off see new fallbacksmax_tokens, since Bedrock counts the requested output inside the windowmax_tokensgets Bedrock's 400 after a round trip, then falls back where setmax_tokensin that router-wide check is out of scope heremax_input_tokens. Nothing breaks, but the override reaches same-model deployments, as on maincontext_window_fallbacksentrycontext_window_fallbacksentry sends overflow there instead of to the lower order, as fix(router)!: scope context fallback precedence to the requested group #49779 does for every providerScreenshots / Proof of Fix
Last updated: 71943a7. QA ran on 5fc4f7f (rows 1 to 5), 6777e82 (rows 6 to 8), and 71943a7 (rows 9 to 13). Changes since 6777e82: overflow errors now start with "prompt is too long". Proof remains valid because rows 1 to 8 never hit that error or hit it before an unchanged fallback. Verification: the exception mapping unit tests and rows 9 to 13
Each leg is a 2-worker proxy on real Bedrock in us-east-1, only the commit changing, with prompts of about 257k tokens and
max_tokens16, overflow rows on Converse and MantleRegression history
Qwen3 Next's 400 before the regression comes from its row saying 128000 back then
Setup, with the config, the prompts, and the proxy start, is in this gist
Before (bad98c4)
Kimi K2.5 on /v1/chat/completions
The other cases
Kimi K2.5 on /v1/messages
Steps
Kimi K2.5 on /v1/responses
Steps
Qwen3 Coder Next, Qwen3 Next, and Nemotron Nano 3 on /v1/chat/completions
Steps
Kimi K2 Thinking on Converse and Mantle
Steps
Five rows with the longer English prompt
Steps
Qwen3 Coder Next over its window, without and with a fallback
Steps
Qwen3 235B, Qwen3 Coder 30B, and Qwen3 32B on Mantle
Steps
Kimi K2.5 streamed on /v1/chat/completions
Steps
Qwen3 Coder Next over its window, streamed, with a fallback
Steps
Qwen3 Next on Mantle over its window on /v1/messages, no fallback
Steps
Over the window with pre-call checks off, Converse and Mantle, without and with a fallback
Steps
Claude Code on Qwen3 32B, Converse and Mantle
Steps
On Converse, start Claude Code with
--model qwen3-32b-converse, paste the text, and press Enter. The pane ends withOn Mantle, start Claude Code with
--model qwen3-32b-mantle, paste the text, and press Enter. The pane ends withGET /model/info
Steps
After (5fc4f7f)
Kimi K2.5 on /v1/chat/completions
The other cases
Kimi K2.5 on /v1/messages
Steps
Kimi K2.5 on /v1/responses
Steps
Qwen3 Coder Next, Qwen3 Next, and Nemotron Nano 3 on /v1/chat/completions
Steps
Kimi K2 Thinking on Converse and Mantle
Steps
Five rows with the longer English prompt
Steps
Qwen3 Coder Next over its window with a fallback, pre-call checks on
Steps
GET /model/info
Steps
After (6777e82)
The three new cases
Qwen3 235B, Qwen3 Coder 30B, and Qwen3 32B on Mantle
Steps
Kimi K2.5 streamed on /v1/chat/completions
Steps
Qwen3 Coder Next over its window, streamed, with a fallback
Steps
After (71943a7)
The overflow cases and the fallback timing
Over the window with pre-call checks on, Converse and Mantle
Steps
Over the window with pre-call checks off, Converse and Mantle, without and with a fallback
Steps
Fallback time with pre-call checks on, Converse and Mantle, three runs each
Steps
Claude Code on Qwen3 32B, Converse and Mantle
Steps
On Converse, start Claude Code with
--model qwen3-32b-converse, paste the text, and press Enter. The pane ends withOn Mantle, start Claude Code with
--model qwen3-32b-mantle, paste the text, and press Enter. The pane ends withType
🐛 Bug Fix
Caveats (if any)
Severe
context_window_fallbackslose them for these models at mergefallbacksstill run. Upgrading orLITELLM_LOCAL_MODEL_COST_MAP=Trueavoids it (Decision 10)Medium
context_window_fallbacks, about 1 s more on Converse (Decision 6)Low
context_window_fallbacksentry goes there first (Decision 11)max_input_tokensstill reaches same-model deployments, as on mainmax_tokenscan still overflow at Bedrock, then falls back where setFinal Attestation
Bugbot summary
/live-pr-risk at 71943a7 found no break at merge into current main and one older-release break waiting on the severe sign-off, in this report