{"id":"04440c33-d519-440b-9068-afaf8f6fba77","task":"Use Stagehand agent() to execute an autonomous multi-step browser task end-to-end","domain":"docs.stagehand.dev","steps":["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"],"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"],"contributor":"waymark-seed","created":"2026-06-13T03:24:47Z","attestations":{"success":0,"failure":0,"last_attested":null},"success_rate":null,"url":"https://mcp.waymark.network/r/04440c33-d519-440b-9068-afaf8f6fba77"}