Skip to content

restart-recovery 不触发 reply_payload_sending event,导致渠道插件丢失回复 #90282

Closed

Description

@lansenger-pm

问题描述

Gateway 重启后,OpenClaw 的 main-session-restart-recovery 恢复了被中断的 session transcript,agent 重新运行并产出回复。但这个回复被写入 transcript 后没有触发 reply_payload_sending event,导致渠道插件无法 delivery——用户永远看不到回复。

重现步骤

  1. 用户通过蓝信发送消息 → 插件 handleInbound() → inbound.run() 注册 delivery adapter → 发 ack 消息
  2. Gateway 重启(插件升级、配置变更等) → SIGTERM → session transcript 被 drain 保存
  3. main-session-restart-recovery 恢复 session → agent 产出新回复 → 回复写入 transcript
  4. 没有任何 reply_payload_sending event 触发 → 渠道插件的 fallback delivery hook 无法执行 → 用户永远收不到回复

关键日志证据

测试环境:OpenClaw 2026.6.1 + 蓝信渠道插件 3.14.2

17:28:07 inbound.run starting (旧进程)
17:29:27 SIGTERM → gateway draining
17:29:55 restart-recovery: resumed interrupted session
17:29:55~17:32 agent 精确产出完整回复(输出内容出现在 gateway log 中)

之后没有任何 reply_payload_sending 或 deliverReply 的日志。

蓝信插件在 3.14.2 中已经加了 fallback delivery(通过 reply_payload_sending hook),但这个 hook 本身没有被 core 触发,所以 fallback 也没机会执行。

根因分析

main-session-restart-recovery 在恢复 session 后,可能通过 "internal transcript append" 的方式写入 agent 回复,绕过了正常的 reply event pipeline(reply_payload_sending → channel delivery adapter)。这意味着所有依赖 reply_payload_sending hook 做回复 delivery 的渠道插件(不仅仅是蓝信)在 restart-recovery 场景下都会丢失回复。

影响范围

这个问题影响所有渠道插件,不只是蓝信:

  • Telegram、Discord、Signal、WhatsApp 等所有通过 reply_payload_sending hook 做 delivery 的插件都会受影响
  • 每次插件升级或 gateway 重启都会触发

建议修复方向

  1. Core 应在 restart-recovery agent 回复完成后触发 reply_payload_sending event,让渠道插件有机会通过正常 pipeline delivery
  2. 或者:Core 在 recovery 完成后 emit 一个专门的 session.recovered event,包含最后一条 agent 回复内容,让渠道插件可以主动 delivery
  3. 或者:Core 提供一个 session.getLastReply() API,让插件在 recovery 场景下可以主动提取并发送回复

优先级

🔴 高 — 这是 OpenClaw core 的 bug,影响所有渠道插件的用户体验。每次 gateway 重启都会导致正在处理的消息回复丢失。

Activity

  1. clawsweeper commented on Jun 4, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 21, 2026, 10:39 AM ET / 14:39 UTC.

    Summary
    Keep open: current main and latest release still send restart-recovered agent-command final replies without replyPayloadSendingHook, and the linked closing PR is open but currently conflicting rather than merged.

    Reproducibility: yes. Source inspection shows restart recovery calls Gateway agent with delivery enabled, while current main sends the recovered final payload without replyPayloadSendingHook; I did not run a live external-channel restart.

    Root-cause cluster
    Relationship: canonical
    Canonical: #90282
    Summary: This issue is the canonical user report for restart-recovered agent-command replies missing reply_payload_sending; the open linked PR is the active candidate fix, and the earlier equivalent PR is closed unmerged.

    Members:

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

    Next step
    No new repair PR should be queued because the linked open PR already owns the implementation path for this issue.

    Review details

    Best possible solution:

    Land or replace #90300 so agent-command durable delivery supplies the existing reply hook metadata while preserving current restart-abort handling.

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

    Yes. Source inspection shows restart recovery calls Gateway agent with delivery enabled, while current main sends the recovered final payload without replyPayloadSendingHook; I did not run a live external-channel restart.

    Is this the best way to solve the issue?

    Yes. Reusing the existing durable reply_payload_sending hook metadata is the narrow maintainable fix; adding a new recovery event or last-reply API would duplicate the established pre-delivery hook path.

    AGENTS.md: found and applied where relevant.

    Remaining risk / open question:

    • The linked fix PR is open and conflict-marked, so this issue remains unfixed until that branch is repaired, merged, or replaced.
    • This review is source-reproducible and supported by reporter logs, but it did not run a live gateway restart with an external channel plugin.

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

    Label changes

    Label justifications:

    • P1: The report describes a broken restart-recovered agent/channel workflow where users can miss the final reply after a gateway restart.
    • impact:message-loss: Recovered agent replies can be produced but not delivered through channel plugins that depend on the documented pre-delivery hook.
    • impact:session-state: The failure occurs while resuming persisted main-session state after an interrupted run.
    Evidence reviewed

    What I checked:

    • Repository policy read: Root and scoped agents guidance were read and applied; this review treats agent delivery, plugin hooks, and restart recovery as source-backed core behavior. (AGENTS.md:1, 0ad48dad2c47)
    • Vision fit: VISION.md prioritizes bug fixes, stability, and major messaging-channel support, which fits this reported restart-recovery delivery loss. (VISION.md:18, 0ad48dad2c47)
    • Restart recovery re-enters agent delivery: resumeMainSession calls Gateway agent with deliver: Boolean(deliveryContext) and channel/target fields, so recovered replies flow into agent-command delivery. (src/agents/main-session-restart-recovery.ts:580, 0ad48dad2c47)
    • Current main missing hook metadata: deliverAgentCommandResult calls sendDurableMessageBatch with payloads, session, reply/thread ids, restart-abort signal, and callbacks, but no replyPayloadSendingHook. (src/agents/command/delivery.ts:750, 0ad48dad2c47)
    • Sibling reply path supplies the hook: The routed reply path passes replyPayloadSendingHook with kind, channel, session key, run id, and context into the same durable send API. (src/auto-reply/reply/route-reply.ts:278, 0ad48dad2c47)
    • Outbound layer applies supplied hook: Durable outbound delivery applies params.replyPayloadSendingHook before channel send, so the current source gap is the agent-command caller not supplying it. (src/infra/outbound/deliver.ts:1618, 0ad48dad2c47)

    Likely related people:

    • piersonr: PR history shows feat(plugin-sdk): add reply payload sending hook added the hook surface, docs, routed reply wiring, and outbound delivery support. (role: introduced hook surface; confidence: high; commits: b474f429ee4b; files: docs/plugins/hooks.md, src/auto-reply/reply/route-reply.ts, src/infra/outbound/deliver.ts)
    • MertBasar0: PR history shows the main-session durable delivery work changed the affected agent-command and restart-recovery delivery path. (role: feature introducer; confidence: medium; commits: c240e718e91e; files: src/agents/agent-command.ts, src/agents/command/delivery.ts, src/agents/main-session-restart-recovery.ts)
    • samzong: Merged restart-recovery reply delivery work changed the same recovery-to-delivery product path. (role: restart-recovery delivery contributor; confidence: high; commits: 4decdf6245a1; files: src/agents/agent-command.ts, src/agents/main-session-restart-recovery.ts, src/infra/outbound/targets-session.ts)
    • joshavant: Recent merged work hardened final-delivery routing and session refresh in the same agent-command delivery surface. (role: recent area contributor; confidence: high; commits: e99615973810, 2c8f78e723ec; files: src/agents/agent-command.ts, src/agents/command/delivery.ts, src/agents/command/delivery.test.ts)
    • ooiuuii: Recent merged restart shutdown recovery work added restart-abort handling around the same durable send block that the candidate fix must preserve. (role: recent adjacent contributor; confidence: high; commits: d20fdf3b3842; files: src/agents/command/delivery.ts, src/agents/command/delivery.test.ts, src/agents/main-session-restart-recovery.ts)
    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.
  2. added
    P1
    impact:message-loss
    impact:session-state
    issue-rating: 🦞 diamond lobster
    clawsweeper:source-repro
    clawsweeper:queueable-fix
    clawsweeper:fix-shape-clear
    on Jun 4, 2026
  3. added
    clawsweeper:linked-pr-open
    clawsweeper:no-new-fix-pr
    and removed
    clawsweeper:fix-shape-clear
    clawsweeper:queueable-fix
    on Jun 15, 2026
  4. locked as resolved and limited conversation to collaborators on Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1clawsweeper:linked-pr-openclawsweeper:no-new-fix-prclawsweeper:source-reproimpact:message-lossimpact:session-stateissue-rating: 🦞 diamond lobster

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions