Skip to content

fix: check both dash-form and dot-form model IDs in getDefaultMaxTokens - #464

Open
wasim-builds wants to merge 2 commits into
stripe:mainfrom
wasim-builds:fix/normalized-anthropic-model-max-tokens
Open

fix: check both dash-form and dot-form model IDs in getDefaultMaxTokens#464
wasim-builds wants to merge 2 commits into
stripe:mainfrom
wasim-builds:fix/normalized-anthropic-model-max-tokens

Conversation

@wasim-builds

Copy link
Copy Markdown

Summary

Fixes #432

in both the V2 and V3 language models only checked for dash-form model ID patterns (e.g., claude-3-7-sonnet), but normalizeModelId converts version dashes to dots (e.g., claude-3.7-sonnet). This caused normalized Anthropic model IDs to silently fall back to the 4096 default instead of their intended values:

Model Expected Actual (before fix)
anthropic/claude-3-7-sonnet 64000 64000
anthropic/claude-3.7-sonnet (normalized) 64000 4096
anthropic/claude-3-5-haiku 8192 8192
anthropic/claude-3.5-haiku (normalized) 8192 4096
anthropic/claude-haiku-4-5 64000 64000
anthropic/claude-haiku-4.5 (normalized) 64000 4096

Changes

  • stripe-language-model.ts: Added dot-form pattern checks (claude-3.7-sonnet, claude-3.5-haiku, haiku-4.5) to getDefaultMaxTokens
  • stripe-language-model-v3.ts: Same fix applied to the V3 implementation
  • Tests: Added test cases for both normalized (dot-form) and dash-form model IDs in both V2 and V3 test suites

All 333 tests pass.

normalizeModelId converts Anthropic version dashes to dots (e.g.,
claude-3-7-sonnet -> claude-3.7-sonnet), but getDefaultMaxTokens only
checked dash-form patterns. This caused normalized model IDs to silently
fall back to the 4096 default instead of their intended values (64000
for Sonnet 4/3.7, 8192 for 3.5 Haiku, 64000 for Haiku 4.5).

Fixes stripe#432
@cla-assistant

cla-assistant Bot commented Jul 23, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@cla-assistant

cla-assistant Bot commented Jul 23, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@wasim-builds

Copy link
Copy Markdown
Author

By the way, I've really been enjoying contributing to this project! My goal is to get more involved in open source to help maintain projects and learn from great engineering teams. Is there a process or pathway for becoming a member of the stripe GitHub organization? I'd love to continue helping out where I can!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Normalized Anthropic model IDs fall back to the wrong default max_tokens

1 participant