Repository navigation
fix(v3): honor CAPTCHA awareness options for local attachments - #3114
Conversation
🦋 Changeset detectedLatest commit: 7d60cac The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
All reported issues were addressed across 8 files
Architecture diagram
sequenceDiagram
participant Client as V3 Client Code
participant V3 as V3 Class
participant API as StagehandAPIClient
participant Server as Standalone V3 Server
participant Store as InMemorySessionStore
participant Browser as Browserbase Session
Note over Client,Browser: CAPTCHA Awareness Resolution Flow
Client->>V3: Create instance(env, waitForCaptchaSolves, solveCaptchas)
V3->>V3: Resolve isCaptchaAutoSolveEnabled
Note over V3: waitForCaptchaSolves ?? solveCaptchas ?? (env === "BROWSERBASE")
Note over V3: Explicit solveCaptchas: false always wins
Client->>V3: init()
V3->>V3: Read isCaptchaAutoSolveEnabled (before CDP init)
V3->>API: init(waitForCaptchaSolves=resolvedValue)
API-->>V3: sessionId, available
V3->>Browser: Attach via CDP (env LOCAL or BROWSERBASE)
alt Local attachment (env: "LOCAL")
Note over V3,Browser: Same CAPTCHA awareness now applies
Browser-->>V3: Captcha solve event
V3->>V3: Wait for solve (if enabled)
V3-->>Client: Continue action
else Browserbase attachment (env: "BROWSERBASE")
Browser-->>V3: Captcha solve event
V3->>V3: Wait for solve (if enabled)
end
Note over V3,Store: Server-side forwarding (standalone)
V3->>Server: Session start request (includes waitForCaptchaSolves)
Server->>Store: Persist session params
Store-->>Server: Stored session
Server-->>V3: Session established
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 2 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 5 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 8 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
…chemas" This reverts commit 8e6eb1f.
AzamAbdul
left a comment
There was a problem hiding this comment.
not sure how much this is an actual issue, but the code looks fine to me. just a question about if this is actually a problem:
from claude
found one real bug. On plain local Chrome, setting solveCaptchas: true now turns captcha waiting on. The agent is then told not to solve captchas, but there's no solver locally, so it gets stuck. The bug is in two places: the core library check (v3.ts:203) and the server, which now passes Browserbase settings to local sessions (InMemorySessionStore.ts:251).
…#3150) ## Why `act` fails on OpenAI models routed through the AI SDK client (for example `openai/gpt-4.1-nano`) with: ``` Invalid schema for response_format 'response': In context=('properties', 'action', 'anyOf', '0'), 'additionalProperties' is required to be supplied and to be false. ``` `AISdkClient` sends OpenAI requests with `strictJsonSchema: true`, and OpenAI strict mode requires `additionalProperties: false` on every object. `generateObject` converts the Zod schema with the AI SDK's own converter, which leaves that field off the object inside the nullable `action`'s `anyOf`. The direct provider clients use `toJsonSchema` and already emit it. This is what fails `server/v3/integration/v3/act` and `server/v3/integration/v3/agentExecute` (the variables tests return an empty field because the agent's `act` tool call 400s). See #3114. ## What changed - Mark the action object with `.meta({ additionalProperties: false })` when running on Zod 4. `zod` is a peer dependency (`^3.25 || ^4`) and Zod 3 has no `.meta()`; its converter already emits the field, so the call is skipped there. This changes only the generated JSON schema. Parsing still strips unknown keys, so clients that validate locally (Google, AI SDK providers without strict mode, custom clients) keep accepting responses with extra fields. `.strict()` was considered and rejected because it would make those responses fail validation. - Unit tests check both converters, that parsing still strips unknown keys, and that `act()` builds its schema under a Zod 3 peer. ## Test plan - [x] New `act-response-schema` unit tests pass; the AI SDK converter test fails without the fix. - [x] `act-response-schema-zod3` (mocks `zod` with `zod/v3`) passes; without the guard it fails with `actionSchema.meta is not a function`. - [x] `inference-temperature` unit tests pass. - [x] Live `generateObject` call with `@ai-sdk/openai` `gpt-4.1-nano` and `strictJsonSchema: true`: without the fix it returns the 400 above; with the fix it returns a valid action. - [x] ESLint and Prettier clean. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixes `act` calls failing on OpenAI models routed through the AI SDK client. OpenAI strict mode requires `additionalProperties: false` on every object, and the AI SDK schema converter omitted it inside the nullable `action`'s `anyOf`, producing an `invalid_json_schema` 400. - Sets `additionalProperties: false` via `.meta()` so only the generated JSON schema changes; parsing still strips unknown keys, so clients that validate locally keep accepting responses with extra fields. - Calls `.meta()` only under Zod 4 since `zod` is a peer dependency (^3.25 || ^4) and its Zod 3 import lacks the method; the Zod 3 converter already emits the field. - Adds unit tests for the AI SDK and `toJsonSchema` converters, including the Zod 3 path. <sup>Written for commit 8c3658a. Summary will update on new commits.</sup> <a href="https://cubic.dev/pr/browserbase/stagehand/pull/3150?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="View guided diff" src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a> <a href="https://www.cubic.dev/action/auto-fix/pr/browserbase/stagehand/3150?returnTo=https%3A%2F%2Fgithub.com%2Fbrowserbase%2Fstagehand%2Fpull%2F3150&source=description" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img alt="Turn on auto-fix" src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
|
@AzamAbdul not an issue this fix is going out for the hosted version mainly |
Summary
browserbaseSessionCreateParams.browserSettings.solveCaptchasandwaitForCaptchaSolvesfor local attachments. An explicitfalsefor either option disables awareness; absent options retain Browserbase-on/local-off defaults.Validation
Summary by cubic
Fixes CAPTCHA awareness for local attachments in Stagehand v3 so agents no longer interfere with Browserbase solves or stop at already-solved widgets.
Previously the
waitForCaptchaSolvesandbrowserSettings.solveCaptchasoptions only took effect whenenv: "BROWSERBASE", since awareness was gated on the environment. NowisCaptchaAutoSolveEnabledresolves from constructor options before CDP initialization, withwaitForCaptchaSolves ?? solveCaptchas ?? env === "BROWSERBASE"as the default andsolveCaptchas: falsealways disabling awareness. The resolved value is forwarded through the SDK session-start request and the standalone v3 server.Rollout
Written for commit 90d5767. Summary will update on new commits.