fix(bedrock): honor ttl for tool_config cache injection points - #31929
fix(bedrock): honor ttl for tool_config cache injection points#31929mateo-berri merged 12 commits into
Conversation
Pass cache_control_injection_points control.ttl through to Bedrock toolConfig cachePoint blocks, matching message/system cache behavior. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Shivam Rawat seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
Greptile SummaryThis PR fixes Bedrock Converse
Confidence Score: 5/5Safe to merge. The core transformation logic change is narrow and correct, the pricing JSON edits are verified by tests that assert on specific model entries, and all new tests use local cost maps or monkeypatch to avoid network calls. The tool-config TTL fix routes through the same helper already trusted for message/system cache points. Model-eligibility checks now read from the pricing JSON, which is the established pattern. The only noteworthy item is a TypedDict annotation precision issue with NotRequired that has no runtime impact. No behavioral regressions were found. No files require special attention. The pricing JSON changes are symmetric across the main and backup files, and the models that lost cache_creation_input_token_cost_above_1hr match their regional variants and AWS documentation.
|
| Filename | Overview |
|---|---|
| litellm/llms/bedrock/chat/converse_transformation.py | Extracted shared _build_cache_point_block helper and wired both message/system and tool_config injection paths through it, fixing the TTL drop. Parallel tool use guard now uses bedrock_converse_supports_parallel_tool_use_config instead of is_claude_4_5_on_bedrock. |
| litellm/llms/bedrock/common_utils.py | Replaced the hardcoded Claude-4.5 pattern list in is_claude_4_5_on_bedrock with a lookup against cache_creation_input_token_cost_above_1hr in litellm.model_cost. Added bedrock_converse_supports_parallel_tool_use_config using a separate supports_parallel_tool_use_config flag. |
| litellm/types/integrations/anthropic_cache_control_hook.py | Added control: Optional[ChatCompletionCachedContent] to CacheControlToolConfigInjectionPoint. The field is technically required (TypedDict default total=True) but callers that omit it still work at runtime via .get("control"); NotRequired would be more accurate. |
| litellm/model_prices_and_context_window_backup.json | Removed incorrect cache_creation_input_token_cost_above_1hr from Claude 3.5 Sonnet Bedrock entries; added supports_parallel_tool_use_config: true to haiku-4.5, opus-4.6 variants, opus-4.7 variants, and claude-sonnet-5 entries. |
| model_prices_and_context_window.json | Mirrors backup JSON changes: removes erroneous 1h-TTL pricing from Claude 3.5 Sonnet Bedrock entries and adds supports_parallel_tool_use_config to relevant Claude 4.5+/4.6/4.7 model entries. |
| tests/test_litellm/llms/bedrock/chat/test_converse_transformation.py | Adds regression tests for TTL honoring on tool_config injection points (supported model, regional fallback, unsupported model) and for decoupled parallel tool use vs TTL eligibility. All tests use monkeypatch or LITELLM_LOCAL_MODEL_COST_MAP to avoid network calls. |
| tests/test_litellm/llms/bedrock/test_bedrock_common_utils.py | Adds a regression test confirming that a regional model entry lacking a capability field correctly falls back to the base model entry via the any() pattern. |
Reviews (9): Last reviewed commit: "fix(bedrock): fall back to base model en..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…ot regex is_claude_4_5_on_bedrock hardcoded a model-name pattern list that needed a manual update for every new Claude release (it already silently missed Sonnet 5 and Fable 5). Replace it with a lookup against cache_creation_input_token_cost_above_1hr in model_prices_and_context_window.json, which AWS docs confirm tracks the same 1h-TTL-capable model set. Also fixes two bedrock Claude 3.5 Sonnet entries that incorrectly carried that pricing field (their own regional variants didn't have it), which would have made the JSON-driven check wrongly grant them 1h TTL support. Co-authored-by: Cursor <cursoragent@cursor.com>
|
@greptile review again with new commit that resolves the p2 issue |
…tests test_add_cache_point_tool_block_passes_ttl_for_claude_4_5 and test_bedrock_tools_pt_passes_ttl_for_claude_4_5 used a fabricated model id (...-20250514-v1:0) that never shipped. This passed under the old regex-based is_claude_4_5_on_bedrock, which matched on substring alone, but fails now that it looks up cache_creation_input_token_cost_above_1hr in litellm.model_cost, since the fake id has no pricing entry. Also force the bundled local cost map in both tests so ttl eligibility reads this branch's pricing data instead of the network-fetched main copy, which lacks the fix until merge. Co-authored-by: Cursor <cursoragent@cursor.com>
|
bugbot run |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
Autofix Details
Bugbot Autofix prepared fixes for both issues found in the latest run.
- ✅ Fixed: ToolBlock constructor on Python 3.10
- Replaced the tool-config cachePoint TypedDict keyword constructor with a plain dict append so the path works on Python 3.10.
- ✅ Fixed: Parallel tools use TTL gate
- Separated the Bedrock parallel-tool capability check from the extended-cache TTL pricing predicate and covered unpriced Claude 4.7-style model IDs with a regression test.
You can send follow-ups to the cloud agent here.
|
bugbot run |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Autofix Details
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Parallel tools gate drops Sonnet 5
- The parallel tool-use gate now also accepts Bedrock models that qualify through the pricing JSON, with a regression test for Sonnet 5 request transformation.
You can send follow-ups to the cloud agent here.
|
bugbot run |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Autofix Details
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: TTL gate enables parallel tools
- Removed the extended-cache TTL pricing helper from the parallel-tool capability gate and added a regression covering TTL-only Bedrock models.
You can send follow-ups to the cloud agent here.
…coded patterns Replace the hardcoded _CLAUDE_BEDROCK_PARALLEL_TOOL_USE_PATTERNS tuple and bedrock_converse_supports_strict_tool_schemas (dead code) with a supports_parallel_tool_use_config key in model_prices_and_context_window.json, matching how is_claude_4_5_on_bedrock already reads cache_creation_input_token_cost_above_1hr from the pricing JSON. New models pick up parallel tool use support automatically when their pricing entry ships with the key set, with no code change required Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…itellm_bedrock_cache_control_default
…g test anthropic.claude-opus-4-7-unlisted-v1:0 has no entry in model_prices_and_context_window.json, so bedrock_converse_supports_parallel_tool_use_config returned False and the test died with KeyError on additionalModelRequestFields. Use jp.anthropic.claude-opus-4-7, a real entry that carries supports_parallel_tool_use_config without 1h-TTL cache pricing, which is exactly the decoupling this test exists to cover
|
Generated by Claude Code |
The misc unit test job validates model_prices_and_context_window.json against the INTENDED_SCHEMA allowlist in test_utils.py, which rejects unknown keys. Add the supports_parallel_tool_use_config key this PR introduced so test_aaamodel_prices_and_context_window_json_is_valid passes again
|
Generated by Claude Code |
|
bugbot run Generated by Claude Code |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Autofix Details
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Regional cost map blocks TTL
- Updated the Bedrock TTL eligibility check to fall back to the stripped base model when a regional cost entry lacks 1-hour cache pricing, with JP Opus 4.7 regression coverage.
You can send follow-ups to the cloud agent here.
…ks capability fields Regional model_cost entries like jp.anthropic.claude-opus-4-7 that omit cache_creation_input_token_cost_above_1hr shadowed the base entry that has it, so is_claude_4_5_on_bedrock returned False and requested cache ttl values were dropped for those deployments. Both capability lookups now consult the full model id and the region-stripped base entry, matching the coverage of the old name-pattern list. Also restores ToolBlock keyword construction for the tool_config cachePoint; PEP 589 TypedDict keyword instantiation works on every supported Python version
|
Generated by Claude Code |
….3) (#1400) This PR contains the following updates: | Package | Update | Change | |---|---|---| | [ghcr.io/berriai/litellm](https://images.chainguard.dev/directory/image/wolfi-base/overview) ([source](https://github.com/BerriAI/litellm)) | patch | `v1.90.2` → `v1.90.3` | --- ### Release Notes <details> <summary>BerriAI/litellm (ghcr.io/berriai/litellm)</summary> ### [`v1.90.3`](https://github.com/BerriAI/litellm/releases/tag/v1.90.3) [Compare Source](BerriAI/litellm@v1.90.3...v1.90.3) ##### Verify Docker Image Signature All LiteLLM Docker images are signed with [cosign](https://docs.sigstore.dev/cosign/overview/). Every release is signed with the same key introduced in [commit `0112e53`](BerriAI/litellm@0112e53). **Verify using the pinned commit hash (recommended):** A commit hash is cryptographically immutable, so this is the strongest way to ensure you are using the original signing key: ```bash cosign verify \ --key https://raw.githubusercontent.com/BerriAI/litellm/0112e53046018d726492c814b3644b7d376029d0/cosign.pub \ ghcr.io/berriai/litellm:v1.90.3 ``` **Verify using the release tag (convenience):** Tags are protected in this repository and resolve to the same key. This option is easier to read but relies on tag protection rules: ```bash cosign verify \ --key https://raw.githubusercontent.com/BerriAI/litellm/v1.90.3/cosign.pub \ ghcr.io/berriai/litellm:v1.90.3 ``` Expected output: ``` The following checks were performed on each of these signatures: - The cosign claims were validated - The signatures were verified against the specified public key ``` *** ##### What's Changed - chore(release): backport [#​31923](BerriAI/litellm#31923), [#​31929](BerriAI/litellm#31929), [#​31393](BerriAI/litellm#31393) to stable/1.90.x and cut 1.90.3 by [@​mateo-berri](https://github.com/mateo-berri) in [#​32025](BerriAI/litellm#32025) **Full Changelog**: <BerriAI/litellm@v1.90.2...v1.90.3> ### [`v1.90.3`](https://github.com/BerriAI/litellm/releases/tag/v1.90.3) [Compare Source](BerriAI/litellm@v1.90.2...v1.90.3) ##### Verify Docker Image Signature All LiteLLM Docker images are signed with [cosign](https://docs.sigstore.dev/cosign/overview/). Every release is signed with the same key introduced in [commit `0112e53`](BerriAI/litellm@0112e53). **Verify using the pinned commit hash (recommended):** A commit hash is cryptographically immutable, so this is the strongest way to ensure you are using the original signing key: ```bash cosign verify \ --key https://raw.githubusercontent.com/BerriAI/litellm/0112e53046018d726492c814b3644b7d376029d0/cosign.pub \ ghcr.io/berriai/litellm:v1.90.3 ``` **Verify using the release tag (convenience):** Tags are protected in this repository and resolve to the same key. This option is easier to read but relies on tag protection rules: ```bash cosign verify \ --key https://raw.githubusercontent.com/BerriAI/litellm/v1.90.3/cosign.pub \ ghcr.io/berriai/litellm:v1.90.3 ``` Expected output: ``` The following checks were performed on each of these signatures: - The cosign claims were validated - The signatures were verified against the specified public key ``` *** ##### What's Changed - chore(release): backport [#​31923](BerriAI/litellm#31923), [#​31929](BerriAI/litellm#31929), [#​31393](BerriAI/litellm#31393) to stable/1.90.x and cut 1.90.3 by [@​mateo-berri](https://github.com/mateo-berri) in [#​32025](BerriAI/litellm#32025) **Full Changelog**: <BerriAI/litellm@v1.90.2...v1.90.3> </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xMDEuMSIsInVwZGF0ZWRJblZlciI6IjQzLjEwMS4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJyZW5vdmF0ZS9jb250YWluZXIiLCJ0eXBlL3BhdGNoIl19--> Reviewed-on: https://git.erwanleboucher.dev/eleboucher/homelab/pulls/1400
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [ghcr.io/berriai/litellm](https://images.chainguard.dev/directory/image/wolfi-base/overview) ([source](https://github.com/BerriAI/litellm)) | final | patch | `v1.90.2` → `v1.90.3` | --- ### Release Notes <details> <summary>BerriAI/litellm (ghcr.io/berriai/litellm)</summary> ### [`v1.90.3`](https://github.com/BerriAI/litellm/releases/tag/v1.90.3) [Compare Source](BerriAI/litellm@v1.90.3...v1.90.3) ##### Verify Docker Image Signature All LiteLLM Docker images are signed with [cosign](https://docs.sigstore.dev/cosign/overview/). Every release is signed with the same key introduced in [commit `0112e53`](BerriAI/litellm@0112e53). **Verify using the pinned commit hash (recommended):** A commit hash is cryptographically immutable, so this is the strongest way to ensure you are using the original signing key: ```bash cosign verify \ --key https://raw.githubusercontent.com/BerriAI/litellm/0112e53046018d726492c814b3644b7d376029d0/cosign.pub \ ghcr.io/berriai/litellm:v1.90.3 ``` **Verify using the release tag (convenience):** Tags are protected in this repository and resolve to the same key. This option is easier to read but relies on tag protection rules: ```bash cosign verify \ --key https://raw.githubusercontent.com/BerriAI/litellm/v1.90.3/cosign.pub \ ghcr.io/berriai/litellm:v1.90.3 ``` Expected output: ``` The following checks were performed on each of these signatures: - The cosign claims were validated - The signatures were verified against the specified public key ``` *** ##### What's Changed - chore(release): backport [#​31923](BerriAI/litellm#31923), [#​31929](BerriAI/litellm#31929), [#​31393](BerriAI/litellm#31393) to stable/1.90.x and cut 1.90.3 by [@​mateo-berri](https://github.com/mateo-berri) in [#​32025](BerriAI/litellm#32025) **Full Changelog**: <BerriAI/litellm@v1.90.2...v1.90.3> ### [`v1.90.3`](https://github.com/BerriAI/litellm/releases/tag/v1.90.3) [Compare Source](BerriAI/litellm@v1.90.2...v1.90.3) ##### Verify Docker Image Signature All LiteLLM Docker images are signed with [cosign](https://docs.sigstore.dev/cosign/overview/). Every release is signed with the same key introduced in [commit `0112e53`](BerriAI/litellm@0112e53). **Verify using the pinned commit hash (recommended):** A commit hash is cryptographically immutable, so this is the strongest way to ensure you are using the original signing key: ```bash cosign verify \ --key https://raw.githubusercontent.com/BerriAI/litellm/0112e53046018d726492c814b3644b7d376029d0/cosign.pub \ ghcr.io/berriai/litellm:v1.90.3 ``` **Verify using the release tag (convenience):** Tags are protected in this repository and resolve to the same key. This option is easier to read but relies on tag protection rules: ```bash cosign verify \ --key https://raw.githubusercontent.com/BerriAI/litellm/v1.90.3/cosign.pub \ ghcr.io/berriai/litellm:v1.90.3 ``` Expected output: ``` The following checks were performed on each of these signatures: - The cosign claims were validated - The signatures were verified against the specified public key ``` *** ##### What's Changed - chore(release): backport [#​31923](BerriAI/litellm#31923), [#​31929](BerriAI/litellm#31929), [#​31393](BerriAI/litellm#31393) to stable/1.90.x and cut 1.90.3 by [@​mateo-berri](https://github.com/mateo-berri) in [#​32025](BerriAI/litellm#32025) **Full Changelog**: <BerriAI/litellm@v1.90.2...v1.90.3> </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yNDkuNSIsInVwZGF0ZWRJblZlciI6IjQzLjI0OS41IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJkZXBlbmRlbmNpZXMiXX0=--> Co-authored-by: Renovate Bot <renovate@bhamm-lab.com> Reviewed-on: https://codeberg.org/blake-hamm/bhamm-lab/pulls/258
…to v1.90.3 (#257) This PR contains the following updates: | Package | Update | Change | |---|---|---| | [https://github.com/BerriAI/litellm.git](https://github.com/BerriAI/litellm) | patch | `v1.90.0` → `v1.90.3` | --- ### Release Notes <details> <summary>BerriAI/litellm (https://github.com/BerriAI/litellm.git)</summary> ### [`v1.90.3`](https://github.com/BerriAI/litellm/releases/tag/v1.90.3) [Compare Source](BerriAI/litellm@v1.90.2...v1.90.3) #### Verify Docker Image Signature All LiteLLM Docker images are signed with [cosign](https://docs.sigstore.dev/cosign/overview/). Every release is signed with the same key introduced in [commit `0112e53`](BerriAI/litellm@0112e53). **Verify using the pinned commit hash (recommended):** A commit hash is cryptographically immutable, so this is the strongest way to ensure you are using the original signing key: ```bash cosign verify \ --key https://raw.githubusercontent.com/BerriAI/litellm/0112e53046018d726492c814b3644b7d376029d0/cosign.pub \ ghcr.io/berriai/litellm:v1.90.3 ``` **Verify using the release tag (convenience):** Tags are protected in this repository and resolve to the same key. This option is easier to read but relies on tag protection rules: ```bash cosign verify \ --key https://raw.githubusercontent.com/BerriAI/litellm/v1.90.3/cosign.pub \ ghcr.io/berriai/litellm:v1.90.3 ``` Expected output: ``` The following checks were performed on each of these signatures: - The cosign claims were validated - The signatures were verified against the specified public key ``` *** #### What's Changed - chore(release): backport [#​31923](BerriAI/litellm#31923), [#​31929](BerriAI/litellm#31929), [#​31393](BerriAI/litellm#31393) to stable/1.90.x and cut 1.90.3 by [@​mateo-berri](https://github.com/mateo-berri) in [#​32025](BerriAI/litellm#32025) **Full Changelog**: <BerriAI/litellm@v1.90.2...v1.90.3> ### [`v1.90.2`](https://github.com/BerriAI/litellm/releases/tag/v1.90.2) [Compare Source](BerriAI/litellm@v1.90.1...v1.90.2) #### Verify Docker Image Signature All LiteLLM Docker images are signed with [cosign](https://docs.sigstore.dev/cosign/overview/). Every release is signed with the same key introduced in [commit `0112e53`](BerriAI/litellm@0112e53). **Verify using the pinned commit hash (recommended):** A commit hash is cryptographically immutable, so this is the strongest way to ensure you are using the original signing key: ```bash cosign verify \ --key https://raw.githubusercontent.com/BerriAI/litellm/0112e53046018d726492c814b3644b7d376029d0/cosign.pub \ ghcr.io/berriai/litellm:v1.90.2 ``` **Verify using the release tag (convenience):** Tags are protected in this repository and resolve to the same key. This option is easier to read but relies on tag protection rules: ```bash cosign verify \ --key https://raw.githubusercontent.com/BerriAI/litellm/v1.90.2/cosign.pub \ ghcr.io/berriai/litellm:v1.90.2 ``` Expected output: ``` The following checks were performed on each of these signatures: - The cosign claims were validated - The signatures were verified against the specified public key ``` *** #### What's Changed - chore(release): backport [#​31519](BerriAI/litellm#31519), [#​31733](BerriAI/litellm#31733) to stable/1.90.x and cut 1.90.2 by [@​yuneng-berri](https://github.com/yuneng-berri) in [#​31782](BerriAI/litellm#31782) **Full Changelog**: <BerriAI/litellm@v1.90.1...v1.90.2> ### [`v1.90.1`](https://github.com/BerriAI/litellm/releases/tag/v1.90.1) [Compare Source](BerriAI/litellm@v1.90.0-rc.1...v1.90.1) #### Verify Docker Image Signature All LiteLLM Docker images are signed with [cosign](https://docs.sigstore.dev/cosign/overview/). Every release is signed with the same key introduced in [commit `0112e53`](BerriAI/litellm@0112e53). **Verify using the pinned commit hash (recommended):** A commit hash is cryptographically immutable, so this is the strongest way to ensure you are using the original signing key: ```bash cosign verify \ --key https://raw.githubusercontent.com/BerriAI/litellm/0112e53046018d726492c814b3644b7d376029d0/cosign.pub \ ghcr.io/berriai/litellm:v1.90.1 ``` **Verify using the release tag (convenience):** Tags are protected in this repository and resolve to the same key. This option is easier to read but relies on tag protection rules: ```bash cosign verify \ --key https://raw.githubusercontent.com/BerriAI/litellm/v1.90.1/cosign.pub \ ghcr.io/berriai/litellm:v1.90.1 ``` Expected output: ``` The following checks were performed on each of these signatures: - The cosign claims were validated - The signatures were verified against the specified public key ``` *** #### What's Changed - chore(release): backport [#​31036](BerriAI/litellm#31036), [#​31342](BerriAI/litellm#31342), [#​31653](BerriAI/litellm#31653) to stable/1.90.x and cut 1.90.1 (litellm-enterprise 0.1.43.post1) by [@​yuneng-berri](https://github.com/yuneng-berri) in [#​31667](BerriAI/litellm#31667) **Full Changelog**: <BerriAI/litellm@v1.90.0...v1.90.1> </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yNDkuNSIsInVwZGF0ZWRJblZlciI6IjQzLjI0OS41IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJkZXBlbmRlbmNpZXMiXX0=--> Co-authored-by: Renovate Bot <renovate@bhamm-lab.com> Reviewed-on: https://codeberg.org/blake-hamm/bhamm-lab/pulls/257
…AI#31929) * fix(bedrock): honor ttl for tool_config cache injection points Pass cache_control_injection_points control.ttl through to Bedrock toolConfig cachePoint blocks, matching message/system cache behavior. Co-authored-by: Cursor <cursoragent@cursor.com> * refactor(bedrock): drive Claude 4.5+ ttl support from pricing JSON, not regex is_claude_4_5_on_bedrock hardcoded a model-name pattern list that needed a manual update for every new Claude release (it already silently missed Sonnet 5 and Fable 5). Replace it with a lookup against cache_creation_input_token_cost_above_1hr in model_prices_and_context_window.json, which AWS docs confirm tracks the same 1h-TTL-capable model set. Also fixes two bedrock Claude 3.5 Sonnet entries that incorrectly carried that pricing field (their own regional variants didn't have it), which would have made the JSON-driven check wrongly grant them 1h TTL support. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(tests): use real Claude Sonnet 4.5 release id in ttl cache-point tests test_add_cache_point_tool_block_passes_ttl_for_claude_4_5 and test_bedrock_tools_pt_passes_ttl_for_claude_4_5 used a fabricated model id (...-20250514-v1:0) that never shipped. This passed under the old regex-based is_claude_4_5_on_bedrock, which matched on substring alone, but fails now that it looks up cache_creation_input_token_cost_above_1hr in litellm.model_cost, since the fake id has no pricing entry. Also force the bundled local cost map in both tests so ttl eligibility reads this branch's pricing data instead of the network-fetched main copy, which lacks the fix until merge. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(bedrock): restore cache and tool config compatibility * fix(bedrock): preserve Sonnet 5 parallel tool config * fix(bedrock): decouple parallel tool support from cache ttl * refactor(bedrock): drive parallel tool use config from JSON, not hardcoded patterns Replace the hardcoded _CLAUDE_BEDROCK_PARALLEL_TOOL_USE_PATTERNS tuple and bedrock_converse_supports_strict_tool_schemas (dead code) with a supports_parallel_tool_use_config key in model_prices_and_context_window.json, matching how is_claude_4_5_on_bedrock already reads cache_creation_input_token_cost_above_1hr from the pricing JSON. New models pick up parallel tool use support automatically when their pricing entry ships with the key set, with no code change required Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(tests): use real model id in parallel-tool-use-without-ttl-pricing test anthropic.claude-opus-4-7-unlisted-v1:0 has no entry in model_prices_and_context_window.json, so bedrock_converse_supports_parallel_tool_use_config returned False and the test died with KeyError on additionalModelRequestFields. Use jp.anthropic.claude-opus-4-7, a real entry that carries supports_parallel_tool_use_config without 1h-TTL cache pricing, which is exactly the decoupling this test exists to cover * test(utils): allow supports_parallel_tool_use_config in pricing schema The misc unit test job validates model_prices_and_context_window.json against the INTENDED_SCHEMA allowlist in test_utils.py, which rejects unknown keys. Add the supports_parallel_tool_use_config key this PR introduced so test_aaamodel_prices_and_context_window_json_is_valid passes again * fix(bedrock): preserve ttl for regional claude models * fix(bedrock): fall back to base model entry when regional pricing lacks capability fields Regional model_cost entries like jp.anthropic.claude-opus-4-7 that omit cache_creation_input_token_cost_above_1hr shadowed the base entry that has it, so is_claude_4_5_on_bedrock returned False and requested cache ttl values were dropped for those deployments. Both capability lookups now consult the full model id and the region-stripped base entry, matching the coverage of the old name-pattern list. Also restores ToolBlock keyword construction for the tool_config cachePoint; PEP 589 TypedDict keyword instantiation works on every supported Python version --------- Co-authored-by: Shivam Rawat <shivamrawat@Shivams-MacBook-Pro.local> Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: mateo <mateo@berri.ai> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com> (cherry picked from commit 1543725)
|
bugbot run |
|
@coderabbitai review |
✅ Action performedReview finished.
|
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 4e53edc. Configure here.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (11)
📝 WalkthroughWalkthroughBedrock Converse gating for parallel tool-use and extended cache TTL support switches from hardcoded Claude 4.5 name matching to data-driven lookups against ChangesCapability-driven parallel tool-use and cache TTL gating
Pricing/context window JSON data updates
Estimated code review effort: 3 (Moderate) | ~30 minutes ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts
Comment |
Resolves LIT-3892
Issue
Bedrock Converse cache_control_injection_points with location: tool_config did not honor control.ttl. Callers could request ttl: 1h on tool definitions, but LiteLLM always emitted a bare {"cachePoint": {"type": "default"}} in toolConfig.tools, so Bedrock silently fell back to the 5-minute default. Message and system cache points already respected ttl via _get_cache_point_block; the tool_config path skipped that logic entirely
Separately, is_claude_4_5_on_bedrock used a hardcoded model-name pattern list to decide whether 5m/1h TTL was allowed. That list needed manual updates for every new Claude release and already missed models like Sonnet 5 and Fable 5 that have 1h TTL pricing in model_prices_and_context_window.json
Two Claude 3.5 Sonnet entries in the pricing JSON incorrectly carried cache_creation_input_token_cost_above_1hr, which would have made a JSON-driven check wrongly grant them 1h TTL support (their own us./eu./apac. regional variants did not have the field)
Cause
In converse_transformation.py, the tool_config branch hardcoded the cache point and never read point["control"]:
bedrock_tools.append({"cachePoint": {"type": "default"}})
The message/system path already went through _get_cache_point_block, which mapped cache_control.ttl onto the Bedrock cachePoint when the model was eligible. The type for tool_config injection points also lacked a control field, so ttl was not even modeled for that location
For model eligibility, is_claude_4_5_on_bedrock matched substring patterns like sonnet-4-5 and opus-4-7 instead of reading capability data from the pricing JSON. New models only worked after someone updated the regex list, and the JSON already had a better signal: cache_creation_input_token_cost_above_1hr is present only on models AWS bills for 1-hour cache writes
Fix
Pass ttl through for tool_config cache injection
Extracted shared _build_cache_point_block(control, model) and wired both message/system and tool_config paths through it. Added control: Optional[ChatCompletionCachedContent] to CacheControlToolConfigInjectionPoint. Added regression tests asserting ttl: 1h survives for Claude Sonnet 4.5 and is dropped for unsupported models
Drive 1h TTL eligibility from pricing JSON
Replaced the hardcoded pattern list in is_claude_4_5_on_bedrock with a lookup against cache_creation_input_token_cost_above_1hr in litellm.model_cost (with get_bedrock_base_model fallback). New Claude releases pick up 1h TTL support automatically when their pricing entry ships
Fix bad pricing data
Removed cache_creation_input_token_cost_above_1hr (and its above-200k variant) from anthropic.claude-3-5-sonnet-20240620-v1:0 and anthropic.claude-3-5-sonnet-20241022-v2:0 in both model_prices_and_context_window.json and the bundled backup, matching their regional variants and AWS's documented 1h-TTL model set
SCRIPT:
print(result["system"]) # -> cachePoint DOES carry {'ttl': '1h'} (message path works)
print(result["toolConfig"]) # -> {'cachePoint': {'type': 'default'}} <-- ttl silently dropped
Before:

After:

Note
Medium Risk
Changes Bedrock request shaping for prompt caching and parallel tools; wrong pricing flags could omit TTL or parallel config for some model IDs, but scope is limited to capability gating and cache metadata.
Overview
Fixes LIT-3892: Bedrock Converse
cache_control_injection_pointswithlocation: tool_confignow forwardcontrol.ttl(e.g.1h) intotoolConfig.toolscache points, using the same_build_cache_point_blockpath as message/system blocks.CacheControlToolConfigInjectionPointgains an optionalcontrolfield.Model capability checks no longer rely on hardcoded Claude name patterns.
is_claude_4_5_on_bedrock(extended cache TTL) keys offcache_creation_input_token_cost_above_1hrin pricing data, with regional → base-model lookup.bedrock_converse_supports_parallel_tool_use_configis a separate JSON flag so parallel-tool config is not tied to TTL eligibility.Pricing updates:
supports_parallel_tool_use_configon eligible Bedrock Anthropic models; removed erroneouscache_creation_input_token_cost_above_1hrfrom two Claude 3.5 Sonnet base entries so they are not treated as 1h-TTL models.Reviewed by Cursor Bugbot for commit 4e53edc. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit
New Features
Bug Fixes
Chores