vercel-labs/agent-browser · error
The "switch" action requires a target tab id or label.
Error message
The "switch" action requires a target tab id or label.
What it means
The eve 'tabs' tool switch action maps to 'agent-browser tab <target>' where target is a tab id or label. Unlike 'new' and 'close', which have sensible defaults, switching has nothing to default to, so execute() throws when action is 'switch' and target is undefined.
Solutions
- List tabs first (action: 'list') and pass a concrete id or label
- Pass the label you created the tab with: tools.tabs({ action: 'switch', target: 'checkout' })
- For creating-and-switching use action 'new' with a label instead
Example fix
// before
await tools.tabs({ action: "switch" });
// after
const list = await tools.tabs({ action: "list" });
await tools.tabs({ action: "switch", target: list[0].id }); Defensive patterns
Strategy: validation
Validate before calling
if (input.action === "switch" && input.target === undefined) {
const tabs = await tools.tabs({ action: "list" });
if (tabs.length === 1) return tabs[0]; // nothing to switch to
throw new Error("switch requires a tab id or label from the list");
} Type guard
function canSwitchTab(i: { action: string; target?: string }): boolean {
return i.action !== "switch" || i.target !== undefined;
} Prevention
- List tabs first and carry a concrete id/label into the switch call
- Label tabs at creation ('tab new --label x') so switches are stable
- Remember 'close' and 'new' work without target; only 'switch' requires it
When it happens
Trigger: Calling tabs with { action: 'switch' } and no target; label stored in an undefined variable; confusing 'switch' with 'new' (which needs neither).
Common situations: Agents assuming switch-to-latest semantics; flows where the tab list was fetched earlier and the id was dropped.
Related errors
- Provide a direction to scroll, or a selector to scroll into…
- Provide at least one of: selector, text, urlPattern…
- The " " action requires a value.
- The "attr" property requires an attribute name.
- The "goto" action requires a url.
AI-assisted analysis of vercel-labs/agent-browser@548b159b30 (2026-08-16).
Data as JSON: /api/errors/0c6d16ea643f7a81.
Report an issue: GitHub.
Appendix: source
Thrown at packages/@agent-browser/eve/extension/tools/tabs.ts:33
target: z
.string()
.optional()
.describe('Tab id ("t2") or label. Required for "switch"; "close" defaults to the active tab.'),
url: z.string().optional().describe('URL to open when action is "new".'),
}),
async execute({ action, label, target, url }, ctx) {
switch (action) {
case "list":
return await runBrowser(ctx, ["tab"]);
case "new": {
const args = ["tab", "new"];
if (label !== undefined) args.push("--label", label);
if (url !== undefined) args.push(url);
return await runBrowser(ctx, args);
}
case "switch":
if (target === undefined) {
throw new Error('The "switch" action requires a target tab id or label.');
}
return await runBrowser(ctx, ["tab", target]);
case "close":
return await runBrowser(ctx, target === undefined ? ["tab", "close"] : ["tab", "close", target]);
}
},
});
View on GitHub (pinned to 548b159b30)