From f24487be87b3b74bc56e2b98348a116efc752ee6 Mon Sep 17 00:00:00 2001 From: bennycortese Date: Fri, 31 Oct 2025 01:14:30 -0700 Subject: [PATCH 1/2] So when I ran stagehand.agent out of the box, I kept getting the model set to gpt-4.1-mini by default. This seems to be because the Vercel AI SDK is used as the default for logging, and the model isn't ever getting set to openai/gpt-4.1-mini. This should fix both issues and hopefully fix default model configs for all provides --- packages/core/lib/v3/v3.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/core/lib/v3/v3.ts b/packages/core/lib/v3/v3.ts index 88bf0f196..66c6c697e 100644 --- a/packages/core/lib/v3/v3.ts +++ b/packages/core/lib/v3/v3.ts @@ -1371,7 +1371,7 @@ export class V3 { ? typeof options?.model === "string" ? { value: options.model, type: "string" } : { value: options.model.modelName, type: "string" } - : { value: this.llmClient.modelName, type: "string" }, + : { value: this.modelName, type: "string" }, systemPrompt: { value: options?.systemPrompt ?? "", type: "string" }, tools: { value: JSON.stringify(options?.tools ?? {}), type: "object" }, ...(options?.integrations && { @@ -1473,8 +1473,13 @@ export class V3 { try { if (this.apiClient && !this.experimental) { const page = await this.ctx!.awaitActivePage(); + // Ensure model is set for API calls - use the resolved modelName + const agentConfigWithModel: AgentConfig = { + ...options, + model: options?.model || modelName, + }; result = await this.apiClient.agentExecute( - options, + agentConfigWithModel, resolvedOptions, page.mainFrameId(), ); @@ -1576,8 +1581,13 @@ export class V3 { try { if (this.apiClient && !this.experimental) { const page = await this.ctx!.awaitActivePage(); + // Ensure model is set for API calls - default to V3's modelName if not specified + const agentConfigWithModel: AgentConfig = { + ...options, + model: options?.model || this.modelName, + }; result = await this.apiClient.agentExecute( - options, + agentConfigWithModel, resolvedOptions, page.mainFrameId(), ); From e6f6d86221e93dc3d0a314598f7d391ac4878069 Mon Sep 17 00:00:00 2001 From: bennycortese Date: Fri, 31 Oct 2025 01:18:28 -0700 Subject: [PATCH 2/2] Changeset added --- .changeset/whole-goats-clap.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/whole-goats-clap.md diff --git a/.changeset/whole-goats-clap.md b/.changeset/whole-goats-clap.md new file mode 100644 index 000000000..44d25085c --- /dev/null +++ b/.changeset/whole-goats-clap.md @@ -0,0 +1,5 @@ +--- +"@browserbasehq/stagehand": minor +--- + +Default model providers don't seem to be working correctly in Stagehand V3 when a model isn't specified - this diff should fix that and fix the associated logging