Skip to content

Refactor model ID checks for GPT 5.x model family#1844

Closed
praveentcom wants to merge 2 commits intobrowserbase:mainfrom
praveentcom:patch-1
Closed

Refactor model ID checks for GPT 5.x model family#1844
praveentcom wants to merge 2 commits intobrowserbase:mainfrom
praveentcom:patch-1

Conversation

@praveentcom
Copy link

@praveentcom praveentcom commented Mar 18, 2026

All GPT-5.x series models don't support minimal as the reasoningEffort. Currently, it is enabled only for GPT-5.1 and GPT-5.2 models to set the reasoningEffort as low. This would start throwing errors like these.

Unsupported value: 'minimal' is not supported with the 'gpt-5.4' model. Supported values are: 'none', 'low', 'medium', 'high', and 'xhigh'.

This PR fixes the behavior to set the reasoning effort as low for all GPT-5.x series models so that we don't need to manually patch it every time when a new SOTA model is released.


Summary by cubic

Set reasoningEffort to "low" for all GPT-5.x models to prevent unsupported "minimal" errors on new releases like gpt-5.4. Use a precise gpt-5. match (not version-specific) and keep codex excluded, removing the need for manual patches.

Written for commit a637dc3. Summary will update on new commits. Review in cubic

@changeset-bot
Copy link

changeset-bot bot commented Mar 18, 2026

⚠️ No Changeset found

Latest commit: a637dc3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions
Copy link
Contributor

This PR is from an external contributor and must be approved by a stagehand team member with write access before CI can run.
Approving the latest commit mirrors it into an internal PR owned by the approver.
If new commits are pushed later, the internal PR stays open but is marked stale until someone approves the latest external commit and refreshes it.

@github-actions github-actions bot added external-contributor Tracks PRs mirrored from external contributor forks. external-contributor:awaiting-approval Waiting for a stagehand team member to approve the latest external commit. labels Mar 18, 2026
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 18, 2026

Greptile Summary

This PR refactors the usesLowReasoningEffort guard in AISdkClient so that all gpt-5.x versioned models automatically receive reasoningEffort: "low" instead of the unsupported "minimal" value, eliminating the need to manually add each new GPT-5 sub-version.

Key changes:

  • Replaced the explicit gpt-5.1 || gpt-5.2 OR-chain with a single includes("gpt-5.") prefix check, which covers all current and future gpt-5.<version> model IDs.
  • The existing !isCodex guard is preserved to keep Codex models on "medium" reasoning effort.

Issues found:

  • A model ID of exactly gpt-5 (no version dot) passes the existing isGPT5 = includes("gpt-5") check (triggering the providerOptions branch) but does not pass the new includes("gpt-5.") check, so it would still fall through to reasoningEffort: "minimal" — the unsupported value this PR is trying to eliminate. If OpenAI ever surfaces a bare gpt-5 alias (a common pattern for their "latest" pointer), this would reproduce the original error.

Confidence Score: 3/5

  • The PR solves the stated problem for versioned gpt-5.x models but leaves a gap for any bare gpt-5 alias, which would still receive the unsupported "minimal" reasoning effort.
  • The core intent is correct and the change is minimal in scope. However, the isGPT5 / usesLowReasoningEffort checks are now misaligned: isGPT5 matches gpt-5 while usesLowReasoningEffort requires gpt-5., meaning a bare gpt-5 model would still trigger the broken "minimal" path that this PR explicitly aims to fix. This is a reproducible logic gap that warrants a fix before merging.
  • packages/core/lib/v3/llm/aisdk.ts — the usesLowReasoningEffort condition on lines 137–139

Important Files Changed

Filename Overview
packages/core/lib/v3/llm/aisdk.ts Broadened usesLowReasoningEffort from explicit gpt-5.1/gpt-5.2 checks to a gpt-5. prefix match — fixes the immediate problem for versioned models, but leaves a gap for a bare gpt-5 model ID (no version dot), which would still receive the unsupported "minimal" reasoning effort.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[LLM Request with GPT-5 model] --> B{isGPT5?\nincludes 'gpt-5'}
    B -- No --> C[providerOptions: undefined]
    B -- Yes --> D{isCodex?\nincludes 'codex'}
    D -- Yes --> E[textVerbosity: 'medium'\nreasoningEffort: 'medium']
    D -- No --> F{usesLowReasoningEffort?\nincludes 'gpt-5.' AND not codex}
    F -- Yes\ngpt-5.1, gpt-5.4, etc. --> G[textVerbosity: 'low'\nreasoningEffort: 'low']
    F -- No\ne.g. bare 'gpt-5' --> H[textVerbosity: 'low'\nreasoningEffort: 'minimal' ⚠️]
    H --> I[API Error: 'minimal' not supported]
Loading

Last reviewed commit: "Fix condition for GP..."

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 1 file

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Add one-off context when rerunning by tagging @cubic-dev-ai with guidance or docs links (including llms.txt)
  • Ask questions if you need clarification on any suggestion

@praveentcom
Copy link
Author

@greptile review

@github-actions github-actions bot added external-contributor:mirrored An internal mirrored PR currently exists for this external contributor PR. and removed external-contributor:awaiting-approval Waiting for a stagehand team member to approve the latest external commit. labels Mar 18, 2026
@github-actions
Copy link
Contributor

This PR was approved by @miguelg719 and mirrored to #1852. All further discussion should happen on that PR.

@github-actions github-actions bot closed this Mar 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external-contributor:mirrored An internal mirrored PR currently exists for this external contributor PR. external-contributor Tracks PRs mirrored from external contributor forks.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants