{"record":{"id":"b60bb9f9d956a365","repo":"vercel-labs/agent-browser","slug":"agent-browser-command-failed-result-command-n","errorCode":null,"errorMessage":"agent-browser command failed: ${result.command}\\n${detail}","messagePattern":"agent-browser command failed: (.+?)\\\\n(.+?)","errorType":"exception","errorClass":"AgentBrowserCommandError","httpStatus":null,"severity":"error","filePath":"packages/@agent-browser/eve/extension/lib/browser.ts","lineNumber":89,"sourceCode":"    session: config.session ?? defaultSessionName(config.sessionPrefix, sandbox.id),\n  });\n  const raw = await withDeadline(\n    sandbox.run({ abortSignal: ctx.abortSignal, command }),\n    \"The browser command\",\n  );\n  const result = createAgentBrowserCommandResult<CommandEnvelope<TData>>({\n    command,\n    exitCode: raw.exitCode,\n    stderr: raw.stderr,\n    stdout: raw.stdout,\n  });\n\n  const envelope = result.json;\n  if (envelope !== null && envelope.success === false) {\n    throw new Error(`agent-browser ${args[0] ?? \"\"} failed: ${envelope.error ?? \"unknown error\"}`);\n  }\n  if (result.exitCode !== 0) {\n    throw new AgentBrowserCommandError(result);\n  }\n  return (envelope?.data ?? null) as TData;\n}\n\nasync function requireSandbox(ctx: BrowserToolContext): Promise<EveSandboxSession> {\n  const sandbox = await withDeadline(ctx.getSandbox(), \"The sandbox session\");\n  if (sandbox === null || sandbox === undefined) {\n    throw new Error(\n      \"The browser tools require an eve sandbox. Configure agent/sandbox.ts in the consuming agent.\",\n    );\n  }\n  return sandbox;\n}\n\nasync function ensureInstalled(sandbox: EveSandboxSession, abortSignal?: AbortSignal): Promise<void> {\n  if (!extension.config.autoInstall) {\n    return;\n  }","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/vercel-labs/agent-browser/blob/548b159b30eef119ccf6846c8bc807d0eaa3f6f8/packages/@agent-browser/eve/extension/lib/browser.ts#L71-L107","documentation":"In eve's runBrowser, after the JSON-envelope check, a non-zero exit code throws AgentBrowserCommandError. This path means the CLI process itself failed without a parseable failure envelope: binary missing or not installed, crashes, usage errors, or garbage on stdout. The message is 'agent-browser command failed: <command>\\n<detail>' where detail is trimmed stderr (or stdout, or 'exit N').","triggerScenarios":"agent-browser binary absent from PATH in the sandbox and autoInstall disabled or failed; CLI version mismatch (unknown flags); native binary crash; sandbox.run returning a non-zero exit for environment reasons.","commonSituations":"Fresh sandboxes where installation raced or config.autoInstall was turned off; pinned old CLI versions that lack newer flags the extension passes; restricted sandboxes without network for install.","solutions":["Inspect error.stderr/error.command on the thrown AgentBrowserCommandError to see the exact failing command and stderr","Ensure the binary exists in the sandbox: run 'command -v agent-browser'; if missing, enable extension autoInstall or install the matching 'agent-browser@<version>' spec","Align the installed CLI version with the eve extension's expected version (AGENT_BROWSER_SANDBOX_VERSION)"],"exampleFix":"// before\nconst ext = configure({ autoInstall: false });   // binary missing -> exit 127\n\n// after\nimport { AGENT_BROWSER_SANDBOX_VERSION } from \"@agent-browser/sandbox\";\nconst ext = configure({ autoInstall: true, installSpec: `agent-browser@${AGENT_BROWSER_SANDBOX_VERSION}` });","handlingStrategy":"try-catch","validationCode":"// Before running tools, verify the binary in the sandbox:\n// const probe = await sandbox.run({ command: \"command -v agent-browser\" });\n// if (probe.exitCode !== 0) install before proceeding.","typeGuard":"import { AgentBrowserCommandError } from \"@agent-browser/sandbox\";\nfunction isCommandError(error: unknown): error is AgentBrowserCommandError {\n  return error instanceof AgentBrowserCommandError;\n}","tryCatchPattern":"try {\n  return await runBrowser(ctx, args);\n} catch (error) {\n  if (error instanceof AgentBrowserCommandError) {\n    logger.error({ command: error.command, exitCode: error.exitCode, stderr: error.stderr });\n    // exit 127 => binary missing; 1 with usage text => version skew\n  }\n  throw error;\n}","preventionTips":["Keep extension.config.autoInstall on, or pin installSpec to the matching agent-browser@VERSION","Fail fast on exit code 127 (binary not found) instead of retrying commands","Version-lock the CLI and the npm packages together when upgrading"],"tags":["eve","cli","installation","process-exit"],"backgroundTag":null,"analyzedSha":"548b159b30eef119ccf6846c8bc807d0eaa3f6f8","analyzedAt":"2026-08-16T10:12:14.925Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}