Skip to content

Add OpenAI's latest GPT-5.4-mini and GPT-5.4-nano model#2266

Merged
naorpeled merged 2 commits intoqodo-ai:mainfrom
PeterDaveHelloKitchen:add-gpt-5-4-mini-nano-support
Mar 21, 2026
Merged

Add OpenAI's latest GPT-5.4-mini and GPT-5.4-nano model#2266
naorpeled merged 2 commits intoqodo-ai:mainfrom
PeterDaveHelloKitchen:add-gpt-5-4-mini-nano-support

Conversation

@qodo-free-for-open-source-projects
Copy link
Copy Markdown
Contributor

Review Summary by Qodo

Add support for GPT-5.4-mini and GPT-5.4-nano models

✨ Enhancement

Grey Divider

Walkthroughs

Description
• Add GPT-5.4-mini model with 400K context window support
• Add GPT-5.4-nano model with 400K context window support
• Add unit tests for both new model variants
• Update GPT-5 model detection tests with new variants
Diagram
flowchart LR
  A["Model Registry"] -->|"Add gpt-5.4-mini"| B["400K Context Window"]
  A -->|"Add gpt-5.4-nano"| C["400K Context Window"]
  D["Test Suite"] -->|"Add unit tests"| E["Max tokens validation"]
  F["GPT-5 Detection"] -->|"Update model list"| G["New variants included"]
Loading

Grey Divider

File Changes

1. pr_agent/algo/__init__.py ✨ Enhancement +2/-0

Register new GPT-5.4 mini and nano models

• Added gpt-5.4-mini model with 400K context window to model registry
• Added gpt-5.4-nano model with 400K context window to model registry
• Both entries include comments indicating 400K limit with potential config restrictions

pr_agent/algo/init.py


2. tests/unittest/test_get_max_tokens.py 🧪 Tests +26/-0

Add max tokens tests for new models

• Added test_gpt54_mini_model_max_tokens test method validating 400K token limit
• Added test_gpt54_nano_model_max_tokens test method validating 400K token limit
• Both tests follow existing GPT-5.4 test pattern with mocked settings

tests/unittest/test_get_max_tokens.py


3. tests/unittest/test_litellm_reasoning_effort.py 🧪 Tests +2/-0

Update GPT-5 model detection test coverage

• Added gpt-5.4-nano to GPT-5 model detection test list
• Added gpt-5.4-mini to GPT-5 model detection test list
• Ensures new variants are recognized in reasoning effort logic

tests/unittest/test_litellm_reasoning_effort.py


Grey Divider

Qodo Logo

@qodo-free-for-open-source-projects
Copy link
Copy Markdown
Contributor

qodo-free-for-open-source-projects bot commented Mar 17, 2026

Code Review by Qodo

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

Grey Divider


Action required

1. Hardcoded gpt-5.4-mini tokens 📘 Rule violation ⛯ Reliability
Description
The PR adds hardcoded model max-token defaults (400000) in Python code instead of sourcing them
from Dynaconf TOML settings. This makes runtime behavior less adjustable and violates the repo’s
configuration management requirement.
Code

pr_agent/algo/init.py[R47-48]

+    'gpt-5.4-mini': 400000,  # 400K, but may be limited by config.max_model_tokens
+    'gpt-5.4-nano': 400000,  # 400K, but may be limited by config.max_model_tokens
Evidence
Compliance requires runtime behavior/configuration (including model/provider settings and
thresholds) to be adjustable via .pr_agent.toml or pr_agent/settings/*.toml, but the PR
introduces new hardcoded model token limits in code.

AGENTS.md
pr_agent/algo/init.py[47-48]

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

## Issue description
New model max-token values for `gpt-5.4-mini` and `gpt-5.4-nano` are hardcoded in Python code, but this repo requires runtime behavior/configuration to be adjustable via `.pr_agent.toml` and/or `pr_agent/settings/*.toml`.
## Issue Context
Model/provider settings and thresholds should live in Dynaconf TOML defaults/overrides so they can be changed without code edits.
## Fix Focus Areas
- pr_agent/algo/__init__.py[47-48]

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



Remediation recommended

2. Single quotes in new tests 📘 Rule violation ✓ Correctness
Description
The newly added unit tests introduce single-quoted strings in multiple places, diverging from the
repository preference for double quotes. This can trigger formatting/lint inconsistencies and reduce
style consistency.
Code

tests/unittest/test_get_max_tokens.py[R39-44]

+        fake_settings = type('', (), {
+            'config': type('', (), {
+                'custom_model_max_tokens': 0,
+                'max_model_tokens': 0
+            })()
+        })()
Evidence
The formatting rule explicitly prefers double quotes; the new test code uses single quotes for
strings (including type('', (), ...) and dict keys), which is a direct style deviation introduced
by this PR.

AGENTS.md
tests/unittest/test_get_max_tokens.py[39-44]

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

## Issue description
New unit test code uses single quotes, but the repository formatting standard prefers double quotes.
## Issue Context
Keeping quoting consistent reduces lint churn and keeps diffs aligned with Ruff/formatter expectations.
## Fix Focus Areas
- tests/unittest/test_get_max_tokens.py[39-44]

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


3. Duplicated fake_settings setup 📘 Rule violation ✓ Correctness
Description
The new tests duplicate the same fake_settings construction logic for both mini and nano cases.
This increases maintenance burden and violates the duplication-reduction guideline.
Code

tests/unittest/test_get_max_tokens.py[R39-56]

+        fake_settings = type('', (), {
+            'config': type('', (), {
+                'custom_model_max_tokens': 0,
+                'max_model_tokens': 0
+            })()
+        })()
+
+        monkeypatch.setattr(utils, "get_settings", lambda: fake_settings)
+
+        assert get_max_tokens("gpt-5.4-mini") == 400000
+
+    def test_gpt54_nano_model_max_tokens(self, monkeypatch):
+        fake_settings = type('', (), {
+            'config': type('', (), {
+                'custom_model_max_tokens': 0,
+                'max_model_tokens': 0
+            })()
+        })()
Evidence
Compliance requires factoring repeated logic into variables/helpers; both new tests repeat the same
nested type(...-based settings stub, which could be extracted to a helper/fixture or parameterized
test.

tests/unittest/test_get_max_tokens.py[39-56]
Best Practice: Learned patterns

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

## Issue description
Two newly added tests duplicate the same `fake_settings` construction and `monkeypatch.setattr(utils, "get_settings", ...)` setup.
## Issue Context
Reducing duplication makes future changes (e.g., adding more config fields) less error-prone and keeps tests consistent.
## Fix Focus Areas
- tests/unittest/test_get_max_tokens.py[39-56]

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


4. Token limit rationale mismatch 🐞 Bug ✓ Correctness
Description
MAX_TOKENS sets gpt-5.4-mini/nano to 400000 while adjacent gpt-5.4 entries are explicitly documented
as a 272000 “safe default without opt-in,” but the new entries don’t explain why they differ.
Because get_max_tokens() directly feeds token-budget decisions (e.g., diff pruning), this
inconsistency makes it easy to misconfigure/overtrust these values later.
Code

pr_agent/algo/init.py[R47-48]

+    'gpt-5.4-mini': 400000,  # 400K, but may be limited by config.max_model_tokens
+    'gpt-5.4-nano': 400000,  # 400K, but may be limited by config.max_model_tokens
Evidence
The same MAX_TOKENS table documents gpt-5.4 as a deliberately conservative 272K “safe default,” yet
gpt-5.4-mini/nano are set to 400K with no similar rationale. get_max_tokens() returns these table
values (unless capped by config), and pr_processing uses get_max_tokens(model) to decide whether to
return the full diff or prune it—so these numbers are operationally significant and should be
internally consistent/justified.

pr_agent/algo/init.py[45-48]
pr_agent/algo/utils.py[991-1012]
pr_agent/algo/pr_processing.py[72-80]

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` documents `gpt-5.4` as a 272K **safe default** but assigns `gpt-5.4-mini`/`gpt-5.4-nano` a 400K limit without explaining the difference. These values are consumed by `get_max_tokens()` and directly influence prompt/diff budgeting decisions.
### Issue Context
This is primarily an internal consistency/operability issue: future maintainers (or config authors) can’t tell whether 400K is intentional, a different policy for mini/nano, or an oversight relative to the documented `gpt-5.4` safe-default approach.
### Fix Focus Areas
- pr_agent/algo/__init__.py[45-48]
- tests/unittest/test_get_max_tokens.py[25-60]

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


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Grey Divider

Previous review results

Review updated until commit 55d4c73

Results up to commit 901b784


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

Grey Divider
Action required
1. Hardcoded gpt-5.4-mini tokens 📘 Rule violation ⛯ Reliability
Description
The PR adds hardcoded model max-token defaults (400000) in Python code instead of sourcing them
from Dynaconf TOML settings. This makes runtime behavior less adjustable and violates the repo’s
configuration management requirement.
Code

pr_agent/algo/init.py[R47-48]

+    'gpt-5.4-mini': 400000,  # 400K, but may be limited by config.max_model_tokens
+    'gpt-5.4-nano': 400000,  # 400K, but may be limited by config.max_model_tokens
Evidence
Compliance requires runtime behavior/configuration (including model/provider settings and
thresholds) to be adjustable via .pr_agent.toml or pr_agent/settings/*.toml, but the PR
introduces new hardcoded model token limits in code.

AGENTS.md
pr_agent/algo/init.py[47-48]

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

## Issue description
New model max-token values for `gpt-5.4-mini` and `gpt-5.4-nano` are hardcoded in Python code, but this repo requires runtime behavior/configuration to be adjustable via `.pr_agent.toml` and/or `pr_agent/settings/*.toml`.

## Issue Context
Model/provider settings and thresholds should live in Dynaconf TOML defaults/overrides so they can be changed without code edits.

## Fix Focus Areas
- pr_agent/algo/__init__.py[47-48]

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



Remediation recommended
2. Single quotes in new tests 📘 Rule violation ✓ Correctness
Description
The newly added unit tests introduce single-quoted strings in multiple places, diverging from the
repository preference for double quotes. This can trigger formatting/lint inconsistencies and reduce
style consistency.
Code

tests/unittest/test_get_max_tokens.py[R39-44]

+        fake_settings = type('', (), {
+            'config': type('', (), {
+                'custom_model_max_tokens': 0,
+                'max_model_tokens': 0
+            })()
+        })()
Evidence
The formatting rule explicitly prefers double quotes; the new test code uses single quotes for
strings (including type('', (), ...) and dict keys), which is a direct style deviation introduced
by this PR.

AGENTS.md
tests/unittest/test_get_max_tokens.py[39-44]

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

## Issue description
New unit test code uses single quotes, but the repository formatting standard prefers double quotes.

## Issue Context
Keeping quoting consistent reduces lint churn and keeps diffs aligned with Ruff/formatter expectations.

## Fix Focus Areas
- tests/unittest/test_get_max_tokens.py[39-44]

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


3. Duplicated fake_settings setup 📘 Rule violation ✓ Correctness
Description
The new tests duplicate the same fake_settings construction logic for both mini and nano cases.
This increases maintenance burden and violates the duplication-reduction guideline.
Code

tests/unittest/test_get_max_tokens.py[R39-56]

+        fake_settings = type('', (), {
+            'config': type('', (), {
+                'custom_model_max_tokens': 0,
+                'max_model_tokens': 0
+            })()
+        })()
+
+        monkeypatch.setattr(utils, "get_settings", lambda: fake_settings)
+
+        assert get_max_tokens("gpt-5.4-mini") == 400000
+
+    def test_gpt54_nano_model_max_tokens(self, monkeypatch):
+        fake_settings = type('', (), {
+            'config': type('', (), {
+                'custom_model_max_tokens': 0,
+                'max_model_tokens': 0
+            })()
+        })()
Evidence
Compliance requires factoring repeated logic into variables/helpers; both new tests repeat the same
nested type(...-based settings stub, which could be extracted to a helper/fixture or parameterized
test.

tests/unittest/test_get_max_tokens.py[39-56]
Best Practice: Learned patterns

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

## Issue description
Two newly added tests duplicate the same `fake_settings` construction and `monkeypatch.setattr(utils, "get_settings", ...)` setup.

## Issue Context
Reducing duplication makes future changes (e.g., adding more config fields) less error-prone and keeps tests consistent.

## Fix Focus Areas
- tests/unittest/test_get_max_tokens.py[39-56]

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


4. Token limit rationale mismatch 🐞 Bug ✧ Quality
Description
MAX_TOKENS sets gpt-5.4-mini/nano to 400000 while adjacent gpt-5.4 entries are explicitly documented
as a 272000 “safe default without opt-in,” but the new entries don’t explain why they differ.
Because get_max_tokens() directly feeds token-budget decisions (e.g., diff pruning), this
inconsistency makes it easy to misconfigure/overtrust these values later.
Code

pr_agent/algo/init.py[R47-48]

+    'gpt-5.4-mini': 400000,  # 400K, but may be limited by config.max_model_tokens
+    'gpt-5.4-nano': 400000,  # 400K, but may be limited by config.max_model_tokens
Evidence
The same MAX_TOKENS table documents gpt-5.4 as a deliberately conservative 272K “safe default,” yet
gpt-5.4-mini/nano are set to 400K with no similar rationale. get_max_tokens() returns these table
values (unless capped by config), and pr_processing uses get_max_tokens(model) to decide whether to
return the full diff or prune it—so these numbers are operationally significant and should be
internally consistent/justified.

pr_agent/algo/init.py[45-48]
pr_agent/algo/utils.py[991-1012]
pr_agent/algo/pr_processing.py[72-80]

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` documents `gpt-5.4` as a 272K **safe default** but assigns `gpt-5.4-mini`/`gpt-5.4-nano` a 400K limit without explaining the difference. These values are consumed by `get_max_tokens()` and directly influence prompt/diff budgeting decisions.

### Issue Context
This is primarily an internal consistency/operability issue: future maintainers (or config authors) can’t tell whether 400K is intentional, a different policy for mini/nano, or an oversight relative to the documented `gpt-5.4` safe-default approach.

### Fix Focus Areas
- pr_agent/algo/__init__.py[45-48]
- tests/unittest/test_get_max_tokens.py[25-60]

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


Grey Divider Grey Divider

Qodo Logo

Add GPT-5.4-mini and its current snapshot to the model registry with the documented 400K context window.

Align the tests with the existing GPT-5.4 model pattern while keeping the change limited to registry and test coverage.
Add GPT-5.4-nano and its current snapshot to the model registry with the documented 400K context window.

Align the tests with the existing GPT-5.4 model pattern while keeping the change limited to registry and test coverage.
@PeterDaveHello PeterDaveHello force-pushed the add-gpt-5-4-mini-nano-support branch from 901b784 to 55d4c73 Compare March 17, 2026 18:33
@qodo-free-for-open-source-projects
Copy link
Copy Markdown
Contributor

qodo-free-for-open-source-projects bot commented Mar 17, 2026

Persistent review updated to latest commit 55d4c73

@naorpeled naorpeled merged commit 74c0062 into qodo-ai:main Mar 21, 2026
2 checks passed
@PeterDaveHello PeterDaveHello deleted the add-gpt-5-4-mini-nano-support branch March 22, 2026 05:43
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