Skip to content

fix(browser): preserve successor tabs during stale cleanup - #155307

Merged
steipete merged 1 commit into
mainfrom
codex/subagent-browser-cleanup-guard-bf9611
Sep 22, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/subagent-browser-cleanup-guard-bf9611

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

An older subagent run can close a newer run's browser tabs when its cleanup resumes after plugin activation or another asynchronous wait.

User Impact

Replacing or resetting a subagent session stops its previous run from claiming more tabs for cleanup. A close already admitted still settles against that tab's captured ownership and preserves later registrations.

Why This Change Was Made

Carry the existing run-currentness callback through lazy Browser SDK activation, dashboard reconciliation, and tab-claim boundaries. Keep exact tab ownership and admitted-close settlement with the existing Browser cleanup owner. The optional SDK callback preserves existing callers.

Related: #150153.

Evidence

Retained qualification includes 521 passing owner/sibling cases across 12 files, nine expected pre-fix regression failures, five final registered-completion fixtures, 15 SDK compatibility fixtures, the selected changed gates, and a full build (538.83 seconds).

Isolated Linux qualification also exercised the emitted Browser APIs with Chromium 153.0.8010.12 through an isolated HTTP route: two actual tab deletions, survival after owner revocation, closure by a fresh owner, and preservation of an untracked tab. That browser proof uses volatile tracking. Durable claim and replacement behavior is covered separately by the SQLite regressions. The emitted synthetic HTTP boundary is recorded separately from real Chromium.

The refresh onto bf9611abc45ce668af7d7e8b6a322786aabf91b9 preserves all 15 qualified postimages and the exact patch. P2 review remains clean. Runtime/build evidence stays bound to the original 32c12d3eba7e78093e41393cbbaf9ff033a651c3 source and candidate tree 234a50240ccb20fc4274ebab687934043b96c86d; current-head CI remains part of landing.

No production Gateway or personal Chrome instance was changed. The owned Testbox was stopped and independently confirmed completed. A controller-tooling refresh during qualification was recorded; the product checks used the frozen remote source and lockfile.

Carry the current subagent cleanup owner through Browser activation, dashboard reconciliation, and tab claims. Let already admitted closes settle against their captured tab ownership without removing later registrations.
@clawsweeper

clawsweeper Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling extensions: browser size: M maintainer Maintainer-authored PR labels Sep 22, 2026
@steipete
steipete marked this pull request as ready for review September 22, 2026 00:38
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 22, 2026
@clawsweeper

clawsweeper Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 21, 2026, 8:45 PM ET / September 22, 2026, 00:45 UTC.

ClawSweeper review

What this changes

The PR prevents stale subagent cleanup from claiming successor browser tabs while preserving settlement of already-admitted closes and later tab registrations.

Merge readiness

✅ Ready for maintainer review

This remains a useful, focused fix absent from current main and the latest release. No blocking defect was found in the introduced patch; the maintainer-authored PR should remain open for normal landing.

Priority: P2
Reviewed head: cac8bcba3f09c374d357e5db509c13d8bab9f7b6

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused ownership repair with meaningful boundary regressions and no blocking correctness finding.
Proof confidence 🌊 off-meta tidepool Not applicable: The ordinary contributor-proof gate does not apply to this maintainer-authored PR, and the authority review found no unresolved introduced violation requiring exceptional proof. The body reports relevant Chromium revocation and fresh-owner results; the linked raw trace could not be independently inspected because its download host is blocked.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The ordinary contributor-proof gate does not apply to this maintainer-authored PR, and the authority review found no unresolved introduced violation requiring exceptional proof. The body reports relevant Chromium revocation and fresh-owner results; the linked raw trace could not be independently inspected because its download host is blocked.
Evidence reviewed 11 items Introduced patch identity: Reviewed the pinned merge-base-to-head delta, rather than endpoint drift. The checkout was clean before and after inspection; origin identifies openclaw/openclaw.
Run authority reaches Browser cleanup: The completion callback combines exact terminal-generation ownership, successor-run detection, and session-effects suppression. The lifecycle adapter forwards it, and the SDK rechecks it after asynchronous plugin activation.
Admission and settlement remain separate: Durable cleanup checks caller currentness before claiming a tab, then retains the existing exact cleanup-attempt owner. Volatile cleanup checks before reserving or retrying, and settlement deletes only captured registration identities. Dashboard reconciliation rechecks after board reads.
Findings None None.
Security None None.

How this fits together

Subagent completion asks the Browser plugin to close session-owned tabs. Cleanup passes through lazy plugin activation, dashboard reconciliation, and tab ownership checks before issuing browser close requests.

flowchart TD
  A[Subagent completion] --> B[Current run ownership]
  B --> C[Lazy Browser activation]
  C --> D[Dashboard reconciliation]
  D --> E[Admit tab cleanup]
  B --> E
  E --> F[Close captured browser target]
  F --> G[Retire matching registration]
  B --> H[Stop stale cleanup]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +31, Tests +325, Docs +4. Total +360 across 15 files.

View PR surface stats
Area Files Added Removed Net
Source 6 35 4 +31
Tests 8 356 31 +325
Docs 1 4 0 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 15 395 35 +360

Review metrics

Metric Value Why it matters
SDK contract 1 optional callback; 0 new required arguments The cleanup guard extends a public helper while retaining existing callback-free behavior.

Technical review

Best possible solution:

Keep cleanup admission with the current run and settlement with the existing exact tab owner, preserving callback-free SDK callers.

Do we have a high-confidence way to reproduce the issue?

Yes, from source: suspend Browser activation, replace or reset the subagent session, then resume cleanup; current main forwards no run-currentness guard. This review did not execute that scenario.

Is this the best way to solve the issue?

Yes. The patch extends existing ownership checks across the actual asynchronous boundaries and reuses the existing tab claim and settlement owners.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 000a635e3423.

Labels

Label changes:

  • add P2: This repairs a bounded browser-cleanup race during subagent replacement or reset.
  • add merge-risk: 🚨 compatibility: The public Browser maintenance helper gains an optional callback; the maintainer-described compatibility contract and omitted-callback coverage preserve existing callers.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The ordinary contributor-proof gate does not apply to this maintainer-authored PR, and the authority review found no unresolved introduced violation requiring exceptional proof. The body reports relevant Chromium revocation and fresh-owner results; the linked raw trace could not be independently inspected because its download host is blocked.

Label justifications:

  • P2: This repairs a bounded browser-cleanup race during subagent replacement or reset.
  • merge-risk: 🚨 compatibility: The public Browser maintenance helper gains an optional callback; the maintainer-described compatibility contract and omitted-callback coverage preserve existing callers.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The ordinary contributor-proof gate does not apply to this maintainer-authored PR, and the authority review found no unresolved introduced violation requiring exceptional proof. The body reports relevant Chromium revocation and fresh-owner results; the linked raw trace could not be independently inspected because its download host is blocked.

Evidence

What I checked:

  • Introduced patch identity: Reviewed the pinned merge-base-to-head delta, rather than endpoint drift. The checkout was clean before and after inspection; origin identifies openclaw/openclaw. (cac8bcba3f09)
  • Run authority reaches Browser cleanup: The completion callback combines exact terminal-generation ownership, successor-run detection, and session-effects suppression. The lifecycle adapter forwards it, and the SDK rechecks it after asynchronous plugin activation. (src/agents/subagents/registry/subagent-registry-lifecycle-cleanup.ts:599, cac8bcba3f09)
  • Admission and settlement remain separate: Durable cleanup checks caller currentness before claiming a tab, then retains the existing exact cleanup-attempt owner. Volatile cleanup checks before reserving or retrying, and settlement deletes only captured registration identities. Dashboard reconciliation rechecks after board reads. (extensions/browser/src/browser/session-tab-cleanup-claim.ts:182, cac8bcba3f09)
  • Final browser effect retains ownership checks: The existing CDP closer verifies browser fingerprints and rechecks the captured cleanup claim immediately before Target.closeTarget. The patch does not change that contract, persisted record formats, or target routing. (extensions/browser/src/browser/cdp.helpers.ts:425, cac8bcba3f09)
  • Current main still needs the fix: Fetched main's SDK facade lacks the currentness parameter and post-activation check. Its SDK facade and tab registry match the corresponding pre-patch files. (src/plugin-sdk/browser-maintenance.ts:24, 000a635e3423)
  • Latest release comparison: The supplied latest release, v2026.9.5, also lacks the SDK guard propagation; this is not already-shipped cleanup work. (src/plugin-sdk/browser-maintenance.ts:24, ec9c1a13db89)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit cc69772 into main Sep 22, 2026
253 checks passed
@steipete
steipete deleted the codex/subagent-browser-cleanup-guard-bf9611 branch September 22, 2026 01:09
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 22, 2026
…155307)

Carry the current subagent cleanup owner through Browser activation, dashboard reconciliation, and tab claims. Let already admitted closes settle against their captured tab ownership without removing later registrations.

Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation extensions: browser maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant