Stagehand icon

Stagehand

Control browser using Stagehand with AI automation

Agent Execute

AI-generated

Summary

Execute a complex multi-step browser automation task using an AI agent that interprets natural language instructions and performs actions within a controlled browser session.

Inputs

  • AI Provider (required) — Choose which AI provider to use for agent operations, such as OpenAI, Anthropic, Google, Cerebras, or OpenRouter.
  • Instruction (required) — Natural language instruction describing the task for the AI-driven agent to perform in the browser.
  • Max Steps — Maximum number of discrete steps the agent is allowed to take during execution (default is 20).
  • Auto Screenshot — Enable or disable automatic screenshots before each action to document the agent’s progress (default is true).
  • Advanced Options — Optional advanced settings including AI model selection, caching, verbosity, timeouts, delays between actions, resource blocking, and logging.

Output shape

a single JSON object representing the result of the agent's execution, including any outputs or final states produced by the AI agent.

Output includes the operation name ('agentExecute') and the result object from the AI agent. Optional Stagehand log messages are included if enabled via 'Log Messages' option. Execution depends on a previously initialized browser session or will attempt to reconnect or create one as needed.

Examples

Example 1: Running an AI agent to perform a multi-step form submission task on a webpage.

Set 'AI Provider' to OpenAI, specify the natural language 'Instruction' describing the form submission, adjust 'Max Steps' if expecting a longer workflow, and optionally configure advanced options like model name or delays between actions.

Discussion