Fix: Add claude-opus-4-7 to NO_SUPPORT_TEMPERATURE_MODELS (#2400)#2409
Fix: Add claude-opus-4-7 to NO_SUPPORT_TEMPERATURE_MODELS (#2400)#2409utsab345 wants to merge 1 commit into
Conversation
Review Summary by QodoAdd claude-opus-4-7 variants to NO_SUPPORT_TEMPERATURE_MODELS
WalkthroughsDescription• Add Claude Opus 4-7 model variants to temperature exclusion list • Fixes 400 error from Anthropic deprecating temperature parameter • Covers all provider variants: Vertex AI, Anthropic, Bedrock • Follows existing pattern for unsupported temperature models Diagramflowchart LR
A["Claude Opus 4-7 Models"] -->|"Add to exclusion list"| B["NO_SUPPORT_TEMPERATURE_MODELS"]
B -->|"LiteLLMAIHandler skips"| C["Temperature Parameter"]
C -->|"Prevents"| D["400 BadRequestError"]
File Changes1. pr_agent/algo/__init__.py
|
Code Review by Qodo
Context used 1. Model lists inconsistent
|
| "claude-3-7-opus", | ||
| "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", |
There was a problem hiding this comment.
1. Model lists inconsistent 🐞 Bug ≡ Correctness
NO_SUPPORT_TEMPERATURE_MODELS now includes model IDs that are not present in MAX_TOKENS, so configuring those models will still crash in get_max_tokens() (even though temperature is skipped). This specifically affects bedrock/anthropic.claude-opus-4-7-v1:0 and the newly-added aliases claude-3-7-opus and claude-opus-4.7.
Agent Prompt
## Issue description
Several newly added entries in `NO_SUPPORT_TEMPERATURE_MODELS` are not recognized by the rest of the system because they are missing from `MAX_TOKENS`. When a user configures one of these models, PR-Agent will raise an exception in `get_max_tokens()` before making any LLM request.
## Issue Context
- `get_max_tokens(model)` hard-fails when `model` is not in `MAX_TOKENS` and no `config.custom_model_max_tokens` is set.
- The PR added `bedrock/anthropic.claude-opus-4-7-v1:0` (and some additional aliases) to `NO_SUPPORT_TEMPERATURE_MODELS`, but did not add corresponding `MAX_TOKENS` entries.
## Fix Focus Areas
- pr_agent/algo/__init__.py[278-307]
- pr_agent/algo/__init__.py[150-160]
- pr_agent/algo/utils.py[992-1010]
## Suggested fix
1. Add missing `MAX_TOKENS` entries for the newly-added model IDs that are intended to be supported (at minimum `bedrock/anthropic.claude-opus-4-7-v1:0` should map to the same token limit as `bedrock/anthropic.claude-opus-4-7`).
2. For `claude-3-7-opus` and `claude-opus-4.7`, either:
- add them to `MAX_TOKENS` with the correct limits if they are valid model names in this project, or
- remove them from `NO_SUPPORT_TEMPERATURE_MODELS` if they are typos / not supported.
3. (Optional but recommended) Add/extend a unit test similar to `test_claude_opus_4_7_model_max_tokens` to cover the `-v1:0` Bedrock variant if you keep it.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
There was a problem hiding this comment.
Thank you for the review. The issue about inconsistent model lists has been resolved.
The missing models have been added to MAX_TOKENS in commit 80aa7ac:
claude-3-7-opus: 200,000 tokensclaude-opus-4.7: 1,000,000 tokensbedrock/anthropic.claude-opus-4-7-v1:0: 1,000,000 tokens
All Claude Opus 4-7 variants are now present in both MAX_TOKENS (for token calculation) and NO_SUPPORT_TEMPERATURE_MODELS (to skip temperature parameter). This ensures get_max_tokens() works correctly when these models are configured.
The token limits are based on Anthropic's official documentation:
- Claude Opus 4-7: 1,000,000 token context window
- Claude 3.7 Opus: 200,000 token context window
The change maintains consistency between both lists and follows the existing pattern for model configuration.
Please review the updated PR. Thank you.
e5460ca to
80aa7ac
Compare
|
Persistent review updated to latest commit 80aa7ac |
Fix: Add claude-opus-4-7 to NO_SUPPORT_TEMPERATURE_MODELS
Problem Description
Fixes issue #2400
When using Claude Opus 4-7 models (via Vertex AI, Anthropic, or Bedrock), PR-Agent fails with a 400 error because Anthropic has deprecated the
temperatureparameter for these models.Error message: itellm.BadRequestError: Vertex_aiException BadRequestError -
{"type":"error","error":{"type":"invalid_request_error","message":"temperature is deprecated for this model."}}
Affected models:
Solution
Added all Claude Opus 4-7 model variants to the existing
NO_SUPPORT_TEMPERATURE_MODELSlist inpr_agent/algo/__init__.py.This follows the same pattern used for other models that don't support temperature (o1, o3, gpt-5-mini, etc.). The
LiteLLMAIHandleralready has logic to skip sending the temperature parameter for any model in this list.Changes Made
File changed:
pr_agent/algo/__init__.pyAdded to
NO_SUPPORT_TEMPERATURE_MODELS: