Skip to content

fix: add claude-opus-4-7 to NO_SUPPORT_TEMPERATURE_MODELS (#2400)#2448

Open
raywcm wants to merge 1 commit into
The-PR-Agent:mainfrom
raywcm:fix/claude-opus-4-7-temperature-support
Open

fix: add claude-opus-4-7 to NO_SUPPORT_TEMPERATURE_MODELS (#2400)#2448
raywcm wants to merge 1 commit into
The-PR-Agent:mainfrom
raywcm:fix/claude-opus-4-7-temperature-support

Conversation

@raywcm

@raywcm raywcm commented Jun 15, 2026

Copy link
Copy Markdown

Fixes #2400

Description

When using Claude Opus 4-7 models (via Anthropic, Vertex AI, or Bedrock), PR-Agent sends the temperature parameter which Anthropic has deprecated for these models, causing every command to fail with a 400 error:

temperature is deprecated for this model.

Changes Made

  1. Added all Claude Opus 4-7 model variants to NO_SUPPORT_TEMPERATURE_MODELS in pr_agent/algo/__init__.py:

    • claude-opus-4-7
    • vertex_ai/claude-opus-4-7
    • anthropic/claude-opus-4-7
    • bedrock/anthropic.claude-opus-4-7
    • bedrock/anthropic.claude-opus-4-7-v1:0
    • bedrock/us.anthropic.claude-opus-4-7
    • bedrock/global.anthropic.claude-opus-4-7
  2. Added bedrock/anthropic.claude-opus-4-7-v1:0 to MAX_TOKENS (same token limit as the non--v1:0 variant) so that get_max_tokens() does not crash when this model ID is configured.

The fix follows the existing pattern used for the Claude Opus 4-8 variants already in NO_SUPPORT_TEMPERATURE_MODELS. The LiteLLMAIHandler already skips sending the temperature parameter for any model in this list.

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

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

Copy link
Copy Markdown
Contributor

Code Review by Qodo

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

Context used

Grey Divider


Remediation recommended

1. No tests for claude-opus-4-7 📘 Rule violation ⚙ Maintainability
Description
This PR changes runtime behavior by adding claude-opus-4-7 variants to
NO_SUPPORT_TEMPERATURE_MODELS, but no unit tests were added/updated to verify temperature is
omitted for these models. Without coverage, this regression-prone behavior may break again and
reintroduce the 400 error.
Code

pr_agent/algo/init.py[R314-321]

+    # Anthropic Claude Opus 4-7 — temperature is deprecated (Issue #2400)
+    "claude-opus-4-7",
+    "vertex_ai/claude-opus-4-7",
+    "anthropic/claude-opus-4-7",
+    "bedrock/anthropic.claude-opus-4-7",
+    "bedrock/anthropic.claude-opus-4-7-v1:0",
+    "bedrock/us.anthropic.claude-opus-4-7",
+    "bedrock/global.anthropic.claude-opus-4-7",
Evidence
Rule 16 requires adding/updating pytest tests when behavior changes. The PR modifies
NO_SUPPORT_TEMPERATURE_MODELS to include claude-opus-4-7 variants, and LiteLLMAIHandler uses
this list to decide whether to attach kwargs["temperature"]; however, no corresponding unit test
was added alongside existing similar tests (e.g., for claude-opus-4-8) to assert temperature is
omitted for the new claude-opus-4-7 entries.

AGENTS.md: Add/Update Tests and Place Them in the Correct Pytest Suite Directory
pr_agent/algo/init.py[314-321]
pr_agent/algo/ai_handlers/litellm_ai_handler.py[472-480]
tests/unittest/test_litellm_chat_completion_core.py[76-101]

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

## Issue description
The PR adds multiple `claude-opus-4-7` model IDs to `NO_SUPPORT_TEMPERATURE_MODELS` so `LiteLLMAIHandler` skips sending `temperature`, but there is no unit test asserting that `temperature` is not included in the LiteLLM `acompletion()` kwargs for these models.

## Issue Context
There are already unit tests asserting `temperature` behavior for the `claude-opus-4-8` family; this change should add similar coverage for the `claude-opus-4-7` family to prevent regressions.

## Fix Focus Areas
- pr_agent/algo/__init__.py[314-321]
- pr_agent/algo/ai_handlers/litellm_ai_handler.py[472-480]
- tests/unittest/test_litellm_chat_completion_core.py[76-101]

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



Informational

2. Untested MAX_TOKENS entry 🐞 Bug ⚙ Maintainability
Description
A new MAX_TOKENS key (bedrock/anthropic.claude-opus-4-7-v1:0) was added, but the Claude Opus 4-7
max-tokens unit test does not include this variant, so future accidental removal/rename would not be
caught. This is a maintainability/regression-coverage gap rather than a functional bug today.
Code

pr_agent/algo/init.py[170]

+    'bedrock/anthropic.claude-opus-4-7-v1:0': 1000000,
Evidence
The PR introduces a new MAX_TOKENS entry for bedrock/anthropic.claude-opus-4-7-v1:0, but the
unit test that enumerates Claude Opus 4-7 variants omits this identifier, so that new case is not
exercised by tests.

pr_agent/algo/init.py[161-172]
tests/unittest/test_get_max_tokens.py[196-206]

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

### Issue description
`MAX_TOKENS` now includes the model id `bedrock/anthropic.claude-opus-4-7-v1:0`, but the existing `test_claude_opus_4_7_model_max_tokens` parametrization doesn’t cover it. This reduces regression protection for the newly-supported identifier.

### Issue Context
The PR explicitly added this model id to prevent `get_max_tokens()` from raising for that configuration. Adding it to the existing 4-7 parameter list will lock the intended behavior.

### Fix Focus Areas
- tests/unittest/test_get_max_tokens.py[196-206]

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


Grey Divider

Qodo Logo

@github-actions github-actions Bot added the bug label Jun 15, 2026
@qodo-free-for-open-source-projects

Copy link
Copy Markdown
Contributor

PR Summary by Qodo

Fix: skip temperature for Claude Opus 4-7 model IDs and add Bedrock v1:0 max tokens
🐞 Bug fix 🕐 Less than 10 minutes

Grey Divider

Walkthroughs

Description
• Add Claude Opus 4-7 model variants to the no-temperature allowlist to avoid Anthropic 400s.
• Register Bedrock Opus 4-7 v1:0 in MAX_TOKENS to prevent get_max_tokens() crashes.
Diagram
graph TD
  Cfg["pr_agent/algo/__init__.py (model caps)"] --> H(["LiteLLMAIHandler"] ) --> P{{"LLM provider APIs"}}
  H -->|"omit temperature"| P
  subgraph Legend
    direction LR
    _cfg["Config/constants"] ~~~ _svc(["Handler/service"]) ~~~ _ext{{"External API"}}
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Prefix/regex-based model family matching
  • ➕ Avoids enumerating every provider-specific Opus 4-7 variant (incl. future suffixes like -v1:0).
  • ➕ Reduces maintenance when new region-scoped Bedrock IDs appear.
  • ➖ Risk of false positives/negatives if other models share similar prefixes or providers change naming conventions.
  • ➖ Harder to reason about and audit compared to an explicit list.
2. Provider capability discovery (via SDK / LiteLLM metadata)
  • ➕ Single source of truth for which parameters are supported per model.
  • ➕ Automatically adapts to vendor deprecations/rollouts.
  • ➖ Adds runtime dependency on metadata availability/accuracy.
  • ➖ More complex integration and testing; may not be supported uniformly across providers.

Recommendation: The explicit enumeration is appropriate for a targeted hotfix and matches the existing pattern used for Opus 4-8. If Opus model variants continue proliferating, consider augmenting with a conservative prefix-based matcher specifically for known providers (e.g., Bedrock 'bedrock/claude-opus-4-7') to reduce future churn while keeping the explicit list as an override/escape hatch.

Grey Divider

File Changes

Bug fix (1)
__init__.py Add Claude Opus 4-7 to no-temperature models and register Bedrock v1:0 tokens +10/-1

Add Claude Opus 4-7 to no-temperature models and register Bedrock v1:0 tokens

• Adds Bedrock 'anthropic.claude-opus-4-7-v1:0' to MAX_TOKENS to match the existing Opus 4-7 limit and avoid failures in get_max_tokens(). Extends NO_SUPPORT_TEMPERATURE_MODELS with Claude Opus 4-7 variants (Anthropic/Vertex AI/Bedrock, including region-scoped and v1:0 IDs) so the handler omits the deprecated temperature parameter.

pr_agent/algo/init.py


Grey Divider

Qodo Logo

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] temperature parameter sent to claude-opus-4-7 causes 400 from Anthropic

1 participant