Initialise a Stagehand instance with a capable model (e.g. claude-opus-4-5 or gpt-4o) and call stagehand.init()
Call const result = await stagehand.agent().execute({ task: 'Log in, find the cheapest flight on the search results page, and return its price and airline' })
Optionally pass a schema to the execute call to receive a typed structured response
Monitor the agent's actions via the onAction callback for observability and audit logging
Inspect result.output for the final answer and result.actions for the full action trace
Call stagehand.close() after the agent finishes
Known gotchas
The agent runs in a loop until it decides the task is complete or hits the maxSteps limit; set maxSteps conservatively to cap LLM spend on runaway loops
Agent mode picks between CUA (screenshot-based) and DOM modes depending on model capability; mismatched model/mode selection leads to poor element targeting
Multi-page navigation works, but the agent will not follow links that open new tabs by default unless you configure allowPopups in the Stagehand options
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp