Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Nov 25, 2025

Related GitHub Issue

Closes: #9567

Roo Code Task Context (Optional)

N/A - Created by Roo Code agent

Description

This PR fixes the issue where Claude Opus 4.5 (claude-opus-4-5-20251101) was not utilizing Anthropic's prompt caching feature, resulting in significantly higher API costs.

The fix adds the model ID claude-opus-4-5-20251101 to both cache control switch statements in the Anthropic provider implementation, enabling:

  • Cache control headers for request/response caching
  • The prompt-caching-2024-07-31 beta feature

This brings Opus 4.5 in line with other Claude models that properly support caching.

Test Procedure

  1. Ran existing Anthropic provider tests: cd src && npx vitest run api/providers/__tests__/anthropic.spec.ts
  2. All 17 tests passed successfully
  3. The fix ensures Opus 4.5 requests will now include cache control configuration similar to Sonnet 4.5

To verify manually:

  1. Configure Roo Code to use Opus 4.5 model
  2. Check Anthropic API logs - you should now see cache_read and cache_write statistics
  3. Observe reduced costs due to caching on subsequent requests

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

Not applicable - backend API configuration change.

Documentation Updates

  • No documentation updates are required.

The change is internal to the API provider configuration and doesn't affect user-facing features or APIs.

Additional Notes

This is a simple but important fix that ensures Opus 4.5 users benefit from the same cost savings through caching that other Claude models provide.

Get in Touch

Agent-generated PR


Important

Enables caching for Opus 4.5 model by adding its ID to cache control in anthropic.ts, reducing API costs.

  • Behavior:
    • Adds claude-opus-4-5-20251101 to cache control switch statements in anthropic.ts.
    • Enables cache control headers and prompt-caching-2024-07-31 beta feature for Opus 4.5.
  • Testing:
    • All 17 existing tests in anthropic.spec.ts passed.
    • Manual verification shows cache statistics in Anthropic API logs.

This description was created by Ellipsis for b46d1da. You can customize this summary. It will automatically update as commits are pushed.

Added claude-opus-4-5-20251101 to the cache control switch statements
to enable prompt caching, matching the behavior of other Claude models.

Fixes #9567
@roomote roomote bot requested review from cte, jr and mrubens as code owners November 25, 2025 10:30
@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. bug Something isn't working labels Nov 25, 2025
@roomote
Copy link
Contributor Author

roomote bot commented Nov 25, 2025

Rooviewer Clock   See task on Roo Cloud

Review complete. No issues found - the implementation correctly enables caching for Opus 4.5 by adding the model ID to both cache control switch statements.

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

@roomote roomote bot mentioned this pull request Nov 25, 2025
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Nov 25, 2025
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Nov 25, 2025
@mrubens mrubens merged commit 2945b30 into main Nov 25, 2025
23 checks passed
@mrubens mrubens deleted the fix/opus-4-5-caching branch November 25, 2025 12:16
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Nov 25, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Nov 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

[BUG] Opus 4.5 Not Caching

4 participants