Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.

feat: update virtual id for extended output 128k claude#1327

Merged
mrubens merged 4 commits into
RooCodeInc:mainfrom
monotykamary:feat/claude-extended-output
Mar 3, 2025
Merged

feat: update virtual id for extended output 128k claude#1327
mrubens merged 4 commits into
RooCodeInc:mainfrom
monotykamary:feat/claude-extended-output

Conversation

@monotykamary

@monotykamary monotykamary commented Mar 3, 2025

Copy link
Copy Markdown
Contributor

Context

Added support for Claude 3.7 Sonnet with both thinking and 128k output capacity through an existing variant: claude-3-7-sonnet-20250219:thinking. This enhancement provides users with access to the extended output capabilities of Claude 3.7 while maintaining thinking functionality.

Implementation

The implementation required changes in several key areas:

  1. Updated model definition in anthropicModels in api.ts for the 128k
  2. Enhanced the getModel() method to track the original "virtual" model ID alongside the actual model ID
  3. Added header support for the 128k output capability using the anthropic-beta: output-128k-2025-02-19 header

I maintained a consistent pattern for handling feature-specific headers by implementing the same header selection logic across all API methods. This keeps the code maintainable while supporting both prompt caching and extended output capabilities.

Screenshots

before after
Only standard Claude 3.7 Sonnet with thinking was available Users can now select Claude 3.7 Sonnet with thinking and 128k output capacity
image

How to Test

  1. Set your model to claude-3-7-sonnet-20250219:thinking-128k in your configuration
  2. Generate a response that requires a large output (e.g., ask for a comprehensive analysis of a complex topic)
  3. Verify that:
    • The model correctly uses the thinking capability
    • The model can generate responses beyond the standard 64k token limit
    • All API calls (streaming, completion, token counting) work correctly

Get in Touch

I'm available on the Roo Code Discord as @monotykamary if you have any questions!


Important

Updates claude-3-7-sonnet-20250219:thinking model variant with 128k output capacity and updates header handling for extended output capabilities.

  • Behavior:
    • Updates claude-3-7-sonnet-20250219:thinking model variant in anthropicModels in api.ts with 128k output capacity.
    • Updates getModel() in anthropic.ts to track virtualId for special variant handling.
    • Adds header anthropic-beta: output-128k-2025-02-19 for 128k output capability in createMessage.
  • Misc:
    • Ensures consistent header application across all API calls for prompt caching and extended output capabilities.

This description was created by Ellipsis for aec03d7. It will automatically update as commits are pushed.

@monotykamary monotykamary requested review from cte and mrubens as code owners March 3, 2025 00:51
@changeset-bot

changeset-bot Bot commented Mar 3, 2025

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: ef93f5d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. Enhancement New feature or request labels Mar 3, 2025
@cte

cte commented Mar 3, 2025

Copy link
Copy Markdown
Contributor

Do you think it makes sense to always enable 128k as a simplification?

@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Mar 3, 2025
@mrubens

mrubens commented Mar 3, 2025

Copy link
Copy Markdown
Collaborator

Do you think it makes sense to always enable 128k as a simplification?

Yes, I think that makes sense now that we have the ability to set a lower default.

@monotykamary monotykamary changed the title feat: add virtual id for extended output capabilities feat: add virtual id for extended output 128k claude Mar 3, 2025
@monotykamary

Copy link
Copy Markdown
Contributor Author

Do you think it makes sense to always enable 128k as a simplification?

ohi n that case, let me push a quick fix and default the beta tag for 3.7

@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Mar 3, 2025
@monotykamary

Copy link
Copy Markdown
Contributor Author
image

@monotykamary monotykamary changed the title feat: add virtual id for extended output 128k claude feat: update virtual id for extended output 128k claude Mar 3, 2025

@cte cte 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.

Thank you!

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Mar 3, 2025
@cte

cte commented Mar 3, 2025

Copy link
Copy Markdown
Contributor

As a follow-up we might want to also update OpenRouter and Vertex. I believe that OpenRouter already transparently sets this header for us, so we should just be able to update the maxTokens value. I'm not sure if it's being set for Vertex.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Enhancement New feature or request lgtm This PR has been approved by a maintainer size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants