Skip to content

fix(agents): preserve pending subagent completion announces#94349

Merged
sallyom merged 1 commit into
openclaw:mainfrom
sallyom:issue-93323
Jun 18, 2026
Merged

fix(agents): preserve pending subagent completion announces#94349
sallyom merged 1 commit into
openclaw:mainfrom
sallyom:issue-93323

Conversation

@sallyom

@sallyom sallyom commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #93323 by treating non-terminal direct announce responses as accepted delivery for subagent completion handoffs.

Previously subagent-announce-delivery mapped accepted / started / in_flight gateway responses to delivered: false for the plain completion-message branch, which let the registry retry budget exhaust and abandon the announce. The fix removes that inconsistent special case so pending direct announces return delivered: true consistently with the existing media completion path.

Root cause

sendSubagentAnnounceDirectly already classifies gateway accepted, started, and in_flight as non-terminal pending states. For completion handoffs with no media and no required message-tool delivery, it nevertheless returned completion_handoff_pending as a failed delivery. That turned a healthy accepted gateway run into a retryable/final failure at the registry layer.

Changes

  • Remove the completion_handoff_pending failure branch for non-terminal direct announce responses.
  • Add a regression test for pending plain completion announce delivery without media fallback.

Real behavior proof

Behavior addressed: Subagent completion announce delivery no longer treats a non-terminal gateway response as a failed delivery when there are no media URLs and no message-tool delivery requirement.

Real environment tested: Direct AWS Crabbox on Linux, provider aws, lease cbx_7b5a3efee072 (violet-shrimp), run run_ee5d6664b84e, portal https://crabbox.openclaw.ai/portal/runs/run_ee5d6664b84e. The run synced the production-only PR head 021466b57025fef7e1b7677ef9cfc945b650c750 and ran the QA Lab scenario against a real Gateway child with provider-mode live-frontier, openai/gpt-5.5, qa-channel, and fast mode enabled.

Exact steps or command run after this patch:

node scripts/crabbox-wrapper.mjs run --provider aws --allow-env OPENAI_API_KEY --idle-timeout 90m --ttl 240m --timing-json --full-resync --artifact-glob '.artifacts/qa-e2e/pr-94349-live-proof/**' --shell -- 'set -u
RUN_DIR=.artifacts/qa-e2e/pr-94349-live-proof
rm -rf "$RUN_DIR"
mkdir -p "$RUN_DIR"
export OPENCLAW_BUILD_PRIVATE_QA=1
export OPENCLAW_ENABLE_PRIVATE_QA_CLI=1
export OPENCLAW_LOG_LEVEL=debug
export OPENCLAW_QA_REDACT_PUBLIC_METADATA=1
printf "%s\n" "021466b57025fef7e1b7677ef9cfc945b650c750" | tee "$RUN_DIR/head.txt"
printf "%s\n" "issue-93323-ci" | tee "$RUN_DIR/branch.txt"
node scripts/run-node.mjs qa suite --provider-mode live-frontier --scenario subagent-completion-direct-fallback --fast --concurrency 1 --output-dir "$RUN_DIR" 2>&1 | tee "$RUN_DIR/qa-suite.log"'

Evidence after fix:

[qa-suite] provider start: live-frontier
[qa-suite] provider ready: live
[qa-suite] gateway start
[qa-suite] gateway ready: http://127.0.0.1:45907
[qa-suite] scenario start (1/1): subagent-completion-direct-fallback
[qa-suite] scenario pass (1/1): subagent-completion-direct-fallback
[qa-suite] run complete: passed=1 failed=0 total=1

Scenario: Subagent completion direct fallback
Step: yielded parent receives child completion through direct fallback
Details: Native subagent completed with:

`QA-SUBAGENT-DIRECT-FALLBACK-OK`

Run summary: provider=aws lease=cbx_7b5a3efee072 slug=violet-shrimp run=run_ee5d6664b84e exitCode=0 totalMs=224578
Artifact bundle: .crabbox/runs/run_ee5d6664b84e/run_ee5d6664b84e-artifacts.tgz

Observed result after fix: The live QA scenario ran through QA Lab, a real Gateway child, qa-channel, and live OpenAI frontier model routing. The parent launched a native subagent, yielded, and the requester received the child completion marker QA-SUBAGENT-DIRECT-FALLBACK-OK through the completion fallback path. The focused regression still covers the exact pending direct-announce branch by asserting a gateway accepted response now reports delivered: true and does not trigger direct fallback delivery for the plain completion-handoff branch.

What was not tested: Mantis Telegram proof remains unreliable for this PR, and this does not claim to close the broader delivery-loss trackers in #44925 or #52249. The live proof targets the implicated Gateway/subagent completion path for #93323.

Additional verification

node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/core-test.tsbuildinfo
# passed locally after final rebase

node scripts/run-vitest.mjs src/agents/subagent-announce-delivery.test.ts -- --reporter=verbose
# passed locally after final rebase

node scripts/run-vitest.mjs extensions/qa-lab/src/providers/mock-openai/server.test.ts
# passed locally while diagnosing the stale mock QA fixture; QA-lab fixture changes are intentionally left out of this PR and should be handled as follow-up testing debt.

Notes

No agent transcript is included in this PR body.

sallyom commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@clawsweeper

clawsweeper Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed June 18, 2026, 7:11 PM ET / 23:11 UTC.

Summary
This PR deletes the completion_handoff_pending failure branch for non-terminal direct subagent completion announces and adds a regression test for accepted plain completion delivery.

PR surface: Source -12, Tests +38. Total +26 across 2 files.

Reproducibility: yes. at source level: current main and v2026.6.8 map non-terminal plain completion handoffs to completion_handoff_pending, and registry lifecycle treats false delivery as retry/give-up state. I did not run a fresh current-main live repro in this read-only review.

Review metrics: 1 noteworthy metric.

  • Pending delivery semantics changed: 1 failure branch removed. This branch decides whether non-terminal direct completion handoffs consume registry retry budget or are credited as accepted delivery.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #93323
Summary: This PR is the focused candidate fix for the canonical pending direct-announce completion-loss issue; broader durable fallback PRs and delivery-loss issues overlap but are not merged canonical replacements.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🦞 diamond lobster
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • none.

Mantis proof suggestion
A live Telegram transcript would add useful transport-visible proof that a requester receives exactly one completion after a pending or accepted handoff. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis telegram live: verify a sessions_spawn child completion reaches the requester exactly once when direct announce returns a pending or accepted handoff.

Risk before merge

  • [P1] The patch intentionally credits Gateway accepted, started, and in_flight responses as delivered for the plain completion branch; maintainers need to accept that gateway acceptance is durable enough for this narrow handoff.
  • [P1] This should only close the canonical pending direct-announce accounting bug after merge; broader completion-loss, yielded-parent wake, monitor lifecycle, and durable-queue work remains tracked separately.

Maintainer options:

  1. Merge With Delivery Contract Acknowledged (recommended)
    Maintainers can merge this narrow fix if they accept non-terminal Gateway acceptance as sufficient delivery credit for plain completion announces.
  2. Pause For Consumption-Backed Delivery
    If maintainers want a stronger guarantee, pause this PR and choose a durable or consumption-backed completion-delivery design instead.

Next step before merge

  • [P2] Manual review remains because the PR has a protected maintainer label and the remaining question is delivery-contract acceptance, not an automated code repair.

Security
Cleared: The diff only changes agent delivery control flow and a focused Vitest regression; it does not touch dependencies, workflows, credentials, packaging, or external code execution.

Review details

Best possible solution:

Land the narrow consistency fix if maintainers accept accepted-status delivery credit for this branch, while leaving broader durable queue and session-state work to separate canonical follow-ups.

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

Yes, at source level: current main and v2026.6.8 map non-terminal plain completion handoffs to completion_handoff_pending, and registry lifecycle treats false delivery as retry/give-up state. I did not run a fresh current-main live repro in this read-only review.

Is this the best way to solve the issue?

Yes for the narrow reported branch: deleting the inconsistent pending-status failure case aligns plain completions with the existing pending direct/media behavior. A durable queue remains the safer broader design only if maintainers want stronger persistence semantics.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against bb44c5326ee2.

Label changes

Label justifications:

  • P1: The PR targets subagent completion message loss that can leave requester workflows waiting on completed child work.
  • merge-risk: 🚨 message-delivery: The diff changes when pending direct completion announces are considered delivered, which affects whether requester completion messages are retried or credited.
  • 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 (live_output): The PR body includes live Crabbox QA Lab output showing the requester received the child completion marker through the targeted path, and compare checks show the current head has the same two-file patch as the proven head.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes live Crabbox QA Lab output showing the requester received the child completion marker through the targeted path, and compare checks show the current head has the same two-file patch as the proven head.
  • mantis: telegram-visible-proof: Mantis should capture Telegram visible proof. Although the code is channel-generic, the requester-visible completion behavior can be demonstrated in a short Telegram proof run and the PR already carries that review label.
Evidence reviewed

PR surface:

Source -12, Tests +38. Total +26 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 0 12 -12
Tests 1 38 0 +38
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 38 12 +26

What I checked:

  • Repository policy applied: Root and scoped agents policy were read; they require whole-path review for agent delivery changes, including callers, sibling delivery paths, proof, and merge-risk treatment. (AGENTS.md:1, bb44c5326ee2)
  • Current main still has the failure branch: Current main still returns delivered: false with reason completion_handoff_pending when a non-terminal direct completion announce has no expected media and no message-tool requirement. (src/agents/subagent-announce-delivery.ts:1496, bb44c5326ee2)
  • Latest release still has the branch: The latest release tag v2026.6.8 contains the same completion_handoff_pending branch, so this is not already shipped fixed. (src/agents/subagent-announce-delivery.ts:1496, 844f405ac1be)
  • PR removes only the inconsistent pending failure: The live PR diff removes the special completion-handoff failure block, allowing non-terminal direct responses to return the existing delivered: true, path: direct result. (src/agents/subagent-announce-delivery.ts:1496, 0647bf44bdc2)
  • Regression test covers accepted plain completion: The added test drives a Slack-channel completion announce with gateway status accepted, expects direct delivery credit, and asserts no direct message fallback was called. (src/agents/subagent-announce-delivery.test.ts:4526, 0647bf44bdc2)
  • Delivery result controls fallback and retry behavior: Completion dispatch stops when direct delivery is credited; registry lifecycle records false delivery as retry/give-up state through onDeliveryResult, so this branch decides whether the registry keeps retrying or cleans up as delivered. (src/agents/subagent-announce-dispatch.ts:112, bb44c5326ee2)

Likely related people:

  • vincentkoc: Current blame and recent file history for the pending-handoff branch and adjacent subagent registry lifecycle work point to this person as a useful routing candidate. (role: recent area contributor; confidence: medium; commits: b6a06f0e498b, 8fce663861a7, 48042c387556; files: src/agents/subagent-announce-delivery.ts, src/agents/subagent-registry-lifecycle.ts)
  • steipete: History shows foundational refactors for the subagent announce delivery pipeline and helper split, plus repeated adjacent routing and cleanup work in this area. (role: feature-history owner; confidence: high; commits: 4258a3307f5a, b75be0914491, b0d9d1d2dae8; files: src/agents/subagent-announce-delivery.ts, src/agents/subagent-announce-dispatch.ts, src/agents/subagent-registry-lifecycle.ts)
  • maxpetrusenko: Authored the completion announce delivery target inheritance fix in the same delivery module, relevant to target/origin behavior around completion handoffs. (role: adjacent delivery contributor; confidence: medium; commits: 8262078ee50c; files: src/agents/subagent-announce-delivery.ts)
  • Takhoffman: Authored subagent announce dispatch work around dropped queue deliveries, which shares the same delivery result and fallback contract surface. (role: adjacent dispatch contributor; confidence: medium; commits: ab8c834aabff, 0fc27409c0e4; files: src/agents/subagent-announce-dispatch.ts)
  • 100yenadmin: Authored recent dedupe work in subagent registry lifecycle, relevant to avoiding duplicate or missed completion announcements after delivery is credited. (role: adjacent completion-dedupe contributor; confidence: medium; commits: 47c0a5135a0f; files: src/agents/subagent-registry-lifecycle.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Jun 18, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Jun 18, 2026
@clawsweeper clawsweeper Bot added the mantis: telegram-visible-proof Mantis should capture Telegram visible proof. label Jun 18, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jun 18, 2026
@clawsweeper clawsweeper Bot added the status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. label Jun 18, 2026

sallyom commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

Merge-ready after the remaining queued CI completes.

This is the best narrow fix for #93323: the PR fixes the concrete delivery bug where a non-terminal/accepted direct announce for a plain subagent completion was counted as failed delivery, consuming retry budget and losing the completion. The change keeps scope tight by removing only that failed-delivery branch and adding focused regression coverage.

Will merge this narrow fix rather than broaden the PR now. The broader delivery/lifecycle cluster should stay follow-up work; widening this PR would mix a proven #93323 fix with less-bounded behavior and increase merge risk.

Verification is clean: local focused tests passed, PR review/ClawSweeper state is clean, and Real Behavior Proof is sufficient. No backward-incompatible or breaking changes are expected; this only treats an already accepted/pending Gateway announce as accepted delivery instead of retryable failure.

@sallyom
sallyom merged commit 95c87e3 into openclaw:main Jun 18, 2026
191 of 198 checks passed
vincentkoc added a commit that referenced this pull request Jun 19, 2026
* 'main' of https://github.com/openclaw/openclaw: (82 commits)
  fix(e2e): validate chat tools body limit
  fix(e2e): honor chat tools body limit
  fix(e2e): validate chat tools timeout
  fix(e2e): give cleanup smoke build heap headroom
  fix(e2e): validate plugin lifecycle limits
  refactor(auto-reply): add lifecycle storage seams (#93685)
  fix: preserve pending subagent completion announces (#94349)
  fix(e2e): validate plugin log limits before setup
  fix(e2e): validate codex media timeout
  fix(e2e): validate fixture log limits
  fix(e2e): validate cleanup log limits
  fix(e2e): validate docker log limits
  fix(live): validate docker pids limits
  fix(e2e): validate docker pids limits
  test: fold channel message flows into qa e2e (#93174)
  fix(e2e): validate docker build limits
  Prevent Codex thread rotation from losing next-step context (#94093)
  fix(e2e): validate fixture cleanup interval
  fix(agents): correct claw-score validation workflow
  fix(e2e): validate log tail limits
  ...
RomneyDa pushed a commit that referenced this pull request Jun 19, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jun 19, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jun 19, 2026
* 'main' of https://github.com/openclaw/openclaw: (82 commits)
  fix(e2e): validate chat tools body limit
  fix(e2e): honor chat tools body limit
  fix(e2e): validate chat tools timeout
  fix(e2e): give cleanup smoke build heap headroom
  fix(e2e): validate plugin lifecycle limits
  refactor(auto-reply): add lifecycle storage seams (openclaw#93685)
  fix: preserve pending subagent completion announces (openclaw#94349)
  fix(e2e): validate plugin log limits before setup
  fix(e2e): validate codex media timeout
  fix(e2e): validate fixture log limits
  fix(e2e): validate cleanup log limits
  fix(e2e): validate docker log limits
  fix(live): validate docker pids limits
  fix(e2e): validate docker pids limits
  test: fold channel message flows into qa e2e (openclaw#93174)
  fix(e2e): validate docker build limits
  Prevent Codex thread rotation from losing next-step context (openclaw#94093)
  fix(e2e): validate fixture cleanup interval
  fix(agents): correct claw-score validation workflow
  fix(e2e): validate log tail limits
  ...
cxbAsDev pushed a commit to cxbAsDev/openclaw that referenced this pull request Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR mantis: telegram-visible-proof Mantis should capture Telegram visible proof. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. 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.

subagent-announce-delivery: pending direct-announce drops completion notifications across all spawn depths (likely root of #92405)

1 participant