Repository: browserbase/stagehand
File: packages/core/lib/v3/tests/agent-hybrid-mode.spec.ts (TypeScript)

Code before:
      });

      // Should have captured tool calls
      expect(toolCalls.length).toBeGreaterThan(0);

      const toolNames = toolCalls.map((tc) => tc.toolName);
      // Should include screenshot (hybrid mode emphasizes visual)
      expect(toolNames).toContain("screenshot");
    });

    test("DOM mode agent uses DOM-based tools", async () => {
      test.setTimeout(90000);

      const toolCalls: Array<{ toolName: string; input: unknown }> = [];

      const agent = v3.agent({
        mode: "dom",
        model: "anthropic/claude-haiku-4-5-20251001",
      });

      const page = v3.context.pages()[0];
      await page.goto("https://example.com");

      await agent.execute({
        instruction:
          "Use the ariaTree to understand the page, then describe what you see briefly and mark the task as complete.",
        maxSteps: 5,
        callbacks: {
          onStepFinish: async (event: StepResult<ToolSet>) => {
            if (event.toolCalls) {
              for (const tc of event.toolCalls) {
                toolCalls.push({
                  toolName: tc.toolName,
                  input: tc.input,
                });
              }
            }
          },
        },
      });

      // Should have captured tool calls
      expect(toolCalls.length).toBeGreaterThan(0);

      // Should include ariaTree (DOM mode emphasizes aria-based interaction)
      const toolNames = toolCalls.map((tc) => tc.toolName);
      expect(toolNames).toContain("ariaTree");
    });
  });

  test.describe("Scroll tool variants by mode", () => {

Review comment (suggestion):
```suggestion
          "Use the ariaTree to understand the page, then provide the final requested output or a summary of the page.",
```

Code after:
      });

      // Should have captured tool calls
      expect(toolCalls.length).toBeGreaterThan(0);

      const toolNames = toolCalls.map((tc) => tc.toolName);
      // Should include screenshot (hybrid mode emphasizes visual)
      expect(toolNames).toContain("screenshot");
    });

    test("DOM mode agent uses DOM-based tools", async () => {
      test.setTimeout(90000);

      const toolCalls: Array<{ toolName: string; input: unknown }> = [];

      const agent = v3.agent({
        mode: "dom",
        model: "anthropic/claude-haiku-4-5-20251001",
      });

      const page = v3.context.pages()[0];
      await page.goto("https://example.com");

      await agent.execute({
        instruction:
          "Use the ariaTree to understand the page, then provide the final requested output or a summary of the page.",
        maxSteps: 5,
        callbacks: {
          onStepFinish: async (event: StepResult<ToolSet>) => {
            if (event.toolCalls) {
              for (const tc of event.toolCalls) {
                toolCalls.push({
                  toolName: tc.toolName,
                  input: tc.input,
                });
              }
            }
          },
        },
      });

      // Should have captured tool calls
      expect(toolCalls.length).toBeGreaterThan(0);

      // Should include ariaTree (DOM mode emphasizes aria-based interaction)
      const toolNames = toolCalls.map((tc) => tc.toolName);
      expect(toolNames).toContain("ariaTree");
    });
  });

  test.describe("Scroll tool variants by mode", () => {