Skip to content

Add Anthropic Claude Sonnet 5 API support#988

Open
PeterDaveHello wants to merge 1 commit into
ChatGPTBox-dev:masterfrom
PeterDaveHello:add-claude-sonnet-5-support
Open

Add Anthropic Claude Sonnet 5 API support#988
PeterDaveHello wants to merge 1 commit into
ChatGPTBox-dev:masterfrom
PeterDaveHello:add-claude-sonnet-5-support

Conversation

@PeterDaveHello

@PeterDaveHello PeterDaveHello commented Jun 30, 2026

Copy link
Copy Markdown
Member

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

  • New Features
    • Added support for Claude Sonnet 5 as an available model option.
    • Requests for this model now use the appropriate default settings for improved compatibility.
  • Bug Fixes
    • Updated request handling so certain sampling settings are automatically adjusted for Claude Sonnet 5.
    • Disabled default “thinking” behavior for this model when sending requests.

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
@PeterDaveHello PeterDaveHello requested a review from Copilot June 30, 2026 19:30
@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds a new Claude model, claude-sonnet-5, to the configuration registry. It updates the Claude API request builder to omit the temperature parameter and disable default thinking for this model, and extends the corresponding unit tests to validate this behavior.

Changes

Claude Sonnet 5 Support

Layer / File(s) Summary
Model registry entry
src/config/index.mjs
Adds claudeSonnet5Api to claudeApiModelKeys and defines its Models entry with value claude-sonnet-5 and description Anthropic (Claude Sonnet 5).
Request body logic and tests
src/services/apis/claude-api.mjs, tests/unit/services/apis/claude-api.test.mjs
Expands shouldOmitTemperature to cover claude-sonnet-5, adds shouldDisableDefaultThinking helper to set body.thinking = {type: 'disabled'}, and updates unit tests to assert this behavior across the model matrix.

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

Review effort 2/5

Poem

A new Sonnet joins the Claude parade,
Five's the number, thinking's delayed,
No temperature fuss, just steady and cool,
Tests all hop through, by the rabbit's rule,
🐇✨ Hooray for the model freshly made!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding Anthropic Claude Sonnet 5 API support.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@qodo-code-review

Copy link
Copy Markdown
Contributor

PR Summary by Qodo

Add Anthropic Claude Sonnet 5 to model list and request builder

✨ Enhancement 🧪 Tests 🕐 20-40 Minutes

Grey Divider

AI Description

• Expose Claude Sonnet 5 in Anthropic API model registry.
• Adjust Claude API request params for Sonnet 5 compatibility.
• Add unit coverage for temperature omission and thinking disablement.
Diagram

graph TD
  Session["Session (modelName)"] --> ModelValue["getModelValue()"] --> ClaudeSvc["claude-api.mjs"] --> ReqBody["Request body"] --> Anthropic{{"Anthropic /v1/messages"}}
  Config["config/index.mjs Models"] --> ModelValue
  Config --> ClaudeSvc
  Tests["claude-api.test.mjs"] --> ClaudeSvc

  subgraph Legend
    direction LR
    _mod(["Module"]) ~~~ _data["Data"] ~~~ _ext{{"External API"}}
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Model capability map (per-model flags)
  • ➕ Keeps request-shaping logic data-driven (e.g., omitTemperature/disableThinking flags).
  • ➕ Scales better as more models gain special parameter rules.
  • ➕ Easier to test by iterating the map as a single source of truth.
  • ➖ Requires introducing/maintaining a capabilities registry and keeping it in sync with model list.
  • ➖ Slightly more indirection for a single special-case model.
2. Optimistic send + fallback on API error
  • ➕ Avoids hardcoding provider quirks; adapts if provider behavior changes.
  • ➕ Can work for unknown future models without pre-wiring rules.
  • ➖ Adds retry complexity and potentially doubles latency/cost on failures.
  • ➖ Harder to make deterministic in unit tests; error parsing becomes provider-specific.

Recommendation: Current approach (explicit conditionals) is appropriate for a single new model with known constraints, especially with added unit coverage. If additional Claude models start requiring bespoke parameter behavior, consider refactoring to a small capability map keyed by model value to prevent conditionals from growing and to centralize provider-quirk documentation.

Files changed (3) +20 / -2

Enhancement (2) +13 / -1
index.mjsRegister Claude Sonnet 5 model key and metadata +5/-0

Register Claude Sonnet 5 model key and metadata

• Adds 'claudeSonnet5Api' to the Anthropic model key list and to the 'Models' registry with the 'claude-sonnet-5' value and description so it can be selected and displayed.

src/config/index.mjs

claude-api.mjsAdjust Claude request params for Sonnet 5 (omit temperature, disable thinking) +8/-1

Adjust Claude request params for Sonnet 5 (omit temperature, disable thinking)

• Extends temperature omission logic to include 'claude-sonnet-5' and adds a model-gated 'thinking: { type: 'disabled' }' field to prevent default thinking behavior until UI controls exist.

src/services/apis/claude-api.mjs

Tests (1) +7 / -1
claude-api.test.mjsTest Sonnet 5 request parameter behavior +7/-1

Test Sonnet 5 request parameter behavior

• Expands the temperature-omission test matrix to include Sonnet 5 and asserts that only Sonnet 5 sends 'thinking: { type: 'disabled' }' while other models omit the field.

tests/unit/services/apis/claude-api.test.mjs

@gemini-code-assist gemini-code-assist 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.

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.

Comment thread src/services/apis/claude-api.mjs
Comment thread src/services/apis/claude-api.mjs
Comment thread tests/unit/services/apis/claude-api.test.mjs

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 claudeSonnet5Api in the Anthropic API model list and model registry.
  • Updates Claude API request construction to (a) omit temperature for 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.

@qodo-code-review

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Qodo Logo

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

🧹 Nitpick comments (1)
src/services/apis/claude-api.mjs (1)

8-14: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider centralizing per-model behavior flags.

shouldOmitTemperature and shouldDisableDefaultThinking both 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 the Models config entry (e.g., a disableDefaultThinking/omitTemperature boolean 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

📥 Commits

Reviewing files that changed from the base of the PR and between daa1c82 and ef8ec4e.

📒 Files selected for processing (3)
  • src/config/index.mjs
  • src/services/apis/claude-api.mjs
  • tests/unit/services/apis/claude-api.test.mjs

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.

2 participants