Repository navigation
fix(test): unbreak the integration-cost and proxy_e2e_anthropic_messages CircleCI jobs on main - #42048
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Backport of #42048 to stable/1.102.x. Cherry-picked from 7966f50 (main). The safeguards backport maps the dangerous-tool-use-2026-09-03 beta for Bedrock, which Claude Opus 4.5 on Bedrock Invoke rejects as an invalid beta flag, so the all-beta-headers Bedrock cases run on Claude Fable 5.1 as they do on main.
Backport of #42048 to stable/1.101.x. Cherry-picked from 7966f50 (main). The safeguards backport maps the dangerous-tool-use-2026-09-03 beta for Bedrock, which Claude Opus 4.5 on Bedrock Invoke rejects as an invalid beta flag, so the all-beta-headers Bedrock cases run on Claude Fable 5.1 as they do on main.
Backport of #42048 to stable/1.100.x. Cherry-picked from 7966f50 (main). The safeguards backport maps the dangerous-tool-use-2026-09-03 beta for Bedrock, which Claude Opus 4.5 on Bedrock Invoke rejects as an invalid beta flag, so the all-beta-headers Bedrock cases run on Claude Fable 5.1 as they do on main.
Backport of #42048 to stable/1.99.x. Cherry-picked from 7966f50 (main). The safeguards backport maps the dangerous-tool-use-2026-09-03 beta for Bedrock, which Claude Opus 4.5 on Bedrock Invoke rejects as an invalid beta flag, so the all-beta-headers Bedrock cases run on Claude Fable 5.1 as they do on main.
TLDR
Problem this solves:
integration-costhas been red on main since 1b305cd landedproxy_e2e_anthropic_messages_testshas been red on main since c19a199 landedHow it solves it:
User Flow
Before: a maintainer looks at any main pipeline in CircleCI and both jobs are red for reasons unrelated to their change
integration-costfails withx-litellm-response-cost 0.0012456 != expected 0.0021672on thedeepseek-v4p1-flash-fallback_cache_read_at_input_ratecaseproxy_e2e_anthropic_messages_testsfails on bothtest_bedrock_invoke_messages_with_all_beta_headerscases with Bedrock 400invalid beta flagAfter: the same two jobs are green on main, so a red job means something real
integration-costpasses: the renamedfallback_cache_read_at_half_input_ratecase expects 0.0012456proxy_e2e_anthropic_messages_testspasses: the two Bedrock cases hit Fable 5.1 with the full mapped beta list and get 200Relevant issues
Root causes:
cache_read_input_token_cost. The case added in test(integration): literal request/response cost tracking suite on a test-owned cost map #41328 still pinned cached tokens at the full input rate. The actual value in CI, 0.0012456, is exactly640 * 1.5e-7 + 12288 * 7.5e-8 + 380 * 6e-7. test(integration): endpoint, breakdown component and failure support in the cost harness #41999 carries the same repin inside a much larger change; this PR lands just the repin so main goes green now, and test(integration): endpoint, breakdown component and failure support in the cost harness #41999 can drop that hunk on rebasethinking-binding-controls-2026-08-01forbedrockandbedrock_converse. That mapping is correct, Fable 5.1 needs it. Verified live against Bedrock us-east-1 today: the flag is rejected withinvalid beta flagon Opus 4.5, Sonnet 4.5 and Sonnet 4.6, and accepted on Opus 4.7 and Fable 5.1, on both the invoke and converse paths. The test asserts "every mapped beta works on the model under test", so it has to run on a model where that holds, and the repo rule is to test on the latest model in the family anywayAffected release
Linear ticket
Resolves LIT-8149
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
uv run pytest tests/test_litellm/<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 more@greptileaito re-request a review after pushing changes)Delays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
Setup:
python litellm/proxy/proxy_cli.py --config tests/proxy_e2e_anthropic_messages_tests/test_config.yaml --port 4000withLITELLM_MASTER_KEY=sk-1234and the CI Bedrock credentials for us-east-1. The cost case only runs inside the CircleCI integration harness (scripted upstream plus Postgres and Redis), so its Before is the CircleCI log and its After is the CI run on this PRBefore (f49fd22)
Bedrock invoke, every mapped
bedrockbetacurl -s http://localhost:4000/v1/messages -H 'Authorization: Bearer sk-1234' -H 'Content-Type: application/json' -H 'anthropic-version: 2023-06-01' -H 'anthropic-beta: advanced-tool-use-2025-11-20,compact-2026-01-12,computer-use-2025-01-24,computer-use-2025-11-24,context-1m-2025-08-07,context-management-2025-06-27,effort-2025-11-24,fine-grained-tool-streaming-2025-05-14,thinking-binding-controls-2026-08-01,tool-search-tool-2025-10-19' -d '{"model":"bedrock-claude-opus-4.5","max_tokens":10,"messages":[{"role":"user","content":"Say hello"}]}'400 {"type":"error","error":{"type":"invalid_request_error","message":"litellm.BadRequestError: BedrockException - {\"message\":\"invalid beta flag\"}. Received Model Group=bedrock-claude-opus-4.5 ..."}}anthropic-beta: thinking-binding-controls-2026-08-01also returns 400; each of the other nine flags alone returns 200Bedrock converse, every mapped
bedrock_conversebetaanthropic-beta: computer-use-2025-01-24,computer-use-2025-11-24,context-1m-2025-08-07,effort-2025-11-24,fine-grained-tool-streaming-2025-05-14,structured-outputs-2025-11-13,thinking-binding-controls-2026-08-01and"model":"bedrock-converse-claude-sonnet-4.5"400 ... BedrockException - {\"message\":\"The model returned the following errors: invalid beta flag\"}Fireworks fallback cache-read cost (CircleCI job 2191123 on main)
pytest tests/integration/cost_calculation/test_cost_tracking.pyvia.circleci/scripts/run_integration.sh costAssertionError: fireworks_ai-accounts-fireworks-models-deepseek-v4p1-flash-fallback_cache_read_at_input_rate: x-litellm-response-cost 0.0012456 != expected 0.0021672After (7966f50)
Bedrock invoke, every mapped
bedrockbetacurl -s http://localhost:4000/v1/messages -H 'Authorization: Bearer sk-1234' -H 'Content-Type: application/json' -H 'anthropic-version: 2023-06-01' -H 'anthropic-beta: advanced-tool-use-2025-11-20,compact-2026-01-12,computer-use-2025-01-24,computer-use-2025-11-24,context-1m-2025-08-07,context-management-2025-06-27,effort-2025-11-24,fine-grained-tool-streaming-2025-05-14,thinking-binding-controls-2026-08-01,tool-search-tool-2025-10-19' -d '{"model":"bedrock-claude-fable-5.1","max_tokens":10,"messages":[{"role":"user","content":"Say hello and nothing else"}]}'200 {"model":"bedrock-claude-fable-5.1","id":"msg_bdrk_rgklbehc2r5cuzdiphgzpxlhrp2di5zidgqqimaouki7yhki5qia","type":"message","role":"assistant","content":[{"type":"text","text":"Hello"}],"stop_reason":"end_turn","usage":{"input_tokens":17,"output_tokens":5, ...}}Bedrock converse, every mapped
bedrock_conversebetacurl -s http://localhost:4000/v1/messages -H 'Authorization: Bearer sk-1234' -H 'Content-Type: application/json' -H 'anthropic-version: 2023-06-01' -H 'anthropic-beta: computer-use-2025-01-24,computer-use-2025-11-24,context-1m-2025-08-07,effort-2025-11-24,fine-grained-tool-streaming-2025-05-14,structured-outputs-2025-11-13,thinking-binding-controls-2026-08-01' -d '{"model":"bedrock-converse-claude-fable-5.1","max_tokens":10,"messages":[{"role":"user","content":"Say hello and nothing else"}]}'200 {"id":"chatcmpl-4b275756-c40b-4161-b092-9cd53b129717","type":"message","role":"assistant","model":"bedrock-converse-claude-fable-5.1","usage":{"input_tokens":17,"output_tokens":5},"content":[{"type":"text","text":"Hello"}],"stop_reason":"end_turn"}pytest tests/proxy_e2e_anthropic_messages_tests/test_all_beta_headers.py -k bedrock: both cases PASSED against the live proxyFireworks fallback cache-read cost
data_errors()on the edited fixture returns empty, so the renamed case and its contracts.json entry are consistentintegration-costjob on this PR is the live run; see the checks tabType
✅ Test
Caveats (if any)
Low
Link to Devin session: https://app.devin.ai/sessions/fa3712a4b31d4d26a1877f606396ebc9
Open in Devin Desktop: https://app.devin.ai/desktop/session/fa3712a4b31d4d26a1877f606396ebc9?variant=devin