Repository navigation
[codex] fix(agents): run reply payload hooks for agent delivery - #90293
spacegeologist wants to merge 1 commit into
Conversation
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Close as duplicate/superseded: this PR implements the same agent-command hook wiring as #90300, and that other PR is open, cleanly mergeable, proof-positive, and maintainer-editable. Canonical path: Land #90300 as the canonical fix for #90282, then close this duplicate branch. So I’m closing this here and keeping the remaining discussion on #90300 and #90282. Review detailsBest possible solution: Land #90300 as the canonical fix for #90282, then close this duplicate branch. Do we have a high-confidence way to reproduce the issue? Yes at source level: current main and Is this the best way to solve the issue? No for this branch as the best landing path: the code shape is valid, but #90300 is the cleaner open canonical PR with equivalent behavior, sufficient proof, clean mergeability, and maintainer edits enabled. Security review: Security review cleared: The diff touches agent delivery code and tests only; no dependencies, workflows, package metadata, secrets handling, or supply-chain surface changed. AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 1a3ce7c2a8da. |
|
@clawsweeper re-review Added redacted equivalent live channel-plugin proof to the PR body. The proof uses the real global hook runner, active plugin registry, durable outbound queue, |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
ClawSweeper applied the proposed close for this PR.
|
Summary
Fixes #90282.
reply_payload_sendinghook metadata through agent-command durable delivery.Root Cause
Restart recovery resumes interrupted main sessions by calling Gateway
agentwithdeliver: true. That path eventually usesdeliverAgentCommandResult, which sends final payloads throughsendDurableMessageBatch. The normal inbound auto-reply path already passesreplyPayloadSendingHook, but the agent-command durable delivery path did not, so channel plugins relying onreply_payload_sendingnever saw recovered final replies.Real behavior proof
Behavior addressed: restart-recovered agent final delivery now carries
reply_payload_sendinghook metadata into durable outbound delivery, giving channel plugins the same pre-delivery hook opportunity as normal inbound replies.Real environment tested: local OpenClaw checkout on branch
codex/restart-recovery-reply-payload-hook, Node v24.13.1, dependencies installed withcorepack pnpm install --frozen-lockfile.Exact steps or command run after this patch:
node scripts/run-vitest.mjs src/agents/command/delivery.test.ts node scripts/run-vitest.mjs src/agents/main-session-restart-recovery.test.ts src/agents/agent-command.live-model-switch.test.ts src/agents/command/delivery.test.ts src/infra/outbound/deliver.test.ts src/auto-reply/dispatch.test.ts node scripts/run-vitest.mjs src/auto-reply/reply/route-reply.test.ts corepack pnpm exec oxfmt --check --threads=1 src/agents/command/delivery.ts src/agents/command/delivery.test.ts git diff --checkEvidence after fix:
Additional equivalent live channel-plugin proof run locally after ClawSweeper feedback:
corepack pnpm exec tsx .artifacts/issue-90282-proof/run-proof.tsThis proof harness used the real global hook runner, active plugin registry, durable outbound queue,
deliverAgentCommandResult,sendDurableMessageBatch, and a local proof channel plugin with a realoutbound.sendTextadapter. It did not mockdeliverOutboundPayloadsInternalor the channel send call.Redacted output:
{ "proof": "issue-90282-recovered-agent-delivery-reply-payload-hook", "assertion": "reply_payload_sending ran before recovered agent final reply reached the channel adapter", "hookCalls": [ { "kind": "final", "channel": "issue-90282-proof", "sessionKey": "agent:main:issue-90282-proof:direct:redacted", "runId": "run-redacted", "context": { "channelId": "issue-90282-proof", "accountId": "account-redacted", "conversationId": "conversation-redacted", "sessionKey": "agent:main:issue-90282-proof:direct:redacted", "runId": "run-redacted" }, "inputText": "recovered final reply", "outputText": "recovered final reply [hook-proof]" } ], "outboundSends": [ { "channel": "issue-90282-proof", "to": "conversation-redacted", "accountId": "account-redacted", "threadId": null, "text": "recovered final reply [hook-proof]", "messageId": "proof-message-1" } ], "deliveryStatus": { "requested": true, "attempted": true, "status": "sent", "succeeded": true, "resultCount": 1, "payloadOutcomes": [ { "index": 0, "status": "sent", "resultCount": 1 } ] }, "durableQueue": { "stateDir": "<local-artifact-state-dir>", "pendingAfter": 0 } }Observed result after fix: the recovered agent delivery test observes
replyPayloadSendingHookwithkind: "final", channel, conversation id, session key, and run id on the durable delivery call. The live channel-plugin proof also showsreply_payload_sendingreceiving the recovered final payload, mutating it, and the channel adapter receiving the mutated text before delivery completes withstatus: "sent"; the durable queue drains topendingAfter: 0.What was not tested: a full live Gateway process restart with an external network-backed third-party channel. The local proof covers the equivalent live channel-plugin setup and the missing core handoff that #90282 identified.
Verification
node scripts/run-vitest.mjs src/agents/command/delivery.test.tsnode scripts/run-vitest.mjs src/agents/main-session-restart-recovery.test.ts src/agents/agent-command.live-model-switch.test.ts src/agents/command/delivery.test.ts src/infra/outbound/deliver.test.ts src/auto-reply/dispatch.test.tsnode scripts/run-vitest.mjs src/auto-reply/reply/route-reply.test.tscorepack pnpm exec oxfmt --check --threads=1 src/agents/command/delivery.ts src/agents/command/delivery.test.tsgit diff --checkcorepack pnpm exec tsx .artifacts/issue-90282-proof/run-proof.ts(local proof harness; output redacted above)Changelog
No
CHANGELOG.mdedit. This is a contributor fix; release-note context is in this PR body.