vercel-labs/agent-browser · error

Provide a direction to scroll, or a selector to scroll into

Error message

Provide a direction to scroll, or a selector to scroll into view.

What it means

The eve 'scroll' tool has two modes: directional scroll (up/down/left/right, optionally with pixels and a container selector) or scroll-into-view (selector only, direction omitted). If direction is undefined the tool needs a selector to bring into view; with both undefined there is no scroll to perform, so execute() throws before running the CLI.

Source

Thrown at packages/@agent-browser/eve/extension/tools/scroll.ts:23

export default defineTool({
  description:
    "Scroll the page or a scrollable container, or scroll an element into view (pass only a selector).",
  inputSchema: z.object({
    direction: z
      .enum(["up", "down", "left", "right"])
      .optional()
      .describe("Omit to scroll the selector's element into view instead."),
    pixels: z.number().int().positive().optional().describe("Scroll distance in pixels."),
    selector: z
      .string()
      .optional()
      .describe(`Scroll container, or the element to bring into view. ${SELECTOR_HINT}`),
  }),
  async execute({ direction, pixels, selector }, ctx) {
    if (direction === undefined) {
      if (selector === undefined) {
        throw new Error("Provide a direction to scroll, or a selector to scroll into view.");
      }
      return await runBrowser(ctx, ["scrollintoview", selector]);
    }
    const args = ["scroll", direction];
    if (pixels !== undefined) args.push(String(pixels));
    if (selector !== undefined) args.push("--selector", selector);
    return await runBrowser(ctx, args);
  },
});

View on GitHub (pinned to 548b159b30)

Solutions

  1. Directional: tools.scroll({ direction: 'down', pixels: 500 })
  2. Into view: tools.scroll({ selector: '@e7' })
  3. Validate that direction or selector is present before invoking

Example fix

// before
await tools.scroll({ pixels: 500 });

// after
await tools.scroll({ direction: "down", pixels: 500 });
// or: await tools.scroll({ selector: "@e7" });
Defensive patterns

Strategy: validation

Validate before calling

if (input.direction === undefined && input.selector === undefined) {
  throw new Error("scroll needs a direction or a selector to scroll into view");
}
if (input.pixels !== undefined && input.direction === undefined) {
  throw new Error("pixels only applies together with a direction");
}

Type guard

function isScrollInputValid(i: { direction?: string; selector?: string }): boolean {
  return i.direction !== undefined || i.selector !== undefined;
}

Prevention

When it happens

Trigger: Calling scroll with no arguments at all; passing only pixels ({ pixels: 500 }) without a direction; passing an empty-string direction (schema rejects it, but undefined slips through).

Common situations: Models calling scroll as a no-op probe; forgetting that pixels alone does not imply a direction; intending element scroll but omitting the selector.

Related errors


AI-assisted analysis of vercel-labs/agent-browser@548b159b30 (2026-08-16). Data as JSON: /api/errors/7d093202b9382e4b. Report an issue: GitHub.