Add Anthropic Claude Sonnet 5 API support#988
Conversation
Expose Claude Sonnet 5 in the API model list and cover its request parameter behavior with tests. Disable default thinking until the extension exposes thinking controls and response-budget handling. References: - https://www.anthropic.com/news/claude-sonnet-5 - https://platform.claude.com/docs/en/about-claude/models/overview - https://platform.claude.com/docs/en/about-claude/models/whats-new-sonnet-5
📝 WalkthroughWalkthroughThis PR adds a new Claude model, ChangesClaude Sonnet 5 Support
Sequence Diagram(s)Skipped: changes are limited to configuration and conditional request-body logic affecting fewer than 3 distinct components, with a self-evident control flow. Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
PR Summary by QodoAdd Anthropic Claude Sonnet 5 to model list and request builder
AI Description
Diagram
High-Level Assessment
Files changed (3)
|
There was a problem hiding this comment.
Code Review
This pull request adds support for the claude-sonnet-5 model, omitting the temperature parameter for it. It also attempts to disable the default thinking feature by setting thinking: { type: 'disabled' }. However, the reviewer points out that the Anthropic Messages API does not support type: 'disabled' and will return a 400 Bad Request error; instead, the thinking parameter should be omitted entirely to disable it. Consequently, the helper function and associated logic should be removed, and the unit tests should be updated to verify that the thinking parameter is omitted.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
Pull request overview
Adds Anthropic Claude Sonnet 5 as a selectable Anthropic API model in ChatGPTBox and adjusts the Claude API request payload to match Sonnet 5’s parameter expectations (including disabling default thinking), with unit test coverage to lock in the behavior.
Changes:
- Exposes
claudeSonnet5Apiin the Anthropic API model list and model registry. - Updates Claude API request construction to (a) omit
temperaturefor Sonnet 5 and (b) explicitly disable default thinking for Sonnet 5. - Extends unit tests to cover Sonnet 5 request-body behavior alongside existing Opus 4.7/4.8 behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
tests/unit/services/apis/claude-api.test.mjs |
Extends request-body tests to include Sonnet 5, asserting temperature omission and thinking: { type: 'disabled' }. |
src/services/apis/claude-api.mjs |
Adds Sonnet 5 handling: omit temperature and disable default thinking in the Messages API payload. |
src/config/index.mjs |
Registers claudeSonnet5Api in claudeApiModelKeys and Models so it appears in the UI/model selection. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/services/apis/claude-api.mjs (1)
8-14: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider centralizing per-model behavior flags.
shouldOmitTemperatureandshouldDisableDefaultThinkingboth hardcode model-id string literals independently. As more Claude models gain similar special-casing (sampling restrictions, thinking defaults), this duplication makes it easy for the two lists to drift out of sync. Consider deriving these flags from theModelsconfig entry (e.g., adisableDefaultThinking/omitTemperatureboolean per model) so behavior is declared in one place.This is optional given the current small scope, not blocking.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/services/apis/claude-api.mjs` around lines 8 - 14, The per-model special-casing in shouldOmitTemperature and shouldDisableDefaultThinking is duplicated with hardcoded Claude model IDs, so centralize these flags in the Models config instead. Update the model metadata to declare omitTemperature and disableDefaultThinking (or equivalent) and have both helper functions read from that shared config rather than maintaining separate string literal lists, using the existing shouldOmitTemperature and shouldDisableDefaultThinking symbols to locate the logic.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/services/apis/claude-api.mjs`:
- Around line 8-14: The per-model special-casing in shouldOmitTemperature and
shouldDisableDefaultThinking is duplicated with hardcoded Claude model IDs, so
centralize these flags in the Models config instead. Update the model metadata
to declare omitTemperature and disableDefaultThinking (or equivalent) and have
both helper functions read from that shared config rather than maintaining
separate string literal lists, using the existing shouldOmitTemperature and
shouldDisableDefaultThinking symbols to locate the logic.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 0da758ae-5886-471f-ad58-b67ac2e5249e
📒 Files selected for processing (3)
src/config/index.mjssrc/services/apis/claude-api.mjstests/unit/services/apis/claude-api.test.mjs
Expose Claude Sonnet 5 in the API model list and cover its request parameter behavior with tests.
Disable default thinking until the extension exposes thinking controls and response-budget handling.
References:
Summary by CodeRabbit