Recommended Migration Process
- Backup your project. If you use a version control system, make sure all previous versions are committed.
- Upgrade to Stagehand v3.
- Follow the breaking changes guide below.
- Verify your project is working as expected.
- Commit your changes.
Stagehand v3 Package Version
Update yourpackage.json to use Stagehand v3:
Bash
Overview of Major Changes
Stagehand v3 introduces significant improvements to the API design and functionality:- Removing Playwright Dependency: Stagehand v3 is now a standalone library that does not depend on Playwright. You can still use Stagehand with Playwright, check out our Playwright integration for more details.
- Simplified Method Signatures: Cleaner, more intuitive parameter structures.
- Unified Model Configuration: Model configuration is now consolidated into a single
modelparameter. - Automatic iframe & Shadow DOM Support: No more manual flags required.
- Improved Type Safety: Better TypeScript inference and type checking.
- Enhanced Multi-Page Support: New Context API for managing multiple pages.
- Streamlined Timeouts: Consistent timeout naming across all methods.
- Auto-caching: Stagehand v3 now automatically caches actions and agent steps using the file system cache.
- Agent Improvements: Renamed parameters (
instructions→systemPrompt), unified model configuration, and newexecutionModeloption for cost optimization.
Breaking Changes
Stagehand Initialization
Model Configuration Consolidation
ThemodelName and modelClientOptions parameters have been unified into a single model parameter.
Stagehand v2
Stagehand v3
DOM Settle Timeout Rename
ThedomSettleTimeoutMs parameter has been renamed to domSettleTimeout for consistency.
Stagehand v2
Stagehand v3
Changes to return value of stagehand.init()
The init() used to return debugUrl, sessionUrl and sessionId
Stagehand v2
v2, the returned object contains:
v3 the return value is Promise<void>. The sessionId, sessionUrl, and debugUrl are now directly accessible via the stagehand object:
Stagehand v3
Caching Changes
TheenableCaching boolean has been replaced with a cacheDir string for more flexible cache management.
Stagehand v2
Stagehand v3
Page Access Changes
Direct page access has changed to use the Context API.Stagehand v2
Stagehand v3
Context and Multi-Page Management
New Context API
v3 introduces a structured Context API for managing multiple pages.Stagehand v2
Stagehand v3
act() Method Changes
Method Signature Simplification
Theaction parameter has been removed from ActOptions. Now you only pass the instruction as a string.
Stagehand v2
Stagehand v3
Method Location Change: In v3,
act() is called on the stagehand instance, not the page object.Model Configuration in act()
Model configuration follows the same pattern as initialization.Stagehand v2
Stagehand v3
Timeout Parameter Rename
timeoutMs has been renamed to timeout.
Stagehand v2
Stagehand v3
Automatic iframe Support
Theiframes flag has been removed. iframe support is now automatic.
Stagehand v2
Stagehand v3
Automatic Support: Stagehand v3 automatically handles iframe and Shadow DOM interactions without requiring explicit flags.
Result Structure Changes
TheActResult structure has been enhanced with more detailed information.
Stagehand v2
Stagehand v3
extract() Method Changes
Method Location and Signature
extract() has moved from the page object to the stagehand instance, with a cleaner parameter structure.
Stagehand v2
Stagehand v3
Parameter Order: In v3,
instruction and schema are separate positional parameters, with options as an optional third parameter.Extract Without Schema
Schema-less extraction also has a simpler interface.Stagehand v2
Stagehand v3
Model Configuration in extract()
Stagehand v2
Stagehand v3
Automatic iframe Support
Stagehand v2
Stagehand v3
Array Schema Changes
Array extraction now has a more ergonomic syntax.Stagehand v2
Stagehand v3
observe() Method Changes
Method Signature Updates
Stagehand v2
Stagehand v3
Method Location Change: Like
act() and extract(), observe() is now called on the stagehand instance.Draw Overlay Removed
ThedrawOverlay option has been removed in v3.
Stagehand v2
Stagehand v3
Automatic iframe Support
Stagehand v2
Stagehand v3
Observe with act() Integration
The observe → act workflow remains similar but with updated method signatures.Stagehand v2
Stagehand v3
agent() Method Changes
Agent Configuration Updates
The agent configuration has been significantly restructured in v3 with renamed parameters and new capabilities.Stagehand v2
Stagehand v3
Key Changes:
providerremoved - now part of the model string (e.g.,"anthropic/claude-sonnet-4-5")instructionsrenamed tosystemPromptoptionsremoved - use model object format for advanced configurationexecutionModeladded - specify a different model for tool executioncuaflag added - enable/disable Computer Use Agent mode
Model Configuration in agent()
Model configuration follows the same unified pattern as other methods.Stagehand v2
Stagehand v3
Execute Method Changes
Theexecute() method has been simplified with some options removed and new ones added.
Stagehand v2
Stagehand v3
Execution Model Configuration
v3 introduces a newexecutionModel option to use a different (often faster/cheaper) model for tool execution.
Stagehand v3
Agent with Multi-Page Support
v3 agents can now specify which page to operate on.Stagehand v3
History and Metrics
History API
History is now async and returns a promise.Stagehand v2
Stagehand v3
Metrics API
Metrics is now async and returns a promise.Stagehand v2
Stagehand v3
Complete Migration Example
Here’s a complete example showing a full migration:- Stagehand v2
- Stagehand v3
Quick Reference: Breaking Changes
Troubleshooting
Error: Cannot find property ‘page’ on Stagehand instance
Problem: Directstagehand.page is not supported in Stagehand v3.
Solution: Use the Context API or await the active page:
Error: act() method not found on page
Problem: v3 movedact(), extract(), and observe() to the stagehand instance.
Solution: Call these methods on the stagehand instance:
TypeScript: Model configuration type errors
Problem: TypeScript errors with model configuration. Solution: Use the proper format:Agent configuration errors
Problem: Using oldprovider and instructions parameters.
Solution: Update to v3 format:
Agent execute options not recognized
Problem: Using removed options likeautoScreenshot, waitBetweenActions, or context.
Solution: Remove these options and use v3 alternatives:
Best Practices for v3
- Use the string model format for simplicity:
model: "openai/gpt-5" - Leverage automatic iframe support - remove all
iframesflags - Use the Context API for multi-page scenarios
- Monitor metrics to track token usage and optimize costs
- Use history for debugging and understanding automation flow
- Set appropriate timeouts based on your use case
- Specify cache directory to improve performance for repeated actions
- Use executionModel for agents - configure a faster/cheaper model for tool execution while keeping a powerful model for reasoning (e.g.,
model: "anthropic/claude-sonnet-4-5",executionModel: "google/gemini-2.0-flash")

