Skip to content

fix(browser): return every step of an exec batch instead of "Unknown browser error" - #36246

Merged
AmoabaKelvin merged 3 commits into
mainfrom
fix-exec-batch
Oct 30, 2026
Merged

AmoabaKelvin merged 3 commits into
mainfrom
fix-exec-batch

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​72 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​72
Prod 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​54 $\color{#cf222e}{\Huge{\mathbf{−}}}$​17 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​37

ELI5

Agents can send several browser steps in one call with orca exec --command 'batch "…" "…"'. That always failed with "Unknown browser error", even when every step worked. A bare batch hung for a minute. Now you get every step's result back, and a bare batch fails straight away with agent-browser's own message.

What Changed

  • parseAgentBrowserJsonOutput now reads a reply with several entries as one successful result: the list of steps, each with command, success, result and error, and the daemon lifecycle bookkeeping removed from each result. Before, it handed the array back as if it were a single-command envelope, so translateResult read .success off an array and reported "Unknown browser error". Orca's own one-command batches (sent on stdin) still unwrap to the single result; a batch the caller sent through exec always returns its step list, even when --bail stopped it at the first step.
  • agent-browser exits 1 when any batch step failed. runAgentBrowserRaw now resolves a reply that parses as a success even on a non-zero exit, so the failed step comes back in the list instead of as a raw "Command failed: …agent-browser… batch --bail …".
  • runAgentBrowserRaw always ends the helper's stdin. Commands passed as argv used to leave it open, so a bare batch (which reads JSON from stdin) waited until the CLI gave up after 60 s.

Before, against a dev build of main:

$ orca exec --page $P --command 'batch "get title" "get url"'
Unknown browser error
$ orca exec --page $P --command 'batch --bail "get title" "click @e999" "get url"'
Command failed: …/agent-browser-darwin-arm64 --session orca-tab-… --cdp 62196 batch --bail get title click @e999 get url --json
$ orca exec --page $P --command 'batch'      # 61 s
Timed out waiting for the Orca runtime to respond.

After:

$ orca exec --page $P --command 'batch "get title" "get url"'
[ { "command": ["get","title"], "error": null, "result": { "title": "Login" }, "success": true },
  { "command": ["get","url"], "error": null, "result": { "url": "http://127.0.0.1:8761/login.html" }, "success": true } ]
$ orca exec --page $P --command 'batch --bail "get title" "click @e999" "get url"'
[ { …"get title"… "success": true },
  { "command": ["click","@e999"], "error": "Unknown ref: e999", "result": null, "success": false } ]
$ orca exec --page $P --command 'batch'      # 0 s
Invalid JSON input: EOF while parsing a value at line 1 column 0. Expected an array of string arrays, …

Why

The parser is the one place both the desktop bridge and the orcad external-Chromium session read agent-browser output, so fixing it there covers both. The external-Chromium session already ended stdin (run-process.ts), so ending it in the desktop bridge makes the two match. A batch's overall exit code says nothing the per-step results don't already say, so returning the steps beats turning the whole call into an error.

Linked Issue

No issue. This came out of the browser-use research re-run on agent-browser 0.39.4 (batch was listed as broken through exec).

Visual Proof

N/A: CLI output only, no UI change. Before/after terminal output is shown above.

Testing

  • Reproduced all three failures on a hidden dev build of main, then re-ran them on this branch (output above). macOS.

  • Three regression tests in agent-browser-bridge-command-transport.test.ts, both built from real agent-browser 0.39.4 replies: a two-step batch that exits 1 because one step failed, a --bail batch stopped at its first step, and a bare batch whose stdin must be closed. Each fails without the fix.

  • Ran every test file that depends on the changed modules (14 files, 176 tests).

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

AI Disclosure

Review

Codex and a Claude reviewer each did one round; neither found a P0, P1 or P2. I took one P3: the bare-batch test now fakes agent-browser's real empty-stdin reply. CodeRabbit's Major (a --bail batch stopped at step one came back as an error) held and is fixed: the parser tells Orca's own batches from exec ones by how the command was sent.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Cross-platform: ending stdin applies on every OS. Windows daemons that inherit stdio already went through the batch path, which always ended stdin.
  • Remote/SSH and mixed versions: the reply shape only changes for multi-step exec batch, which used to fail every time, so no caller depended on the old shape.
  • A one-step exec 'batch "get title"' now returns a one-item list too, so every exec batch reply has the same shape.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3a70cbd7-655c-4aa2-b9b6-4eaafb9ccf96
Commits

Reviewing files that changed from the base of the PR and between 3447108 and 3e2a04b.

Files selected for processing: 2
  • src/main/browser/agent-browser-batch-command.ts
  • src/main/browser/agent-browser-bridge-tab-routing.test.ts
Files skipped from review as they are similar to previous changes: 1
  • src/main/browser/agent-browser-batch-command.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

Walkthrough

The parser accepts execution options and treats array output as successful batch results when cliArgv is true. It removes lifecycle data from batch results and daemon envelope data, and checks arrays recursively for results that mint refs. The bridge and external session pass execution options to the parser. The raw process resolves successful parsed output even when the helper exits with an error, and closes child stdin whenever stdin is available. Tests cover batch results, invalid JSON input, and tab routing after a batch snapshot.

Priority: Normal

Merge Risk: Minimal · up to 3e2a0

Batch results retain their steps; no material merge risk was identified.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Description check Warning The description explains the user impact, implementation, rationale, testing, and before/after behavior. However, it states "No issue" even though the template requires an actual linked issue, and the… Add a valid issue reference under Linked Issue. Update the checklist to confirm that pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass, or state that CI will cover them. Complete the AI Disclosure section if the contributor is exter…
Docstring Coverage Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: returning all results from an exec batch instead of reporting "Unknown browser error".
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description explains the user impact, implementation, rationale, testing, and before/after behavior. However, it states "No issue" even though the template requires an actual linked issue, and the required command checks remain unchecked.

Resolution

Add a valid issue reference under Linked Issue. Update the checklist to confirm that pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass, or state that CI will cover them. Complete the AI Disclosure section if the contributor is external.

Full details: Docstring Coverage

Explanation

Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 5 functions across 8 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: caee9806-fe03-4d47-984c-45bcdfad0b5f
Commits

Reviewing files that changed from the base of the PR and between 0c99ccb and 085da92.

Files selected for processing: 4
  • src/main/browser/agent-browser-batch-command.ts
  • src/main/browser/agent-browser-bridge-command-transport.test.ts
  • src/main/browser/agent-browser-bridge-raw-process.ts
  • src/main/browser/agent-browser-bridge-test-harness.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 50f4a249-3765-4801-9cd1-dbb34900f00c
Commits

Reviewing files that changed from the base of the PR and between 085da92 and 54ce9ed.

Files selected for processing: 6
  • src/main/browser/agent-browser-batch-command.ts
  • src/main/browser/agent-browser-bridge-command-transport.test.ts
  • src/main/browser/agent-browser-bridge-execution.ts
  • src/main/browser/agent-browser-bridge-raw-process.ts
  • src/main/browser/agent-browser-bridge-result.ts
  • src/main/orcad/external-chromium-browser-session.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.

@AmoabaKelvin
AmoabaKelvin merged commit 561de18 into main Oct 30, 2026
68 of 69 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant