Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/cold-onions-refuse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@browserbasehq/stagehand": patch
---

add support for codex models
14 changes: 10 additions & 4 deletions packages/core/lib/v3/llm/aisdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,11 @@ export class AISdkClient extends LLMClient {

let objectResponse: Awaited<ReturnType<typeof generateObject>>;
const isGPT5 = this.model.modelId.includes("gpt-5");
const isCodex = this.model.modelId.includes("codex");
const usesLowReasoningEffort =
this.model.modelId.includes("gpt-5.1") ||
this.model.modelId.includes("gpt-5.2");
(this.model.modelId.includes("gpt-5.1") ||
this.model.modelId.includes("gpt-5.2")) &&
Comment on lines +135 to +136
Copy link
Collaborator

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.?

Copy link
Member Author

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

Copy link
Member Author

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

!isCodex;
const isDeepSeek = this.model.modelId.includes("deepseek");
// Kimi models only support temperature=1
const isKimi = this.model.modelId.includes("kimi");
Expand Down Expand Up @@ -173,8 +175,12 @@ You must respond in JSON format. respond WITH JSON. Do not include any other tex
providerOptions: isGPT5
? {
openai: {
textVerbosity: "low", // Making these the default for gpt-5 for now
reasoningEffort: usesLowReasoningEffort ? "low" : "minimal",
textVerbosity: isCodex ? "medium" : "low", // codex models only support 'medium'
reasoningEffort: isCodex
? "medium"
: usesLowReasoningEffort
? "low"
: "minimal",
Comment on lines +179 to +183
Copy link
Contributor

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".

Suggested change
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.

},
}
: undefined,
Expand Down
15 changes: 10 additions & 5 deletions packages/evals/lib/AISdkClientWrapped.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,15 @@ export class AISdkClientWrapped extends LLMClient {

let objectResponse: Awaited<ReturnType<typeof generateObject>>;
const isGPT5 = this.model.modelId.includes("gpt-5");
const isCodex = this.model.modelId.includes("codex");
const usesLowReasoningEffort =
this.model.modelId.includes("gpt-5.1") ||
this.model.modelId.includes("gpt-5.2");
(this.model.modelId.includes("gpt-5.1") ||
this.model.modelId.includes("gpt-5.2")) &&
!isCodex;
const isDeepSeek = this.model.modelId.includes("deepseek");
// Kimi models only support temperature=1
const isKimi = this.model.modelId.includes("kimi");
const temperature = isKimi ? 1 : options.temperature;

if (options.response_model) {
if (isDeepSeek || isKimi) {
const parsedSchema = JSON.stringify(
Expand All @@ -164,8 +165,12 @@ You must respond in JSON format. respond WITH JSON. Do not include any other tex
providerOptions: isGPT5
? {
openai: {
textVerbosity: "low", // Making these the default for gpt-5 for now
reasoningEffort: usesLowReasoningEffort ? "low" : "minimal",
textVerbosity: isCodex ? "medium" : "low", // codex models only support 'medium'
reasoningEffort: isCodex
? "medium"
: usesLowReasoningEffort
? "low"
: "minimal",
Comment on lines +169 to +173
Copy link
Contributor

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".

Suggested change
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.

},
}
: undefined,
Expand Down