Skip to content

fix(agent): recover interrupted browser tool turns#210

Merged
DavidBabinec merged 1 commit into
mainfrom
fix/agent-browser-tool-recovery
Jul 11, 2026
Merged

fix(agent): recover interrupted browser tool turns#210
DavidBabinec merged 1 commit into
mainfrom
fix/agent-browser-tool-recovery

Conversation

@DavidBabinec

@DavidBabinec DavidBabinec commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

What changed

  • tie each chat turn to response-stream cancellation so reloads, disconnects, and failed enqueues abort the provider request, browser bridge, and conversation writer lock
  • treat a rejected browser bridge as one terminal transport failure: persist/emit one failed tool result, preserve already-billed usage, and stop instead of asking the model to retry against the same dead bridge
  • keep resolved { ok: false } browser-tool outcomes recoverable by the model
  • propagate active tool-result POST failures, distinguish them from intentional Stop, detect truncated NDJSON streams, and finalize every pending live tool badge
  • rehydrate unmatched or malformed persisted screenshot calls as interrupted errors without reconstructing session-only preview images
  • reconnect workspace MCP bridges with a fresh per-attempt controller when result delivery fails, while preserving protocol-level MCP tool errors
  • share interrupted-call recovery between browser history and provider replay, update the lifecycle documentation, and add focused regressions

Why

A server restart replaces the in-memory browser-bridge registry. The browser could finish capturing a screenshot, then POST its result to a new runtime that no longer owned the old request. The client previously ignored that 404, while the old turn waited 90 seconds and the model repeatedly retried the screenshot. This makes the stale turn terminate once, preserves the failed round's usage/cost, and gives both live and reloaded conversations an honest terminal state.

Verification

  • bun test
  • bun run build
  • bun run lint
  • bunx react-doctor --verbose --diff origin/main --no-score
  • focused lifecycle regressions across client rehydration/delivery, tool loop, chat cancellation, runner persistence, history replay, and MCP bridge recovery

@DavidBabinec
DavidBabinec force-pushed the fix/agent-browser-tool-recovery branch from c4b2b34 to 91e75e2 Compare July 11, 2026 15:28
@DavidBabinec
DavidBabinec marked this pull request as ready for review July 11, 2026 15:38
@DavidBabinec
DavidBabinec merged commit a2111db into main Jul 11, 2026
11 of 12 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