Skip to content

fix: harden subagent completion fallback delivery#79405

Open
bingo30008196 wants to merge 3 commits into
openclaw:mainfrom
bingo30008196:danbi/delivery-patch-v2-fallback-recovery-20260508
Open

fix: harden subagent completion fallback delivery#79405
bingo30008196 wants to merge 3 commits into
openclaw:mainfrom
bingo30008196:danbi/delivery-patch-v2-fallback-recovery-20260508

Conversation

@bingo30008196

@bingo30008196 bingo30008196 commented May 8, 2026

Copy link
Copy Markdown

Summary

  • Harden subagent completion delivery fallback around task-aware give-up paths.
  • Preserve taskId in pending delivery context and separate child run id from task id for idempotency.
  • Avoid persisting a transient primary announce failure as terminal before retry/give-up fallback can resolve.

Verification

  • OPENCLAW_TEST_FAST=1 node scripts/run-vitest.mjs run --config test/vitest/vitest.agents-core.config.ts src/agents/subagent-registry-lifecycle.test.ts — 19/19 PASS
  • pnpm check:test-types — PASS
  • pnpm build — PASS

Hold / not included

  • No gateway restart
  • No live Telegram smoke
  • No deploy

Danbi evidence:

  • Closeout: /home/danbi/.openclaw/agents/main/logs/delivery-patch-v2-recovery-closeout-20260508-215411.md
  • Drive fileId: 1B4j8QKb0wtK1G0x17a1xgeVDF9r25_WmvdeMCXuMf-o

Real behavior proof

  • Behavior or issue addressed: Subagent completion fallback delivery can lose/withhold requester-facing completion context when a task-aware give-up path retries after a transient primary announce failure.
  • Real environment tested: DESKTOP-3FEA2LO WSL2, OpenClaw-managed worktree /home/danbi/.openclaw/agents/main/worktrees/openclaw-c97b9f7-20260508, PR head 557f7544c8a4248348da7b4ec100500cd2ac782f.
  • Exact steps or command run after this patch: Inspected the real OpenClaw subagent trajectory/session logs for run 391cc989-7104-4eb5-8328-e4bb31ed04a3, confirmed the requester-visible finalization payload, then ran the targeted local verification commands listed above from the same worktree.
  • Evidence after fix: Terminal output / log excerpt from the real setup:
    2026-05-08T14:01:16.277Z model.completed 391cc989-7104-4eb5-8328-e4bb31ed04a3
    ✅ PR #79405 CI follow-up finalization complete.
    - Commit: 557f7544c8a4248348da7b4ec100500cd2ac782f
    - Message: fix: constrain task status delivery access
    - Pushed: fork danbi/delivery-patch-v2-fallback-recovery-20260508
    
    Local evidence logs: /home/danbi/.openclaw/agents/main/logs/delivery-patch-v2-dev-unreported-verify-corrected-20260508-224031.md and /home/danbi/.openclaw/agents/main/logs/pr79405-failed-log-excerpts-20260508-231522.md.
  • Observed result after fix: The actual subagent completion payload included the commit SHA, changed-files/cleanup outcome, verification result summary, and push result instead of only an incomplete raw test dump.
  • What was not tested: Gateway restart, live Telegram smoke, deploy, and merge were intentionally not performed.

@bingo30008196
bingo30008196 requested review from a team as code owners May 8, 2026 12:56
@openclaw-barnacle openclaw-barnacle Bot added triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. docs Improvements or additions to documentation channel: discord Channel integration: discord channel: googlechat Channel integration: googlechat channel: imessage Channel integration: imessage channel: line Channel integration: line channel: matrix Channel integration: matrix channel: mattermost Channel integration: mattermost channel: msteams Channel integration: msteams channel: nextcloud-talk Channel integration: nextcloud-talk channel: nostr Channel integration: nostr channel: signal Channel integration: signal channel: slack Channel integration: slack channel: telegram Channel integration: telegram channel: tlon Channel integration: tlon channel: voice-call Channel integration: voice-call channel: whatsapp-web Channel integration: whatsapp-web channel: zalo Channel integration: zalo channel: zalouser Channel integration: zalouser app: android App: android app: ios App: ios app: macos App: macos app: web-ui App: web-ui gateway Gateway runtime extensions: copilot-proxy Extension: copilot-proxy extensions: diagnostics-otel Extension: diagnostics-otel extensions: llm-task Extension: llm-task extensions: lobster Extension: lobster labels May 8, 2026
@clawsweeper

clawsweeper Bot commented May 8, 2026

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed July 3, 2026, 5:06 PM ET / 21:06 UTC.

Summary
The PR adds task-aware subagent completion fallback delivery, taskId propagation into pending delivery state, direct/direct-thread fallback sends, new task delivery statuses, and lifecycle tests.

PR surface: Source +526, Tests +152. Total +678 across 9 files.

Reproducibility: yes. at source level. Related live reports establish the completion-loss class, and this branch’s blockers are traceable in the task-context, direct-fallback, and persisted-status paths.

Review metrics: 2 noteworthy metrics.

  • Task Delivery Status Surface: 5 added. The branch writes new persisted delivery statuses, so parser, store, audit, and upgrade compatibility matter before merge.
  • Direct Completion Fallback Paths: 2 added. The new direct and direct-thread fallback paths change exactly-once visible delivery and session mirror behavior.

Root-cause cluster
Relationship: partial_overlap
Canonical: #67777
Summary: This PR overlaps the broader subagent completion delivery-loss cluster, but the open durable-delivery issue remains canonical because this branch is conflicting and still has delivery/session-state blockers.

Members:

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

Merge readiness
Overall: 🧂 unranked krab
Proof: 🦞 diamond lobster
Patch quality: 🧂 unranked krab
Result: blocked by patch quality or review findings.

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

Rank-up moves:

  • Rebase against current main before renewed merge review.
  • Preserve requester-origin fallback and mirrored direct-message or durable queue semantics.
  • Update persisted delivery-status parser, store, and audit coverage if new statuses remain.

Mantis proof suggestion
A live Telegram transcript would materially show whether the changed fallback reaches the requester exactly once after active requester wake failure. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis telegram live: verify a subagent completion fallback reaches the requester exactly once after active requester wake failure.

Risk before merge

  • [P1] The branch is currently conflicting, so maintainers need a rebase before reviewing the actual merged result.
  • [P2] The direct/direct-thread fallback can expose raw completion text to external channel targets without current direct-message and transcript-mirror guardrails.
  • [P1] The PR adds persisted task delivery status strings that need parser, SQLite store, audit, and upgrade coverage after rebase.
  • [P1] The broader durable completion-delivery design remains open in [Bug]: Subagent completion delivery can be lost on direct-announce timeout, drain, or orphan prune #67777, so this branch should not become the permanent contract without maintainer consolidation.

Maintainer options:

  1. Rebase Around Current Delivery Contracts (recommended)
    Refresh the branch on current main and preserve requester-origin fallback, mirrored direct-message gating, and task status parser/store compatibility before renewed review.
  2. Consolidate Under Canonical Durable Delivery
    Pause this branch if maintainers want [Bug]: Subagent completion delivery can be lost on direct-announce timeout, drain, or orphan prune #67777 or the queue-first maintainer PR to own the permanent completion-delivery contract.
  3. Accept Broader Raw Fallback Semantics
    Maintainers could intentionally allow broader raw fallback sends, but that needs explicit approval plus group/thread, session-state, and upgrade proof.

Next step before merge

  • [P2] Manual review is needed because the branch requires a rebase plus maintainer consolidation of the durable fallback/session-state contract, not a narrow automated repair.

Security
Needs attention: No supply-chain changes were found, but the raw fallback send introduces a privacy-sensitive delivery concern.

Review findings

  • [P1] Keep requester-origin delivery when task context is absent — src/agents/subagent-announce.ts:564-570
  • [P1] Constrain fallback sends to mirrored direct messages — src/agents/subagent-announce-delivery.ts:784-795
  • [P1] Keep delivery-status parsing in sync — src/tasks/task-registry.types.ts:19-23
Review details

Best possible solution:

Land or sponsor one rebased durable completion-delivery design that preserves requester-origin fallback, direct-message or durable-queue guardrails, task-ledger compatibility, and live transport proof.

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

Yes, at source level. Related live reports establish the completion-loss class, and this branch’s blockers are traceable in the task-context, direct-fallback, and persisted-status paths.

Is this the best way to solve the issue?

No. This is a plausible mitigation, but the best fix must preserve current-main requester-origin fallback, mirrored or durable delivery semantics, and persisted-status compatibility before it is merge-ready.

Full review comments:

  • [P1] Keep requester-origin delivery when task context is absent — src/agents/subagent-announce.ts:564-570
    This returns false whenever task id or task delivery requester origin is missing, even though directOrigin was already resolved from the requester session. Task status context should enhance completion delivery rather than suppress the existing requester-origin fallback.
    Confidence: 0.86
  • [P1] Constrain fallback sends to mirrored direct messages — src/agents/subagent-announce-delivery.ts:784-795
    The fallback send accepts any resolved channel/thread target and omits agentId plus mirror metadata. For group/thread or message-tool-only routes, that bypasses the requester-agent rewrite and leaves session state unaware of the visible send, so retries or later prompts can duplicate or miss delivered context.
    Confidence: 0.84
  • [P1] Keep delivery-status parsing in sync — src/tasks/task-registry.types.ts:19-23
    These new statuses can be written through detached task delivery updates, but current main restores SQLite rows through a closed delivery-status parser. A rebased version needs to update the parser/store/audit tests or avoid persisting new status strings, otherwise upgraded checkouts can fail to read rows containing them.
    Confidence: 0.8

Overall correctness: patch is incorrect
Overall confidence: 0.88

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P1: The PR targets a broken subagent completion workflow where finished work can fail to reach users in real agent/channel sessions.
  • merge-risk: 🚨 compatibility: The patch adds persisted delivery-status values and changes retry/give-up fallback behavior that existing runs and status consumers may observe after upgrade.
  • merge-risk: 🚨 message-delivery: The patch can send completion text directly to external channel targets instead of preserving the current requester-agent or mirrored direct-message delivery contract.
  • merge-risk: 🚨 session-state: The patch can mark fallback delivery successful without the requester-session mirror evidence current main uses to keep transcript state aligned.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦞 diamond lobster and patch quality is 🧂 unranked krab.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (logs): The PR body includes after-fix runtime log evidence from an OpenClaw-managed WSL2 worktree plus targeted verification commands; live Telegram or gateway proof remains a merge-risk reducer.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes after-fix runtime log evidence from an OpenClaw-managed WSL2 worktree plus targeted verification commands; live Telegram or gateway proof remains a merge-risk reducer.
  • mantis: telegram-visible-proof: Mantis should capture Telegram visible proof. The PR changes requester-visible subagent completion delivery on Telegram-capable paths, so a short Telegram proof can materially show exactly-once fallback delivery.
Evidence reviewed

PR surface:

Source +526, Tests +152. Total +678 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 8 550 24 +526
Tests 1 157 5 +152
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 707 29 +678

Security concerns:

  • [medium] Avoid raw fallback exposure outside direct mirrors — src/agents/subagent-announce-delivery.ts:784
    The fallback can send raw completion text to any resolved channel/thread target without direct-message gating or transcript mirror metadata, which can expose subagent output on the wrong visible surface.
    Confidence: 0.78

What I checked:

  • Repository policy applied: Root and scoped agent policy were read; OpenClaw treats fallback behavior, session state, persisted task state, and message delivery as compatibility-sensitive review surfaces. (AGENTS.md:17, 010b61746379)
  • Live PR state: GitHub reports head 6da0a18 as mergeable=CONFLICTING and mergeStateStatus=DIRTY, so a rebase is required before maintainers can judge the actual three-way result. (6da0a184c5fb)
  • PR head suppresses requester-origin fallback: The PR returns false on task_id_missing/context_missing before using the already resolved requester directOrigin path, which can drop completion delivery when task status context is absent. (src/agents/subagent-announce.ts:564, 6da0a184c5fb)
  • PR head raw fallback send: sendCompletionFallback sends directly to the resolved channel/thread target without direct-message gating, agentId, or transcript mirror metadata. (src/agents/subagent-announce-delivery.ts:784, 6da0a184c5fb)
  • Current fallback contract: Current main gates text completion direct fallback to direct-message targets and mirrors successful direct sends back to the requester session with agentId and idempotency metadata. (src/agents/subagent-announce-delivery.ts:1042, 010b61746379)
  • Persisted delivery status parser: Current main restores SQLite task rows through a closed TASK_DELIVERY_STATUSES parser, so adding persisted delivery statuses requires parser/store/audit coverage after rebase. (src/tasks/task-registry.types.ts:43, 010b61746379)

Likely related people:

  • vincentkoc: Recent commits and the canonical issue discussion tie Vincent Koc to partial subagent completion fallback fixes and QA coverage in this delivery area. (role: recent area contributor; confidence: high; commits: a1b656705992, a911eb748bd0, da000ce511fa; files: src/agents/subagent-announce-delivery.ts, src/agents/subagent-registry-lifecycle.ts, src/tasks/task-registry.ts)
  • steipete: Peter Steinberger authored the open queue-first completion announce PR and has feature-history commits around subagent registry lifecycle boundaries. (role: feature-history contributor; confidence: high; commits: f862685ed8e4; files: src/agents/subagent-registry.ts, src/agents/subagent-registry-lifecycle.ts, src/agents/subagent-announce-delivery.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.

@barnacle-openclaw

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

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

Labels

agents Agent runtime and tooling mantis: telegram-visible-proof Mantis should capture Telegram visible proof. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: L status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant