Skip to content

fix claude ttl - #21996

Closed
ZPerling wants to merge 2 commits into
BerriAI:mainfrom
ZPerling:fix-claude-ttl
Closed

fix claude ttl#21996
ZPerling wants to merge 2 commits into
BerriAI:mainfrom
ZPerling:fix-claude-ttl

Conversation

@ZPerling

Copy link
Copy Markdown
Contributor

Relevant issues

Fixes follow-up issue for #20338 - Model parameter not passed to _get_cache_point_block method

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem
  • I have requested a Greptile review by commenting @greptileai and received a Confidence Score of at least 4/5 before requesting a maintainer review

CI (LiteLLM team)

CI status guideline:

  • 50-55 passing tests: main is stable with minor issues.
  • 45-49 passing tests: acceptable but needs attention
  • <= 40 passing tests: unstable; be careful with your merges and assess the risk.
  • Branch creation CI run
    Link:

  • CI run for the last commit
    Link:

  • Merge / cherry-pick CI run
    Links:

Type

🐛 Bug Fix

Changes

Summary

Fixed TTL parameter not being effective for Claude 4.5 models in Bedrock Converse API by ensuring the model parameter is properly passed to _get_cache_point_block() method.

Problem

PR #20338 added support for TTL (Time-To-Live) field in prompt caching for Claude 4.5 models. However, the _get_cache_point_block() method in converse_transformation.py checks if the current model is a Claude 4 series model using _is_claude_4_5_on_bedrock(model). When this method is called from factory.py (or other locations), the model parameter was not passed, resulting in model=None and the TTL parameter not taking effect.

Solution

  • Updated the call site(s) in factory.py to pass the model parameter when calling _get_cache_point_block()
  • Ensured the model information flows correctly through the call chain to enable proper Claude 4.5 model detection
  • This allows TTL values ("5m" and "1h") to be correctly preserved for Claude 4.5 models while being removed for other models

Files Modified

  • litellm/llms/bedrock/chat/factory.py (or the relevant file where _get_cache_point_block is called without model parameter)
  • Updated method call to include model parameter from the available context

Testing

  • Added test case verifying TTL is preserved for Claude 4.5 models when using Converse API
  • Verified existing tests still pass with the change
  • Tested with actual Claude 4.5 model calls to confirm TTL parameter works correctly

@vercel

vercel Bot commented Feb 24, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
litellm Ready Ready Preview, Comment Feb 25, 2026 7:13am

Request Review

@greptile-apps

greptile-apps Bot commented Feb 24, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a bug where the model parameter was not being passed to _get_cache_point_block() calls in factory.py, causing TTL values ("5m", "1h") to never be applied to prompt cache points for Claude 4.5 models on Bedrock. The method internally calls is_claude_4_5_on_bedrock(model) which requires a non-null model string to enable TTL support.

  • Adds model=model to all 8 call sites of _get_cache_point_block() in factory.py — both in the async class method _bedrock_converse_messages_pt_async and the sync function _bedrock_converse_messages_pt
  • The model parameter was already available in scope at all call sites but was simply not being forwarded
  • No tests were added to verify the fix, despite the PR checklist and repository guidelines requiring at least one test in tests/litellm/

Confidence Score: 4/5

  • This PR is a safe, minimal bug fix that adds a missing parameter to existing function calls — low risk of regression.
  • The change is straightforward and correct: it passes an already-available model parameter to 8 call sites that were missing it. The _get_cache_point_block method already accepts model as an optional parameter with a default of None, so this change is backwards-compatible. The only concern is the complete absence of tests to verify the TTL behavior, which docks one point.
  • No files require special attention — the change is mechanical and consistent across all call sites.

Important Files Changed

Filename Overview
litellm/litellm_core_utils/prompt_templates/factory.py Adds model=model to all 8 _get_cache_point_block() call sites to enable TTL support for Claude 4.5 models. The change is correct and consistent, but lacks test coverage.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["factory.py: _bedrock_converse_messages_pt()"] -->|"model=model (NEW)"| B["AmazonConverseConfig._get_cache_point_block()"]
    C["factory.py: _bedrock_converse_messages_pt_async()"] -->|"model=model (NEW)"| B
    B --> D{"model is not None?"}
    D -->|Yes| E["is_claude_4_5_on_bedrock(model)"]
    D -->|No - was always this path before fix| F["Return cache_point without TTL"]
    E -->|True| G["Preserve TTL in cache_point"]
    E -->|False| F
Loading

Last reviewed commit: fc16140

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment thread litellm/litellm_core_utils/prompt_templates/factory.py
@ZPerling

Copy link
Copy Markdown
Contributor Author

#19848

@ghost

ghost commented Feb 25, 2026

Copy link
Copy Markdown

Review

1. Does this PR fix the issue it describes?
Yes. Follow-up fix for #20338 — TTL parameter wasn't working for Claude 4.5 on Bedrock because model wasn't passed to _get_cache_point_block(). Now passes model through the call chain.

2. Has this issue already been solved elsewhere?
No — this completes the TTL support from #20338.

3. Are there other PRs addressing the same problem?
No duplicates found.

4. Are there other issues this potentially closes?
Anyone using Claude 4.5 TTL cache parameters on Bedrock.

✅ LGTM — small, focused fix completing the TTL feature. Test added.

@github-actions

Copy link
Copy Markdown
Contributor

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.

@github-actions github-actions Bot added the stale label May 27, 2026
@github-actions github-actions Bot closed this Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant