Skip to content

Migrate all Stagehand templates to V4 - #101

Open
shrey150 wants to merge 17 commits into
devfrom
agent/update-templates-stagehand-v4
Open

Migrate all Stagehand templates to V4#101
shrey150 wants to merge 17 commits into
devfrom
agent/update-templates-stagehand-v4

Conversation

@shrey150

@shrey150 shrey150 commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Stagehand is the SDK for browser agents.

  • migrate every Stagehand template in this repository to the V4 lifecycle: 35 TypeScript, 32 Python, and 1 Go
  • use published @browserbasehq/stagehand@4.0.0 and stagehand==4.0.0 for the core SDKs
  • replace all removed agent APIs with bring-your-own agent frameworks plus Stagehand code mode; no executable stagehand.agent, Sessions.Execute, AsyncStagehand, new Stagehand, deepLocator, or V3 .init() usage remains
  • adopt browserbase.launch() / localBrowser.launch(), Stagehand.create({ browser }), browser.context, V4 { data, metadata } envelopes, locator(), and explicit Stagehand-then-browser cleanup
  • validate live business outcomes instead of treating a completed API or browser call as success
  • update the docs and template index for V4

Companion PR: browserbase/create-browser-app#40

Agent migration: 14 templates

Nine TypeScript templates now use Vercel AI SDK ToolLoopAgent with Stagehand code mode's stateful code_execute tool:

Five Python templates now use Deep Agents with the Stagehand integration's stateful run, snapshot, and screenshot tools:

The Go template's removed autonomous Sessions.Execute step is now an explicit, verifiable V4 ObserveAct → typed Extract workflow.

Package state

  • TypeScript core: published @browserbasehq/stagehand@4.0.0
  • Python core: published stagehand==4.0.0
  • TypeScript code mode: exact reviewed source commit 54302fc5f13be5ad8e717d8e1388502de22be2ed until @browserbasehq/stagehand-codemode is published
  • Python Deep Agents integration: current stagehand/main source (packages/integrations/deepagents), with its server dependency on published stagehand==4.0.0
  • Go V4 SDK: exact pseudo-version v0.0.0-20260810174315-a46676658b4f until the module is tagged

The native POST /v1/llm/responses route is live and was verified through published V4 with a real Browserbase Model Gateway observe() call. It is not a blocker or warning for this PR.

E2E result

Tested through 2026-08-14 with clean installs, real Browserbase sessions, live sites, real third-party APIs, downloads, extraction, form submissions where safe, and output assertions. After switching the Python Deep Agents integration to stagehand/main, its clean source install succeeded and all five affected templates were rerun: four passed their full live outcomes, while Cerebras completed the live browser/repository work before reaching the unchanged account-quota blocker. The newly standalone TypeScript context and pickleball templates each passed a fresh registry install, strict typecheck, and runtime-import probe; that proof confirmed Pickleball's api_timeout launch option against the freshly resolved @browserbasehq/sdk@2.17.0; the SDK maps it to the API body as timeout.

  • 70/77 first-level language directories passed full live business-outcome testing
  • 61/68 Stagehand V4 directories passed live
  • 9/9 non-Stagehand directories passed live (10 executable flows)
  • 7/77 are externally blocked, not claimed as passes: six authenticated REC.US/GitHub flows lack user-scoped credentials; one Cerebras flow has a valid key but the account returns HTTP 402 for every available model
  • the two Pickleball runs also require explicit approval before creating a real reservation

Review-readiness assessment: 92% confidence that external access is the only material blocker, 85% confidence that all seven complete on their first credentialed live run, and >95% confidence that any remaining failure is localized third-party friction rather than a systemic V4 migration issue. This is sufficient to begin human review while the seven outcomes remain explicitly labeled as blocked—not passed. Detailed E2E readiness report.

TypeScript Stagehand — 32 pass, 3 blocked

Template Status Verified live output / outcome
agent-with-human-in-loop PASS Next app accepted a resume, embedded Live View, paused via askHuman, consumed the response, submitted the synthetic application, and displayed completion + replay.
amazon-global-price-comparison PASS Returned 18 complete products across US/UK/DE/FR/IT/ES with correct regional currencies and real URLs.
amazon-product-scraping PASS Returned three current Seiko products with complete product-detail URLs and validated records.
basic-caching PASS Published V4 returned HIT twice; the repeated observation reported 550 tokens saved.
basic-recaptcha PASS Solved Google's live reCAPTCHA demo, submitted, and verified the success page.
browser-agent-demo PASS Search + Fetch + code mode returned grounded San Francisco coffee recommendations.
browserbase-reducto PASS Downloaded Apple's FY2025 Q4 PDF and verified exact values 49025, 46222, 209586, and 201183.
business-lookup PASS Official SF data returned Jalebi Street LLC, 1466 Haight St, account 1376013-12-241.
company-address-finder PASS Returned four companies with addresses or intentional nulls, each backed by official evidence.
company-value-prop-generator PASS Extracted Browserbase's current value proposition and produced the requested concise one-liner.
context BLOCKED Requires SF_REC_PARK_EMAIL and SF_REC_PARK_PASSWORD.
council-events PASS Returned two current Philadelphia council events from the selected year with dates and times.
download-financial-statements PASS Downloaded four unique Apple FY2025 quarterly PDFs in a valid archive.
dynamic-form-filling PASS Filled and submitted the synthetic trip-planning form and verified Your response has been recorded.
exa-browserbase PASS Found Browserbase's official Ashby board, filled the Agent Platform application and resume, verified the missing GitHub field, and stopped before Submit.
extend-browserbase PASS Downloaded 19/19 receipts and parsed all 19 through Extend into validated JSON and CSV.
form-filling PASS Filled and read back every contact-form field and dropdown exactly.
gemini-3-flash PASS Returned current eclipse dates with two real sources the agent opened.
gemini-cua PASS Returned current eclipse dates with opened, source-backed evidence.
gift-finder PASS Generated three AI Gateway queries, searched Firebox concurrently, validated nine real products, and ranked them.
google-trends PASS Returned 20 current US Google trends from the live page.
image-url-download PASS Downloaded five real images with verified MIME types and nonzero sizes.
job-application PASS Filled and submitted nine synthetic applications with resume uploads and verified confirmations.
license-verification PASS California DRE 02237476 returned the expected licensee, status, expiry, broker, and discipline result.
manual-mfa-with-contexts BLOCKED Requires a user-scoped GitHub test login and manual MFA.
mfa-handling PASS Completed a live RFC 6238/TOTP challenge and verified the success route.
microsoft-cua PASS Returned current eclipse dates with sources the agent actually opened.
nurse-verification PASS Live Alabama lookup returned Ronald Agee, license 346, Active.
pickleball BLOCKED Requires SF Rec credentials; an actual booking additionally requires explicit side-effect approval.
polymarket-research PASS Returned the specified live market and nonempty current odds/prices.
proxies PASS Returned distinct residential IPs and verified New York region, country, timezone, and geolocation.
proxies-weather PASS New York, London, Tokyo, and São Paulo proxies returned current weather and matching countries.
sec-filing-research PASS Returned five current Apple EDGAR filings with exact dates and accession numbers.
smart-fetch-scraper PASS Browserbase Fetch returned Hacker News HTTP 200, title, usable content, and 184 links without browser fallback.
website-link-tester PASS Audited all 66 rendered HTTP links and correctly reported the single live HTTP 500; expected nonzero exit verified.

Python Stagehand — 28 pass, 4 blocked

Template Status Verified live output / outcome
amazon-global-price-comparison PASS Returned three US and three UK products with correct currencies and URLs.
amazon-product-scraping PASS Returned three current Seiko products with complete live URLs.
basic-caching PASS Published V4 returned repeated HIT and reported 550 tokens saved.
basic-recaptcha PASS Solved and submitted Google's live CAPTCHA demo and verified success.
browserbase-reducto PASS Parsed Apple's PDF and verified 49025, 46222, 209586, and 201183.
business-lookup PASS Official SF data returned Jalebi Street's name, address, and account.
cartesia-form-filling PASS Filled all nine fields, submitted the Fillout test form, verified confirmation, and received Gemini READY; phone transport stayed disabled.
cerebras-docs-checker BLOCKED Crawled two live docs pages and found browserbase/stagehand; final agent verification is blocked because the valid Cerebras key returns HTTP 402 for every available model.
company-address-finder PASS Returned four companies with official address evidence.
company-value-prop-generator PASS Returned Browserbase's current value proposition and concise one-liner.
context BLOCKED Requires SF_REC_PARK_EMAIL and SF_REC_PARK_PASSWORD.
council-events PASS Returned two current Philadelphia council events with dates and times.
download-financial-statements PASS Downloaded four Apple FY2025 PDFs; validated the 11.2 MB archive.
exa-browserbase PASS Found the official Browserbase application, filled and verified it with resume upload, and stopped before Submit.
extend-browserbase PASS Downloaded 19 receipts and parsed all 19 through Extend into JSON and CSV.
form-filling PASS Filled and read back all seven fields exactly.
gemini-cua PASS Returned current eclipse dates with real sources.
gift-finder PASS Generated AI Gateway queries, searched live Firebox products, and returned a validated ranking.
google-trends PASS Returned 20 current US trends.
image-url-download PASS Downloaded and verified three real images.
job-application PASS Submitted one synthetic test application and verified its confirmation.
license-verification PASS California DRE 02237476 returned Dhar with status LICENSED.
manual-mfa-with-contexts BLOCKED Requires a user-scoped GitHub test login and manual MFA.
mfa-handling PASS Completed and verified a live TOTP login.
nurse-verification PASS Returned Ronald Agee, license 346, Active.
pickleball BLOCKED Requires SF Rec credentials; booking additionally requires explicit approval.
polymarket-research PASS Returned the live Elon market with current 7% odds.
proxies PASS Verified distinct IPs plus New York/New Jersey timezone and geolocation.
proxies-weather PASS Verified live weather and country for New York, London, Tokyo, and São Paulo.
sec-filing-research PASS Returned five Apple filings; latest 10-Q dated 2026-07-31.
smart-fetch-scraper PASS Browserbase Fetch returned Hacker News HTTP 200 with title, links, and usable content.
website-link-tester PASS Verified all three selected real links through HTTP and semantic checks.

Go Stagehand — 1 pass

Template Status Verified live output / outcome
hackernews PASS V4 observed and opened the live top-story comments, extracted title/comment/author and cross-checked each against deterministic DOM values, then extracted the newest title and cross-checked its real anchor URL.

Non-Stagehand templates — 9 directories / 10 flows passed

Language/template Status Verified live output / outcome
TypeScript getting-started-with-browserbase PASS Search returned five results, Fetch returned Wikipedia HTTP 200, and a real browser extracted the Headless browser summary and five sections.
TypeScript playwright/basic-recaptcha PASS Solved Google's live CAPTCHA, submitted, and verified Verification Success... Hooray!.
TypeScript playwright/quickstart-playwright PASS Opened/closed SFMOMA search, navigated to Membership, and extracted current heading and intro copy.
TypeScript playwright-mfa-handling PASS Generated a live TOTP and verified successful authentication.
TypeScript puppeteer PASS Completed the SFMOMA search and Membership interaction/extraction flow through Puppeteer.
TypeScript selenium PASS Completed the same live SFMOMA flow through Selenium on Browserbase Chrome 151.
Python getting-started-with-browserbase PASS Verified Search, Fetch, and a real Wikipedia browser session.
Python playwright PASS Both CAPTCHA and SFMOMA Playwright flows passed.
Python playwright-mfa-handling PASS Completed and verified the live TOTP login.
Python selenium PASS Completed the live SFMOMA flow using the session's Selenium remote URL.

Repository proof

Check Result
Template index 43 rows cover all 77 first-level language directories
Standalone manifest follow-up TypeScript context and pickleball both pass fresh install, strict typecheck, and runtime-import resolution
Root checks README index, Prettier, ESLint, Ruff lint, Ruff format, and git diff --check pass
Python installs all 32 Stagehand Python directories completed clean uv sync; changed files pass compile + Ruff
Go go mod tidy, gofmt, go vet ./..., and live go run . pass against the exact V4 source version
V3 audit zero executable references to removed V3 constructors, agent APIs, locators, or initialization
Secrets changed files and commits contain no saved credential values

Before merge / follow-up

  • swap the nine TypeScript code-mode pins to the packaged integration when it is published
  • swap the Go pseudo-version to the tagged V4 module when it is released
  • to complete the remaining seven E2Es, provide SF Rec and GitHub test-account secrets, add Cerebras quota or a replacement user-scoped key, and explicitly approve any real Pickleball reservation

Note

Cursor Bugbot is generating a summary for commit 4eb15f1. Configure here.

@socket-security

socket-security Bot commented Aug 9, 2026

Copy link
Copy Markdown

Warning

Review the following alerts detected in dependencies.

According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.

Action Severity Alert  (click "▶" to expand/collapse)
Warn High
Obfuscated code: npm json-schema is 90.0% likely obfuscated

Confidence: 0.90

Location: Package overview

From: ?npm/@ai-sdk/mcp@2.0.31npm/ai@7.0.65npm/json-schema@0.4.0

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/json-schema@0.4.0. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

@shrey150
shrey150 marked this pull request as ready for review August 10, 2026 19:20
@shrey150
shrey150 requested a review from a team as a code owner August 10, 2026 19:20
Comment thread typescript/amazon-product-scraping/index.ts
Comment thread typescript/amazon-product-scraping/index.ts
Comment thread typescript/browserbase-reducto/index.ts
Comment thread python/cartesia-form-filling/stagehand_form_filler.py
Comment thread typescript/exa-browserbase/index.ts Outdated
Comment thread typescript/exa-browserbase/index.ts
@shrey150 shrey150 changed the title Update TypeScript templates to Stagehand V4 Migrate all Stagehand templates to V4 Aug 11, 2026
Comment thread go/hackernews/main.go
Comment thread python/cartesia-form-filling/stagehand_form_filler.py
Comment thread python/cartesia-form-filling/stagehand_form_filler.py
Comment thread python/exa-browserbase/main.py Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 438ba1c. Configure here.

},
const browser = await browserbase.launch({
apiKey: process.env.BROWSERBASE_API_KEY!,
api_timeout: 900,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong launch timeout option name

Medium Severity

browserbase.launch now sets api_timeout instead of timeout. Other V4 launch calls use camelCase session fields like apiKey and browserSettings, and the Python pickleball template still passes timeout=900 for a 15-minute Browserbase session. This property is unused elsewhere, so the intended session lifetime is no longer applied to the long booking flow.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 438ba1c. Configure here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No code change needed: this is a false positive against the currently resolved TypeScript SDK contract. A fresh install of @browserbasehq/stagehand@4.0.0 resolves @browserbasehq/sdk@2.17.0; its public SessionCreateParams field is api_timeout, and its implementation explicitly converts that to the API body as { timeout: api_timeout, ...body }. Changing this call to timeout fails the template’s strict typecheck with TS2353. I also reran a clean registry install/build and a real Browserbase launch/connect/close using api_timeout, all successfully. The Python SDK intentionally exposes a different language-specific parameter name (timeout).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant