Fix reasoning_effort error for GPT-5.1/5.2 in local mode#317
Merged
Conversation
GPT-5.1 and GPT-5.2 reject reasoning_effort: "minimal" with error: "Unsupported value: 'reasoning_effort' does not support 'minimal'". Set reasoning_effort to "low" for these models to avoid the error. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
1 issue found across 1 file
Confidence score: 3/5
- There is a concrete behavior risk in
stagehand/llm/client.py:reasoning_effortis always overridden for GPT-5.1/5.2, even when callers pass valid explicit values like "high" or "medium". - Given the issue’s high severity/confidence (7/10, 9/10), this could cause user-visible regressions in model configuration rather than being a purely internal refactor concern.
- Pay close attention to
stagehand/llm/client.py- ensure the GPT-5.1/5.2 fallback only handles the rejected "minimal" case and preserves valid user-providedreasoning_effortvalues.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="stagehand/llm/client.py">
<violation number="1" location="stagehand/llm/client.py:120">
P1: This unconditionally overrides `reasoning_effort` for GPT-5.1/5.2, even when the user explicitly passes a valid value (e.g., `"high"`, `"medium"`). Since the bug is specifically about `"minimal"` being rejected, only that value should be replaced.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| # GPT-5.1 and GPT-5.2 don't support "minimal" reasoning_effort. | ||
| # Set "low" for these models to avoid OpenAI API errors. | ||
| if "gpt-5.1" in completion_model or "gpt-5.2" in completion_model: | ||
| filtered_params["reasoning_effort"] = "low" |
There was a problem hiding this comment.
P1: This unconditionally overrides reasoning_effort for GPT-5.1/5.2, even when the user explicitly passes a valid value (e.g., "high", "medium"). Since the bug is specifically about "minimal" being rejected, only that value should be replaced.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At stagehand/llm/client.py, line 120:
<comment>This unconditionally overrides `reasoning_effort` for GPT-5.1/5.2, even when the user explicitly passes a valid value (e.g., `"high"`, `"medium"`). Since the bug is specifically about `"minimal"` being rejected, only that value should be replaced.</comment>
<file context>
@@ -114,6 +114,11 @@ async def create_response(
+ # GPT-5.1 and GPT-5.2 don't support "minimal" reasoning_effort.
+ # Set "low" for these models to avoid OpenAI API errors.
+ if "gpt-5.1" in completion_model or "gpt-5.2" in completion_model:
+ filtered_params["reasoning_effort"] = "low"
+
self.logger.debug(
</file context>
Suggested change
| filtered_params["reasoning_effort"] = "low" | |
| if filtered_params.get("reasoning_effort") == "minimal": | |
| filtered_params["reasoning_effort"] = "low" |
Collaborator
There was a problem hiding this comment.
@shrey150 can users pass specific reasoning effort?
Contributor
Author
There was a problem hiding this comment.
no, not possible on v3 nor in v2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
reasoning_effort: "minimal"— valid values arenone, low, medium, high, xhighreasoning_effort: "low"for GPT-5.1/5.2 models in the local mode LLM client (litellm path)Context
Users on v0 SDK hitting this error when using GPT-5.2:
This matches the fix already shipped in the v3 TypeScript core (
aisdk.ts) which differentiates GPT-5.1/5.2 from other GPT-5 models.Note: For API mode (BROWSERBASE) users, the
reasoning_effortis set server-side. Users hitting this in API mode should upgrade tostagehand>=3.6.0which connects to a server with the fix.Test plan
"low"), GPT-5.1 ("low"), GPT-5-nano (no override), GPT-4o (no override)openai/gpt-5.2in LOCAL mode passes🤖 Generated with Claude Code
Summary by cubic
Fixes OpenAI errors for
gpt-5.1andgpt-5.2in local mode by settingreasoning_effortto "low" instead of the unsupported "minimal". Prevents failed requests when using these models via the locallitellmclient.reasoning_effort: "low"only forgpt-5.1andgpt-5.2in local (litellm) mode.gpt-5-nano) are unchanged.stagehand>=3.6.0if you still see the error.Written for commit 6f348f2. Summary will update on new commits. Review in cubic