Skip to main content
Glama

browserbase_stagehand_observe

Locate interactive web page elements from specific instructions to identify buttons, forms, or clickable components for automation tasks.

Instructions

Find interactive elements on the page from an instruction; optionally return an action.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
instructionYesDetailed instruction for what specific elements or components to observe on the web page. This instruction must be extremely specific and descriptive. For example: 'Find the red login button in the top right corner', 'Locate the search input field with placeholder text', or 'Identify all clickable product cards on the page'. The more specific and detailed your instruction, the better the observation results will be. Avoid generic instructions like 'find buttons' or 'see elements'. Instead, describe the visual characteristics, location, text content, or functionality of the elements you want to observe. This tool is designed to help you identify interactive elements that you can later use with the act tool for performing actions like clicking, typing, or form submission.
returnActionNoWhether to return the action to perform on the element. If true, the action will be returned as a string. If false, the action will not be returned.

Implementation Reference

  • The handler function that performs the observation by calling stagehand.observe with the given instruction and returns the observations as text.
    async function handleObserve(
      context: Context,
      params: ObserveInput,
    ): Promise<ToolResult> {
      const action = async (): Promise<ToolActionResult> => {
        try {
          const stagehand = await context.getStagehand();
    
          const observations = await stagehand.observe(params.instruction);
    
          return {
            content: [
              {
                type: "text",
                text: `Observations: ${JSON.stringify(observations)}`,
              },
            ],
          };
        } catch (error) {
          const errorMsg = error instanceof Error ? error.message : String(error);
          throw new Error(`Failed to observe: ${errorMsg}`);
        }
      };
    
      return {
        action,
        waitForNetwork: false,
      };
    }
  • Input schema using Zod for validation of the 'instruction' parameter and the tool schema defining the tool name, description, and input schema.
    const ObserveInputSchema = z.object({
      instruction: z.string().describe(
        `Detailed instruction for what specific elements or components to observe on the web page.
            This instruction must be extremely specific and descriptive. For example: 'Find the red login button
            in the top right corner', 'Locate the search input field with placeholder text', or 'Identify all
            clickable product cards on the page'. The more specific and detailed your instruction, the better
            the observation results will be. Avoid generic instructions like 'find buttons' or 'see elements'.
            Instead, describe the visual characteristics, location, text content, or functionality of the elements
            you want to observe. This tool is designed to help you identify interactive elements that you can
            later use with the act tool for performing actions like clicking, typing, or form submission.`,
      ),
    });
    
    type ObserveInput = z.infer<typeof ObserveInputSchema>;
    
    const observeSchema: ToolSchema<typeof ObserveInputSchema> = {
      name: "browserbase_stagehand_observe",
      description: `Find and identify interactive elements on the page based on an instruction.`,
      inputSchema: ObserveInputSchema,
    };
  • Tool registration object that combines the schema and handler for the observe tool.
    const observeTool: Tool<typeof ObserveInputSchema> = {
      capability: "core",
      schema: observeSchema,
      handle: handleObserve,
    };
    
    export default observeTool;
  • Central registration of all tools including the observeTool in the exported TOOLS array.
    export const TOOLS = [
      ...sessionTools,
      navigateTool,
      actTool,
      extractTool,
      observeTool,
      screenshotTool,
      getUrlTool,
    ];
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions that the tool finds interactive elements and optionally returns an action, but it doesn't cover important aspects like whether this is a read-only operation, potential side effects, performance considerations, or error handling. For a tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise and front-loaded with the core purpose in a single sentence. However, the second part ('optionally return an action') could be integrated more smoothly, and there's some redundancy with the schema's detailed parameter descriptions, but overall it's efficient with zero waste.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (finding interactive elements on a web page), no annotations, and no output schema, the description is incomplete. It doesn't explain what the return values look like (e.g., structured data, error formats), behavioral constraints, or how it interacts with sibling tools beyond a vague reference to the 'act tool'. This leaves the agent with insufficient context for effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both parameters thoroughly. The description adds minimal value beyond the schema by hinting at the purpose ('find interactive elements') but doesn't provide additional syntax, format details, or usage examples for the parameters. Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Find interactive elements on the page from an instruction; optionally return an action.' It specifies the verb ('find'), resource ('interactive elements'), and scope ('from an instruction'), though it doesn't explicitly differentiate from sibling tools like 'browserbase_stagehand_act' or 'browserbase_stagehand_extract', which keeps it from a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage by mentioning that the tool is for identifying elements to later use with the 'act tool', but it doesn't provide explicit guidance on when to use this tool versus alternatives like 'browserbase_stagehand_extract' or 'browserbase_screenshot'. No exclusions or clear alternatives are stated, leaving some ambiguity.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kolbertistvan2/stagehand-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server