Skip to content

[Bug]: Discord reply metadata is not exposed to before_dispatch hooks #88521

Closed

Description

@hoyanhan

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

In OpenClaw 2026.5.28, Discord reply metadata is finalized into ReplyToId, ReplyToBody, and ReplyToSender, but those fields are not exposed to before_dispatch plugin hooks.

Steps to reproduce

  1. Install or write a plugin that registers a before_dispatch hook and logs the hook event and ctx.
  2. Configure Discord as a channel.
  3. Send a Discord message that replies to an earlier Discord message.
  4. Inspect the before_dispatch hook payload for the inbound replied message.

Expected behavior

The before_dispatch hook should expose the Discord reply target metadata, either as replyToId / replyToBody / replyToSender on the hook event/context or through an equivalent documented field.

This is expected because OpenClaw 2026.5.28 already derives Discord quote metadata and finalizes it into inbound context fields:

  • ReplyToId
  • ReplyToBody
  • ReplyToSender

Actual behavior

The finalized inbound context contains the reply metadata, but the before_dispatch hook boundary drops it.

Observed in the published 2026.5.28 package:

  • dist/inbound-context-CbkangX1.js maps SupplementalContext.quote into ReplyToId, ReplyToBody, and ReplyToSender.
  • dist/message-hook-mappers-DBnpM4vz.js deriveInboundMessageHookContext(...) does not include those fields.
  • dist/dispatch-DphqeP-y.js calls hookRunner.runBeforeDispatch(...) without including those fields in either the event or context object.

As a result, plugins cannot reliably implement reply-aware Discord commands through the public before_dispatch hook API.

OpenClaw version

2026.5.28

Operating system

Ubuntu 24.04

Install method

npm global

Model

Not model-dependent; the issue occurs before model dispatch.

Provider / routing chain

Not provider-dependent; reproduced at the Discord channel/plugin hook boundary before model routing matters.

Additional provider/model setup details

NOT_ENOUGH_INFO

Logs, screenshots, and evidence

Published package inspection for OpenClaw 2026.5.28:

dist/inbound-context-CbkangX1.js:
  ReplyToId: supplemental.quote?.id
  ReplyToBody: supplemental.quote?.body
  ReplyToSender: supplemental.quote?.sender

dist/message-hook-mappers-DBnpM4vz.js:
  deriveInboundMessageHookContext(...) does not map ReplyToId, ReplyToBody, or ReplyToSender.

dist/dispatch-DphqeP-y.js:
  hookRunner.runBeforeDispatch(...) event/context omit replyToId, replyToBody, and replyToSender.

Impact and severity

Affected: plugin authors using before_dispatch to implement Discord reply-aware commands.

Severity: Medium. This blocks reply-aware command handling for plugins unless they use an undocumented workaround or patch OpenClaw/plugin internals.

Frequency: Always observed for this hook path in 2026.5.28 when relying on before_dispatch.

Consequence: Plugins cannot determine which Discord message was replied to, even though the channel/runtime has already resolved that metadata internally.

Additional information

A local workaround is to pass the Discord reply target through a channel-specific command marker before before_dispatch, but that requires patching the Discord plugin and should not be necessary if the hook API exposes the already-finalized reply metadata.

Activity

  1. clawsweeper commented on May 31, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed May 31, 2026, 1:15 AM ET / 05:15 UTC.

    Summary
    Codex review failed: codex execution failed.

    Reproducibility: unclear. The review failed before ClawSweeper could establish a reproduction path.

    Ways to help us reproduce this

    • Add a screenshot or short recording showing the behavior.
    • Include the exact command, prompt, or workflow that triggered it.
    • Add expected vs actual behavior.

    Next step
    Review did not complete, so no work-lane recommendation was made.

    Review details

    Best possible solution:

    Retry the Codex review after fixing the execution failure.

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

    Unclear. The review failed before ClawSweeper could establish a reproduction path.

    Is this the best way to solve the issue?

    Unclear. Retry the review first so ClawSweeper can evaluate the actual issue and fix direction.

    AGENTS.md: unclear because the file could not be read completely.

    Remaining risk / open question:

    • No close action taken because the review did not complete.

    Codex review notes: model gpt-5.5, reasoning high; reviewed against 51dee73a5d3e.

    Label changes

    Label changes:

    • add issue-rating: 🦪 silver shellfish: Current issue advisory state selects this label.
    • add clawsweeper:needs-info: Current issue advisory state selects this label.
    Evidence reviewed

    What I checked:

    • failure reason: codex execution failed.
    • codex failure detail: Codex review failed for this issue with exit 1.
    • codex stdout: Per-item Codex failure; continuing with the rest of the shard.

    Likely related people:

    • unknown: Codex failed before it could trace repository history. (role: review did not complete; confidence: low)
    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 a commit that references this issue on Jun 1, 2026
    9215984
  3. steipete commented on Jun 1, 2026

    @steipete
    Contributor

    Fixed on main by PR #88801, commit 9215984.

    Proof:

    • The merged change carries finalized inbound ReplyToId, ReplyToBody, and ReplyToSender through canonical hook mapping into plugin-visible inbound/message hooks and before_dispatch event/context fields.
    • Focused local proof before merge passed: node scripts/run-vitest.mjs src/hooks/message-hook-mappers.test.ts src/auto-reply/reply/dispatch-from-config.test.ts, 2 Vitest shards and 202 tests total.
    • Autoreview was clean: no accepted/actionable findings.
    • PR CI had no failed or pending checks at merge time.
  4. added a commit that references this issue on Jun 1, 2026
    e0af9b5
  5. locked as resolved and limited conversation to collaborators on Jun 3, 2026
  6. added a commit that references this issue on Jun 10, 2026
    eb1e439
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

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions