-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat: enable codex models #1666
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: enable codex models #1666
Conversation
Greptile OverviewGreptile SummaryEnabled codex model support in Stagehand by adding special configuration for OpenAI's codex models. Changes applied consistently across both production ( Key Changes:
Review Notes: Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant AISdkClient
participant ModelCheck
participant generateObject
Client->>AISdkClient: createChatCompletion(options)
AISdkClient->>ModelCheck: Check model.modelId
alt contains "gpt-5"
ModelCheck->>ModelCheck: isGPT5 = true
alt contains "codex"
ModelCheck->>ModelCheck: isCodex = true
ModelCheck->>ModelCheck: usesLowReasoningEffort = false
Note over ModelCheck: Codex models excluded from low reasoning
else contains "gpt-5.1" or "gpt-5.2"
ModelCheck->>ModelCheck: isCodex = false
ModelCheck->>ModelCheck: usesLowReasoningEffort = true
else other gpt-5 variant
ModelCheck->>ModelCheck: isCodex = false
ModelCheck->>ModelCheck: usesLowReasoningEffort = false
end
ModelCheck->>generateObject: Call with providerOptions
alt isCodex = true
Note over generateObject: textVerbosity: "medium"<br/>reasoningEffort: "medium"
else usesLowReasoningEffort = true
Note over generateObject: textVerbosity: "low"<br/>reasoningEffort: "low"
else default
Note over generateObject: textVerbosity: "low"<br/>reasoningEffort: "minimal"
end
else not gpt-5
ModelCheck->>generateObject: Call without providerOptions
Note over generateObject: Uses model defaults
end
generateObject-->>AISdkClient: objectResponse
AISdkClient-->>Client: Return result
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 files reviewed, 2 comments
| reasoningEffort: isCodex | ||
| ? "medium" | ||
| : usesLowReasoningEffort | ||
| ? "low" | ||
| : "minimal", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logic bug: codex models that are gpt-5 (not gpt-5.1 or gpt-5.2) will get reasoningEffort: "minimal" instead of "medium". The ternary checks isCodex first, but if the model is gpt-5-codex, usesLowReasoningEffort is false (doesn't match gpt-5.1 or gpt-5.2), so it falls through to "minimal".
| reasoningEffort: isCodex | |
| ? "medium" | |
| : usesLowReasoningEffort | |
| ? "low" | |
| : "minimal", | |
| reasoningEffort: isCodex | |
| ? "medium" | |
| : usesLowReasoningEffort | |
| ? "low" | |
| : "minimal", |
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/core/lib/v3/llm/aisdk.ts
Line: 175:179
Comment:
Logic bug: codex models that are `gpt-5` (not `gpt-5.1` or `gpt-5.2`) will get `reasoningEffort: "minimal"` instead of `"medium"`. The ternary checks `isCodex` first, but if the model is `gpt-5-codex`, `usesLowReasoningEffort` is false (doesn't match `gpt-5.1` or `gpt-5.2`), so it falls through to `"minimal"`.
```suggestion
reasoningEffort: isCodex
? "medium"
: usesLowReasoningEffort
? "low"
: "minimal",
```
How can I resolve this? If you propose a fix, please make it concise.| reasoningEffort: isCodex | ||
| ? "medium" | ||
| : usesLowReasoningEffort | ||
| ? "low" | ||
| : "minimal", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same logic bug as in aisdk.ts: codex models that are gpt-5 (not gpt-5.1 or gpt-5.2) will get reasoningEffort: "minimal" instead of "medium".
| reasoningEffort: isCodex | |
| ? "medium" | |
| : usesLowReasoningEffort | |
| ? "low" | |
| : "minimal", | |
| reasoningEffort: isCodex | |
| ? "medium" | |
| : usesLowReasoningEffort | |
| ? "low" | |
| : "minimal", |
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/evals/lib/AISdkClientWrapped.ts
Line: 152:156
Comment:
Same logic bug as in `aisdk.ts`: codex models that are `gpt-5` (not `gpt-5.1` or `gpt-5.2`) will get `reasoningEffort: "minimal"` instead of `"medium"`.
```suggestion
reasoningEffort: isCodex
? "medium"
: usesLowReasoningEffort
? "low"
: "minimal",
```
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 issue found across 2 files
Confidence score: 4/5
- The main risk is a new hardcoded model name check (
isCodex) inpackages/core/lib/v3/llm/aisdk.ts, which violates the rule against hardcoded LLM model name checks and could cause future model handling regressions. - Severity is moderate (5/10) with good confidence, so this looks safe to merge with a small policy-compliance concern rather than a likely runtime break.
- Pay close attention to
packages/core/lib/v3/llm/aisdk.ts- hardcoded model name check violates the no-list rule.
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="packages/core/lib/v3/llm/aisdk.ts">
<violation number="1" location="packages/core/lib/v3/llm/aisdk.ts:133">
P2: Rule violated: **Ensure we never check against hardcoded lists of allowed LLM model names**
This adds a new hardcoded model name check (`isCodex`) which violates the rule against hardcoded LLM model name checks. The rule states newly added code should accept any model name and let the provider handle errors. The exception only applies to guarding *against* known-bad models, not special-casing to enable models.
Consider an alternative approach such as:
- Letting the API return an error for unsupported configurations, then handling it
- Using a model capabilities/metadata system
- Adding a configuration option for these parameters rather than inferring from model name</violation>
</file>
Architecture diagram
sequenceDiagram
participant App as Stagehand Application
participant Client as AISdkClient / Wrapped
participant SDK as AI SDK (generateObject)
participant OpenAI as OpenAI API
App->>Client: Request LLM Extraction (modelId, response_model)
Note over Client: Internal Model Classification
Client->>Client: Check modelId for "gpt-5" and "codex"
alt NEW: Model is Codex-based
Note over Client: Set specific Codex requirements
Client->>Client: Set textVerbosity: "medium"
Client->>Client: Set reasoningEffort: "medium"
else Model is Standard GPT-5
Note over Client: Apply default GPT-5 constraints
Client->>Client: Set textVerbosity: "low"
alt modelId is 5.1 or 5.2
Client->>Client: Set reasoningEffort: "low"
else
Client->>Client: Set reasoningEffort: "minimal"
end
end
Client->>SDK: generateObject(prompt, schema, providerOptions)
Note right of SDK: Includes OpenAI-specific<br/>textVerbosity & reasoningEffort
SDK->>OpenAI: POST /v1/chat/completions
OpenAI-->>SDK: JSON Response
SDK-->>Client: Typed Object
Client-->>App: Extraction Result
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| (this.model.modelId.includes("gpt-5.1") || | ||
| this.model.modelId.includes("gpt-5.2")) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can these be consolidated into includes gpt-5.?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think so, will test if gpt-5-2025-08-07 also has the same reasoning requirements
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gpt 5 reasoning requirement is different
a926fad to
5b5b831
Compare
|
why
people want to try codex models in Stagehand (also see benchmarks)
what changed
Codex needs a text verbosity and reasoning effort of medium (not low) so we set this using a conditional operator.
test plan
Ran evals
Summary by cubic
Enables Codex models in Stagehand via the AI SDK by setting OpenAI provider options. Addresses STG-1324. Codex uses medium text verbosity and medium reasoning effort; gpt-5 non-Codex defaults stay the same.
Written for commit 5b5b831. Summary will update on new commits. Review in cubic