fix(agents): harden subagent completion delivery#82834
Conversation
|
Codex review: needs real behavior proof before merge. Summary Reproducibility: yes. The current-main source path shows active wake failures can return before requester-agent handoff, and group/channel subagent completions do not participate in the shared message-tool-only policy; linked reports add concrete delivery-drop evidence. Real behavior proof Next step before merge Security Review detailsBest possible solution: Land a rebased version of this consolidated runtime fix if maintainer review and CI stay clean, while keeping the broader late-success/reconcile lifecycle work in the separate linked follow-ups. Do we have a high-confidence way to reproduce the issue? Yes. The current-main source path shows active wake failures can return before requester-agent handoff, and group/channel subagent completions do not participate in the shared message-tool-only policy; linked reports add concrete delivery-drop evidence. Is this the best way to solve the issue? Yes for the narrow bug. The PR keeps delivery agent-mediated, reuses the existing visible-reply policy, and avoids raw child-output sends; late-success watching and durable reconciliation are correctly left to separate work. Acceptance criteria:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 9e67f53b913a. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: adf6bd7703
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const requiresMessageToolDelivery = | ||
| agentMediatedCompletion && | ||
| (expectedMediaUrls.length > 0 || | ||
| completionRequiresMessageToolDelivery({ | ||
| cfg, |
There was a problem hiding this comment.
Skip message-tool-only checks for internal subagent handoffs
Do not apply completionRequiresMessageToolDelivery(...) to internal requester-agent handoffs (requesterIsSubagent=true), because these deliveries are intentionally deliver=false and should produce an internal orchestration reply, not a user-facing message-tool send. With this change, nested subagent completions that inherit a group/channel origin can be forced into message_tool_only, then fail with "completion agent did not deliver through the message tool", which causes retries/fallback and can drop completion propagation to the parent subagent.
Useful? React with 👍 / 👎.
Co-authored-by: Galin Iliev <galini@microsoft.com> Co-authored-by: Ava Daigo <theavadaigo@gmail.com> Co-authored-by: Moeed Ahmed <moeedahmed@users.noreply.github.com>
adf6bd7 to
67b3d73
Compare
|
Landed in Thanks @galiniliev, @yozakura-ava, and @moeedahmed. I kept the co-author trailers on the landed commit and moved the changelog entry into the current Unreleased section. Verification:
|
Summary
Fixes #82803.
Refs #44925, #82784, #82787, #82804, #79059, and #80223.
This consolidates the narrow subagent completion delivery fixes from the related partial PRs into one runtime change:
subagent_announcecompletion handoffs now participate in agent-mediated completion delivery, so group/channel requester sessions inherit the existingmessage_tool_onlyvisible-reply policy instead of relying on a normal final reply that the user may never see.This intentionally does not solve the broader lifecycle/reconciliation work from #82784/#82787. Late-success watching and durable restart/reconcile semantics still belong in a follow-up.
Contributor credit preserved in the commit trailers for @galiniliev, @yozakura-ava, and @moeedahmed.
Verification
pnpm docs:listpnpm exec oxfmt --write --threads=1 src/agents/subagent-announce-delivery.ts src/agents/subagent-announce.ts src/agents/subagent-announce-delivery.test.ts src/agents/subagent-announce.format.e2e.test.tsnode scripts/run-vitest.mjs src/agents/subagent-announce-delivery.test.ts src/agents/subagent-announce-dispatch.test.ts src/agents/subagent-announce.format.e2e.test.tsnode scripts/run-vitest.mjs src/auto-reply/reply/completion-delivery-policy.test.tsnode scripts/run-vitest.mjs src/agents/subagent-announce-delivery.test.ts src/agents/subagent-announce-dispatch.test.ts src/agents/subagent-announce.format.e2e.test.ts src/auto-reply/reply/completion-delivery-policy.test.tsgit diff --check/Users/steipete/Projects/agent-scripts/skills/codex-review/scripts/codex-review --mode branchBehavior addressed: subagent completion announce delivery could disappear or arrive too late when the requester-agent handoff produced no visible output, active requester wake failed, or group/channel routes required message-tool delivery.
Real environment tested: local OpenClaw checkout on macOS, focused Vitest shards through
node scripts/run-vitest.mjs, plus Codex review againstorigin/main.Exact steps or command run after this patch:
node scripts/run-vitest.mjs src/agents/subagent-announce-delivery.test.ts src/agents/subagent-announce-dispatch.test.ts src/agents/subagent-announce.format.e2e.test.ts;node scripts/run-vitest.mjs src/auto-reply/reply/completion-delivery-policy.test.ts;git diff --check; Codex review helper.Evidence after fix: focused announce shard passed 112 tests; policy shard passed 16 tests; regression tests cover active-wake fallback, empty direct handoff steer fallback, channel message-tool-only subagent completions, and direct DM automatic delivery.
Observed result after fix: group/channel subagent completions request
sourceReplyDeliveryMode: "message_tool_only"and require message-tool evidence; active requester wake failures continue into requester-agent handoff; empty handoff results can steer fallback instead of being accepted as delivered.What was not tested: live chat-channel round trip, full suite, and the broader late-success/reconcile lifecycle work tracked by #82784/#82787.