chore(tests): source live Bedrock Anthropic model from env var - #26722
chore(tests): source live Bedrock Anthropic model from env var#26722ryan-crabbe-berri wants to merge 2 commits into
Conversation
Greptile SummaryThis PR centralizes Bedrock Anthropic model IDs used by live tests behind three env vars ( Confidence Score: 5/5Safe to merge once the three CircleCI env vars are configured as described in the PR. Changes are limited to two test files; no production code is touched. All previously raised concerns (collection-time KeyError, missing CircleCI config block) were acknowledged as intentional by the author. No new P0/P1 issues are present. No files require special attention beyond verifying that all three CircleCI env vars are set before merging.
|
| Filename | Overview |
|---|---|
| tests/local_testing/test_function_calling.py | Replaces hardcoded Bedrock model string in @pytest.mark.parametrize with os.environ["BEDROCK_ANTHROPIC_MODEL"]; env-var is evaluated at collection time (intentional loud failure per author). |
| tests/pass_through_unit_tests/test_anthropic_messages_prompt_caching.py | Replaces two hardcoded model strings in get_model() methods with os.environ["BEDROCK_ANTHROPIC_CONVERSE_MODEL"] and os.environ["BEDROCK_ANTHROPIC_INVOKE_MODEL"]; evaluated lazily at test-run time (not collection time), so no collection-error risk here. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[CircleCI env vars\nBEDROCK_ANTHROPIC_MODEL\nBEDROCK_ANTHROPIC_CONVERSE_MODEL\nBEDROCK_ANTHROPIC_INVOKE_MODEL] --> B{pytest collection}
B -->|BEDROCK_ANTHROPIC_MODEL missing| C[KeyError — collection aborts\ntest_function_calling.py]
B -->|All vars set| D[test_aaparallel_function_call_with_anthropic_thinking\nparametrize resolves model]
B -->|All vars set| E[TestBedrockConversePromptCaching.get_model\nreturns BEDROCK_ANTHROPIC_CONVERSE_MODEL]
B -->|All vars set| F[TestBedrockInvokePromptCaching.get_model\nreturns BEDROCK_ANTHROPIC_INVOKE_MODEL]
D --> G[Live Bedrock API call]
E --> G
F --> G
Reviews (9): Last reviewed commit: "chore(tests): source bedrock anthropic l..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Replace hardcoded Bedrock Anthropic model IDs in 2 live test files with required env vars set in CircleCI project env vars. Future AWS EOLs of Bedrock Anthropic models become CircleCI UI value bumps — no PR, no multi-file code edit (cf. PR #26721 which had to touch 16 files). Three env vars, one per route prefix, each holding a full copy-pasteable model path: BEDROCK_ANTHROPIC_MODEL → bedrock/<id> (default route) BEDROCK_ANTHROPIC_CONVERSE_MODEL → bedrock/converse/<id> (explicit converse) BEDROCK_ANTHROPIC_INVOKE_MODEL → bedrock/invoke/<id> (explicit invoke) Test code is os.environ[...] with no concatenation. No in-code fallback default — files fail loud at collection (KeyError) if any env var is missing. This avoids the dead-code trap of unused fallbacks (cf. existing precedents BEDROCK_TEST_MODEL, LITELLM_PROXY_RESPONSES_MODEL which silently default forever because their env vars were never set). Scope is limited to live tests only: - tests/local_testing/test_function_calling.py - tests/pass_through_unit_tests/test_anthropic_messages_prompt_caching.py Mocked transformation tests intentionally keep their hardcoded IDs — the model string is opaque there and never reaches AWS. Pre-merge: all 3 env vars must be set in CircleCI UI.
022b5ae to
e10b14a
Compare
…c live-call sites Migrate 8 additional sonnet-routed live test call sites to read the model path from the existing `BEDROCK_ANTHROPIC_MODEL` / `BEDROCK_ANTHROPIC_INVOKE_MODEL` env vars introduced in e10b14a. Future Anthropic-on-Bedrock EOL bumps now take fewer file edits than they did under PR #26721. Sites (4 files): tests/llm_translation/test_bedrock_completion.py 478, 605, 633, 942, 2890 bedrock/<id> → BEDROCK_ANTHROPIC_MODEL tests/local_testing/test_exceptions.py 474 bedrock/<id> → BEDROCK_ANTHROPIC_MODEL tests/local_testing/test_streaming.py 1244 bedrock/<id> → BEDROCK_ANTHROPIC_MODEL tests/pass_through_unit_tests/test_bedrock_tool_use_beta_header.py 27 bedrock/invoke/<id> → BEDROCK_ANTHROPIC_INVOKE_MODEL Route prefix is preserved at every site (no cross-routing). Deliberately not migrated: - haiku-pinned tests (env vars resolve to sonnet) — see test_bedrock_completion.py haiku sites and tests/local_testing/test_timeout.py:79 - test_bedrock_govcloud.py — uses completion_cost(), pure utility, never hits AWS - test_bedrock_completion.py:2038 (_transform_request), 2526 (decoder), 664 (@pytest.mark.skip) - test_bedrock_completion.py:3145, 3152, 3247, 3300, 3352 — passthrough tests with hardcoded `endpoint=` alongside `model=`; would need a 4th env var or string-derivation - test_bedrock_anthropic_messages_test.py and test_websearch_interception_e2e.py — multi-site router-config refactors; deferred - all tests/test_litellm/* — strict unit / mocked transformation tests; the hardcoded model string never reaches AWS so EOLs don't break them
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
Summary
tests/local_testing/test_function_calling.py::test_aaparallel_function_call_with_anthropic_thinking(Bedrock parametrize entry)tests/pass_through_unit_tests/test_anthropic_messages_prompt_caching.py(TestBedrockConversePromptCachingandTestBedrockInvokePromptCaching)KeyErrorif any env var is missing. Avoids the dead-code trap of an unused fallback (see existing precedentsBEDROCK_TEST_MODEL,LITELLM_PROXY_RESPONSES_MODELwhich silently default forever).Required before merge
Add the following 3 env vars to https://app.circleci.com/settings/project/github/BerriAI/litellm/environment-variables. Without all 3, CI will fail at collection.
BEDROCK_ANTHROPIC_MODELbedrock/us.anthropic.claude-sonnet-4-5-20250929-v1:0BEDROCK_ANTHROPIC_CONVERSE_MODELbedrock/converse/us.anthropic.claude-sonnet-4-5-20250929-v1:0BEDROCK_ANTHROPIC_INVOKE_MODELbedrock/invoke/us.anthropic.claude-sonnet-4-5-20250929-v1:0Local dev requires
exporting all 3 (or setting via.envrc/.env).Test plan
KeyErrorat collection (loud failure). With all 3 set → parametrize ID andget_model()resolve to the override values.How to bump after future EOLs
Edit the 3 CircleCI UI values (all visible together alphabetically). No code change, no PR. If you forget one, CI surfaces the EOL 404 from the un-bumped one — self-correcting.