Skip to content

fix: prevent stale subagent notifications from failing chats - #149863

Merged
fuller-stack-dev merged 1 commit into
openclaw:mainfrom
fuller-stack-dev:fix/subagent-completion-cancellation-20260916
Sep 16, 2026
Merged

fuller-stack-dev merged 1 commit into
openclaw:mainfrom
fuller-stack-dev:fix/subagent-completion-cancellation-20260916

Conversation

@fuller-stack-dev

@fuller-stack-dev fuller-stack-dev commented Sep 16, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes a main conversation showing "This turn ended before a reply: subagent source lifecycle changed before completion delivery" when a completed subagent reports the same result twice or its queued notification becomes obsolete.

User Impact

Unchanged completion results remain deliverable. Obsolete notifications are cancelled without adding a failed-reply message to the conversation or replaying stale work after restart. Genuine execution failures remain visible.

Why This Change Was Made

Both lifecycle events and agent.wait can report completion. Replacing an unchanged outcome invalidated the authority captured by an already prepared notification. Preserve that outcome when its facts have not changed, and route actual ownership loss through the existing Gateway cancellation mechanism. Stale-result checks and private-completion observation deadlines remain enforced.

Evidence

  • Reproduced both failures on unmodified upstream code. Identical and older equivalent completion reports invalidated prepared results; the real Gateway saved source revocation as a failed session and appended a run-failed-before-reply notice.
  • 569 focused tests pass with the fix, including the real Gateway/SQLite cancellation receipt and replay after restart, changed-result rejection, requester reset/replacement, genuine provider failure, required receipt-write failure, and delayed private admission.
  • The Gateway proof uses a controlled agent command with real admission, lifecycle persistence and SQLite. It does not invoke an external model or modify a live deployment.
  • Production and test type checks, targeted lint, database guards and import-cycle checks passed. Independent autoreview reported no actionable P0-P2 findings; a source-blind operator probe passed all six observable Gateway/history/receipt clauses.
  • The seven producer/Gateway regression probes also pass on publication head f2f3deeea602a795c5ab8df349658e438b58aacc. Raw red/green results, Gateway observations and artifact manifest.

@clawsweeper

clawsweeper Bot commented Sep 16, 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 gateway Gateway runtime agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Sep 16, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 16, 2026
@clawsweeper

clawsweeper Bot commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 16, 2026, 3:54 AM ET / 07:54 UTC.

ClawSweeper review

What this changes

Preserves equivalent subagent completion results and cancels obsolete notifications without marking the parent conversation as failed, with regression coverage for both paths.

Merge readiness

✅ Ready for maintainer review

This remains a useful, focused repair: fetched main still contains both failure mechanisms. No actionable introduced defect was found, and the supplied Gateway evidence supports cancellation without hiding genuine failures.

Priority: P2
Reviewed head: f2f3deeea602a795c5ab8df349658e438b58aacc

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with useful red/green regressions, substantive Gateway observations, and no blocking finding.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): Inspected Gateway/SQLite observations exercise the changed cancellation owner with revoked, successful, and failing execution, including durable replay after restart; publication-head regressions also preserve equivalent results and reject changed facts. This proves the internal completion boundary, without claiming live model or external-channel coverage.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): Inspected Gateway/SQLite observations exercise the changed cancellation owner with revoked, successful, and failing execution, including durable replay after restart; publication-head regressions also preserve equivalent results and reject changed facts. This proves the internal completion boundary, without claiming live model or external-channel coverage.
Evidence reviewed 7 items Introduced scope and current-main necessity: The pinned introduced delta contains the two production repairs and their tests. Comparing the production files from the merge base to fetched main produced no differences; fetched main still replaces equivalent outcomes and throws SourceOwnerChangedError without initiating cancellation.
Equivalent facts retain authority: The completion owner now retains the existing outcome only when its normalized facts are deeply equal. Prepared results still compare outcome, terminal reply, run, and transcript identity; changed timing, errors, and replies invalidate them.
Cancellation uses existing lifecycle owners: Source revocation aborts the execution signal and throws the existing direct-abort classification before further execution. The outer observer retains the source-change diagnostic. Private observation deadlines remain separate from execution cancellation, and the Gateway facade cancels only its captured run registration.
Findings None None.
Security None None.

How this fits together

Subagent completion delivery carries finished child-task results back into the parent conversation. The registry supplies the result, while Gateway admission, cancellation, and durable receipts control whether that notification executes or replays.

flowchart TD
  A[Child completion reports] --> B[Registry normalizes terminal facts]
  B --> C[Prepared parent notification]
  C --> D{Source still current?}
  D -->|Yes| E[Gateway executes parent turn]
  D -->|No| F[Cancel obsolete notification]
  E --> G[Durable outcome and chat history]
  F --> G
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +15, Tests +134. Total +149 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 23 8 +15
Tests 2 134 0 +134
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 157 8 +149

Review metrics

None.

Technical review

Best possible solution:

Keep terminal-result identity stable for equivalent facts and settle revoked notifications through Gateway’s existing cancellation and replay contracts.

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

Yes: current-main source establishes both mechanisms, and supplied red/green probes exercise duplicate completion and source revocation. This read-only review did not execute tests.

Is this the best way to solve the issue?

Yes: the patch repairs the existing producers and cancellation path without weakening result validation or adding another delivery owner.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: Repairs a bounded subagent-completion race that can incorrectly fail the parent conversation.
  • add proof: sufficient: Contributor real behavior proof is sufficient. Inspected Gateway/SQLite observations exercise the changed cancellation owner with revoked, successful, and failing execution, including durable replay after restart; publication-head regressions also preserve equivalent results and reject changed facts. This proves the internal completion boundary, without claiming live model or external-channel coverage.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): Inspected Gateway/SQLite observations exercise the changed cancellation owner with revoked, successful, and failing execution, including durable replay after restart; publication-head regressions also preserve equivalent results and reject changed facts. This proves the internal completion boundary, without claiming live model or external-channel coverage.

Label justifications:

  • P2: Repairs a bounded subagent-completion race that can incorrectly fail the parent conversation.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): Inspected Gateway/SQLite observations exercise the changed cancellation owner with revoked, successful, and failing execution, including durable replay after restart; publication-head regressions also preserve equivalent results and reject changed facts. This proves the internal completion boundary, without claiming live model or external-channel coverage.
  • proof: sufficient: Contributor real behavior proof is sufficient. Inspected Gateway/SQLite observations exercise the changed cancellation owner with revoked, successful, and failing execution, including durable replay after restart; publication-head regressions also preserve equivalent results and reject changed facts. This proves the internal completion boundary, without claiming live model or external-channel coverage.

Evidence

What I checked:

Likely related people:

  • Ayaan Zaidi: Raw commit 31172cf adds src/agents/subagents/announce/subagent-announce-result.ts:49 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 31172cf54466; files: src/agents/subagents/announce/subagent-announce-result.ts)
  • 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.

@fuller-stack-dev
fuller-stack-dev merged commit b47ba10 into openclaw:main Sep 16, 2026
229 checks passed
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling gateway Gateway runtime maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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