Skip to main content
Stagehand performance depends on several factors: DOM processing speed, LLM inference time, browser operations, and network latency. This guide provides proven strategies to maximize automation speed.

Quick performance wins

Plan ahead with observe

Use a single observe() call to plan multiple actions, then replay each returned Action through act():
Performance tip: Passing an observed Action back to act() replays its recorded method and arguments without another inference call. A planned workflow therefore costs one observe() inference instead of one per step, which is the recommended pattern for multi-step workflows.

Caching guide

Learn advanced caching patterns and cache invalidation strategies

Optimize DOM processing

Reduce DOM complexity before Stagehand processes the page. Scoping is usually the biggest win: pass a locator so Stagehand snapshots one container instead of the whole document, and prune known-noisy subtrees.
Removing iframes speeds up snapshots, but Stagehand traverses iframes by default. Only strip them when you know the content you need lives in the main frame.

Set appropriate timeouts

Use shorter timeouts for simple operations and longer ones for complex page loads. Lowering the DOM settle timeout also shaves time off every act() call on stable pages.

Performance monitoring and benchmarking

Track performance metrics and measure optimization impact:

Performance tracking

Example Output:

Before vs after benchmarking

Example Output:
Server-side caching gets you the same result without restructuring your code: when the replay succeeds, a cached act() runs the recorded action with no inference at all. If the recorded selector no longer resolves, Stagehand falls back to the full inference pipeline and caches the new action. See the caching guide.

Observability & metrics

Track token usage and inference timing per run

Caching strategies

Advanced caching patterns for maximum performance

Cost optimization

Balance speed improvements with cost considerations

Browser configuration

Optimize Browserbase settings for speed

Model selection

Choose the right model for speed vs accuracy