Skip to content

Commit ab5d6ed

Browse files
authored
add gpt 5 handling to operator handler (#1046)
# why when using operator handler with gpt-5, the temperature is not being set to 1 # what changed the temperature now gets set to 1 when gpt-5 is being used # test plan
1 parent 8244ab2 commit ab5d6ed

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

.changeset/true-cloths-film.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@browserbasehq/stagehand": patch
3+
---
4+
5+
Add support for gpt-5 in operator agent

lib/handlers/operatorHandler.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,10 @@ export class StagehandOperatorHandler {
175175
this.allTools = { ...stagehandTools, ...mcpTools };
176176
}
177177

178+
private getTemperatureForModel(): number {
179+
return this.llmClient.modelName.includes("gpt-5") ? 1 : 0.1;
180+
}
181+
178182
public async execute(
179183
instructionOrOptions: string | AgentExecuteOptions,
180184
): Promise<AgentResult> {
@@ -319,6 +323,7 @@ export class StagehandOperatorHandler {
319323
const response = await this.llmClient.createChatCompletion<LLMResponse>({
320324
options: {
321325
messages: this.messages as ChatMessage[],
326+
temperature: this.getTemperatureForModel(),
322327
tools: toolsArray,
323328
tool_choice: "required", // Force tool usage since operator expects tool calls
324329
requestId,
@@ -534,6 +539,7 @@ export class StagehandOperatorHandler {
534539
const { data: response, usage } =
535540
(await this.llmClient.createChatCompletion<OperatorSummary>({
536541
options: {
542+
temperature: this.getTemperatureForModel(),
537543
messages: summaryMessages as ChatMessage[],
538544
response_model: {
539545
name: "operatorSummarySchema",

0 commit comments

Comments
 (0)