Repository navigation
fix(subagents): avoid cleanup failures during overlapping completion - #163741
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed October 2, 2026, 3:55 PM ET / 19:55 UTC (Revision 2). ClawSweeper reviewWhat this changesThe PR prevents overlapping subagent completions from treating a rejected browser-cleanup claim as a failure while preserving genuine persistence errors. Merge readiness✅ Ready for maintainer review The fix remains useful on current main. No actionable correctness or security finding was identified, and the latest test-only correction preserves the prior review outcome. Priority: P2 Review scores
Verification
How this fits togetherSubagents report completion through a lifecycle controller that persists terminal state, cleans up browser resources, and returns results to the parent. Concurrent callbacks must leave cleanup to the current run owner. flowchart TD
A[Completion callbacks] --> B[Subagent lifecycle controller]
B --> C[Persist terminal state]
C --> D[Claim browser cleanup]
D --> E{Original owner still current?}
E -->|Yes| F[Cleanup and completion delivery]
E -->|No| G[Retire obsolete callback]
D --> H[Propagate persistence failures]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +20, Tests +268. Total +288 across 2 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep the existing lifecycle and retirement owners, treating only positively identified pre-commit ownership loss as a harmless retirement. Do we have a high-confidence way to reproduce the issue? Yes, from source: a newer terminal publication or session generation can invalidate a browser-cleanup claim while it waits in the persistence queue. The supplied deterministic regression targets that ordering; no runtime reproduction was executed here. Is this the best way to solve the issue? Yes. Exact error identity plus the not-committed outcome confines the exception to harmless ownership loss, while existing retirement and authority owners retain responsibility. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e42579142bca. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
@clawsweeper re-review Please review head |
|
🦞👀 Re-review progress:
|
…penclaw#163741) * fix(subagents): avoid cleanup failures during overlapping completion * test(subagents): bind retirement assertion to its spy
What Problem This Solves
Fixes subagent completion failing when overlapping completion callbacks or a newer run take browser-cleanup ownership while an older callback waits to persist its cleanup claim.
User Impact
Completed subagent work can finish without a spurious cleanup failure. The current owner retains browser cleanup; genuine persistence and authority failures remain visible. No configuration change is required.
Why This Change Was Made
Retire only the original callback's positively identified pre-commit ownership rejection. A superseded session uses the existing run-retirement path. Committed or uncertain writes and unrelated errors still propagate.
Related: #163725. The failure also reproduced without that PR's authority change.
Evidence
node scripts/run-vitest.mjs src/agents/subagents/registry/subagent-registry-terminal-effects.test.ts --maxWorkers=1— 8.67 seconds wall time, including 2.9 seconds of cached worker preparation; the six cases took 354 ms. CI seconds are pending the attached run.