Skip to content

Add newly released Claude Sonnet 5 model support - #2486

Merged
naorpeled merged 1 commit into
The-PR-Agent:mainfrom
PeterDaveHello:add-claude-sonnet-5
Jul 1, 2026
Merged

naorpeled merged 1 commit into
The-PR-Agent:mainfrom
PeterDaveHello:add-claude-sonnet-5

Conversation

@PeterDaveHello

Copy link
Copy Markdown
Contributor

Add Sonnet 5 model limits and request-parameter handling for the new Anthropic model.

This assumes the LiteLLM dependency is updated before release, so the new bare Anthropic model ID resolves through the provider catalog.

Keep Sonnet 5 out of manual extended thinking and strip non-default temperature parameters to match Anthropic's launch behavior.

References:

@qodo-free-for-open-source-projects

Copy link
Copy Markdown
Contributor

PR Summary by Qodo

Add Claude Sonnet 5 support (limits + request parameter rules)

✨ Enhancement 🧪 Tests 🕐 10-20 Minutes

Grey Divider

AI Description

• Add Claude Sonnet 5 max-token limits across Anthropic, Vertex AI, and Bedrock model IDs.
• Treat Sonnet 5 as no-temperature / no-extended-thinking to match Anthropic launch behavior.
• Add unit tests validating token limits and LiteLLM request kwarg stripping.
Diagram

graph TD
  A["PR-Agent core"] --> B["utils.get_max_tokens()"] --> C[(MAX_TOKENS)]
  A --> D["LiteLLMAIHandler.chat_completion()"] --> E[(NO_SUPPORT_TEMPERATURE_MODELS)] --> F{{"LiteLLM acompletion"}}

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

The following are alternative approaches to this PR:

1. Prefix/pattern-based model handling
  • ➕ Reduces maintenance vs enumerating every provider/region model ID string
  • ➕ Automatically covers future Bedrock region prefixes without adding new entries
  • ➖ Risk of false positives if other models match similar substrings
  • ➖ Harder to audit exact supported IDs; may mask provider-specific edge cases
2. Centralized model metadata registry (YAML/JSON)
  • ➕ Separates data (limits/capabilities) from code; simpler to update on model launches
  • ➕ Enables validation tooling (e.g., lint for duplicate/missing variants)
  • ➖ Adds another config surface and loading path
  • ➖ Still requires keeping provider ID variants in sync unless paired with pattern rules
3. Defer capability/limit lookup to LiteLLM/provider catalog
  • ➕ Single source of truth if LiteLLM reliably exposes context window + parameter support
  • ➕ Minimizes hardcoded model lists in PR-Agent
  • ➖ May not expose all needed semantics (e.g., “strip non-default temperature”) consistently
  • ➖ Introduces runtime dependency on LiteLLM catalog behavior/version

Recommendation: The current explicit enumeration is a safe, low-risk way to ship Sonnet 5 support quickly and keeps behavior consistent with existing Claude model handling. If the list of Bedrock regional IDs continues to grow, consider a follow-up refactor to prefix/pattern-based matching (with tight unit tests) or a small metadata registry to reduce future maintenance.

Files changed (3) +90 / -0

Enhancement (1) +18 / -0
__init__.pyRegister Claude Sonnet 5 limits and capability flags +18/-0

Register Claude Sonnet 5 limits and capability flags

• Adds 1,000,000 max-token entries for Claude Sonnet 5 across Anthropic, Vertex AI, and multiple Bedrock ID variants. Also adds Sonnet 5 IDs to the no-temperature model list so non-default temperature is stripped at request time.

pr_agent/algo/init.py

Tests (2) +72 / -0
test_get_max_tokens.pyTest max token resolution for Claude Sonnet 5 IDs +26/-0

Test max token resolution for Claude Sonnet 5 IDs

• Introduces a parametrized unit test asserting get_max_tokens() returns 1,000,000 for all supported Sonnet 5 provider ID variants.

tests/unittest/test_get_max_tokens.py

test_litellm_chat_completion_core.pyTest Sonnet 5 request shaping (strip temperature, no extended thinking) +46/-0

Test Sonnet 5 request shaping (strip temperature, no extended thinking)

• Adds async tests ensuring LiteLLM chat_completion() removes the temperature kwarg for Sonnet 5 and does not attach extended-thinking parameters even when enabled in config.

tests/unittest/test_litellm_chat_completion_core.py

@PeterDaveHello

Copy link
Copy Markdown
Contributor Author

LiteLLM Claude Sonnet 5 support PR: BerriAI/litellm#31740

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (2) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Missing Bedrock APAC ID 🐞 Bug ≡ Correctness ⭐ New
Description
Bedrock Sonnet 5 is added for several regions but the APAC variant
(bedrock/apac.anthropic.claude-sonnet-5) is missing from MAX_TOKENS and
NO_SUPPORT_TEMPERATURE_MODELS, so get_max_tokens() will raise for that model string and
chat_completion() won’t strip temperature for it. This breaks Sonnet 5 support for APAC even though
APAC Bedrock IDs are supported for other Claude models in the same file.
Code

pr_agent/algo/init.py[R241-245]

+    "bedrock/us.anthropic.claude-sonnet-5": 1000000,
+    "bedrock/au.anthropic.claude-sonnet-5": 1000000,
+    "bedrock/eu.anthropic.claude-sonnet-5": 1000000,
+    "bedrock/jp.anthropic.claude-sonnet-5": 1000000,
+    "bedrock/global.anthropic.claude-sonnet-5": 1000000,
Evidence
The repository already treats bedrock/apac.* model IDs as first-class entries in MAX_TOKENS, but
Sonnet 5 only adds us/au/eu/jp/global variants; absent keys cause get_max_tokens() to raise, and the
handler strips temperature only when the model string exactly matches an entry in
NO_SUPPORT_TEMPERATURE_MODELS.

pr_agent/algo/init.py[218-245]
pr_agent/algo/init.py[308-348]
pr_agent/algo/utils.py[992-1013]
pr_agent/algo/ai_handlers/litellm_ai_handler.py[489-492]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`bedrock/apac.anthropic.claude-sonnet-5` is not included in the new Sonnet 5 token-limit mappings nor in the temperature-stripping allowlist. This causes `get_max_tokens()` to throw for APAC Bedrock Sonnet 5 model IDs and causes `LiteLLMAIHandler.chat_completion()` to incorrectly include `temperature` for that region.

### Issue Context
The codebase already supports APAC-prefixed Bedrock Anthropic model IDs for other Claude models, and both `get_max_tokens()` and temperature stripping rely on exact string matching.

### Fix Focus Areas
- pr_agent/algo/__init__.py[218-245]
- pr_agent/algo/__init__.py[308-354]
- tests/unittest/test_get_max_tokens.py[242-255]
- tests/unittest/test_litellm_chat_completion_core.py[103-117]

### Expected change
1. Add `"bedrock/apac.anthropic.claude-sonnet-5": 1000000` to `MAX_TOKENS`.
2. Add `"bedrock/apac.anthropic.claude-sonnet-5"` to `NO_SUPPORT_TEMPERATURE_MODELS`.
3. Extend the new Sonnet 5 parametrized tests to include the APAC model ID, matching the pattern used for other Claude Bedrock models.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Missing Bedrock v1:0 IDs 🐞 Bug ≡ Correctness
Description
Bedrock configuration docs use model IDs with the “-v1:0” suffix, but Sonnet 5 is only added for
non-suffixed Bedrock IDs, so get_max_tokens() will not recognize “bedrock/...-v1:0” and can raise at
runtime. The temperature-stripping allowlist also won’t match “-v1:0” Sonnet 5 IDs, so the handler
will send a temperature parameter for those Bedrock configurations.
Code

pr_agent/algo/init.py[187]

+    'bedrock/anthropic.claude-sonnet-5': 1000000,
Evidence
The repo documentation demonstrates Bedrock model IDs with “-v1:0”, while get_max_tokens() only
recognizes exact keys in MAX_TOKENS and raises otherwise; Sonnet 5 additions include only
non-suffixed Bedrock IDs and the temperature stripping list likewise omits any “-v1:0” Sonnet 5
entries.

docs/docs/usage-guide/changing_a_model.md[246-254]
pr_agent/algo/utils.py[992-1013]
pr_agent/algo/init.py[166-188]
pr_agent/algo/init.py[308-348]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Bedrock model IDs are often configured in this repo using a `-v1:0` suffix (per docs), but the PR only adds Sonnet 5 support for non-suffixed Bedrock IDs. This causes `get_max_tokens()` lookup failures (exception) and bypasses temperature stripping for the `-v1:0` IDs.
### Issue Context
- `get_max_tokens()` requires an exact string match in `MAX_TOKENS` (otherwise it raises unless `custom_model_max_tokens > 0`).
- The repo’s Bedrock docs demonstrate the `-v1:0` naming convention.
### Fix Focus Areas
- pr_agent/algo/__init__.py[166-245]
- pr_agent/algo/__init__.py[308-348]
- tests/unittest/test_get_max_tokens.py[242-267]
- tests/unittest/test_litellm_chat_completion_core.py[103-128]
### What to change
1. Add `MAX_TOKENS` entries for Bedrock Sonnet 5 `-v1:0` variants (at least `bedrock/anthropic.claude-sonnet-5-v1:0`, and any regional variants you intend to support).
2. Add the same `-v1:0` variants to `NO_SUPPORT_TEMPERATURE_MODELS`.
3. Extend unit tests to include at least one `-v1:0` Sonnet 5 Bedrock model string to prevent regressions.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

  • Author self-review: I have reviewed the code review findings, and addressed the relevant ones.

Previous review results

Review updated until commit cd3f052

Results up to commit 22faeac


🐞 Bugs (1) 📘 Rule violations (0) 📜 Skill insights (0)


Action required
1. Missing Bedrock v1:0 IDs 🐞 Bug ≡ Correctness
Description
Bedrock configuration docs use model IDs with the “-v1:0” suffix, but Sonnet 5 is only added for
non-suffixed Bedrock IDs, so get_max_tokens() will not recognize “bedrock/...-v1:0” and can raise at
runtime. The temperature-stripping allowlist also won’t match “-v1:0” Sonnet 5 IDs, so the handler
will send a temperature parameter for those Bedrock configurations.
Code

pr_agent/algo/init.py[187]

+    'bedrock/anthropic.claude-sonnet-5': 1000000,
Evidence
The repo documentation demonstrates Bedrock model IDs with “-v1:0”, while get_max_tokens() only
recognizes exact keys in MAX_TOKENS and raises otherwise; Sonnet 5 additions include only
non-suffixed Bedrock IDs and the temperature stripping list likewise omits any “-v1:0” Sonnet 5
entries.

docs/docs/usage-guide/changing_a_model.md[246-254]
pr_agent/algo/utils.py[992-1013]
pr_agent/algo/init.py[166-188]
pr_agent/algo/init.py[308-348]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
Bedrock model IDs are often configured in this repo using a `-v1:0` suffix (per docs), but the PR only adds Sonnet 5 support for non-suffixed Bedrock IDs. This causes `get_max_tokens()` lookup failures (exception) and bypasses temperature stripping for the `-v1:0` IDs.

### Issue Context
- `get_max_tokens()` requires an exact string match in `MAX_TOKENS` (otherwise it raises unless `custom_model_max_tokens > 0`).
- The repo’s Bedrock docs demonstrate the `-v1:0` naming convention.

### Fix Focus Areas
- pr_agent/algo/__init__.py[166-245]
- pr_agent/algo/__init__.py[308-348]
- tests/unittest/test_get_max_tokens.py[242-267]
- tests/unittest/test_litellm_chat_completion_core.py[103-128]

### What to change
1. Add `MAX_TOKENS` entries for Bedrock Sonnet 5 `-v1:0` variants (at least `bedrock/anthropic.claude-sonnet-5-v1:0`, and any regional variants you intend to support).
2. Add the same `-v1:0` variants to `NO_SUPPORT_TEMPERATURE_MODELS`.
3. Extend unit tests to include at least one `-v1:0` Sonnet 5 Bedrock model string to prevent regressions.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Qodo Logo

Comment thread pr_agent/algo/__init__.py Resolved
Add Sonnet 5 model limits and request-parameter handling for the new
Anthropic model.

This assumes the LiteLLM dependency is updated before release so the new
bare Anthropic model ID resolves through the provider catalog.

Leave Sonnet 5 on its default adaptive thinking behavior instead of
enabling manual extended thinking, and strip non-default temperature
parameters to match Anthropic's launch behavior.

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
- https://platform.claude.com/docs/en/build-with-claude/claude-in-amazon-bedrock
Comment thread pr_agent/algo/__init__.py Resolved
@qodo-free-for-open-source-projects

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit cd3f052

@naorpeled
naorpeled merged commit 4263175 into The-PR-Agent:main Jul 1, 2026
5 checks passed
@PeterDaveHello
PeterDaveHello deleted the add-claude-sonnet-5 branch September 18, 2026 16:33
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