Skip to content

feat(discord): add implicit reply mention policy - #80235

Closed
JiehoonKwak wants to merge 5 commits into
openclaw:mainfrom
JiehoonKwak:feat/discord-implicit-reply-mentions-policy
Closed

JiehoonKwak wants to merge 5 commits into
openclaw:mainfrom
JiehoonKwak:feat/discord-implicit-reply-mentions-policy

Conversation

@JiehoonKwak

@JiehoonKwak JiehoonKwak commented May 10, 2026 •

Copy link
Copy Markdown

Closes #80234.

Adds channels.discord.implicitReplyMentions:

{
  fromUsers: true,
  fromBots: true
}

Defaults preserve current behavior. Multi-bot deployments can set fromBots: false so bot-authored native replies do not wake another bot via the implicit reply_to_bot path; explicit <@botId> mentions still work.

Checks run:

  • pnpm exec vitest run extensions/discord/src/monitor/message-handler.preflight.test.ts --maxWorkers=1
  • pnpm config:schema:check
  • pnpm config:docs:check
  • pnpm check:bundled-channel-config-metadata
  • git diff --check

Real behavior proof

Behavior or issue addressed: Discord native reply-only mentions can wake an OpenClaw bot when another bot replies to one of its messages. This PR adds a policy knob so deployments can keep human reply activation while disabling bot-authored reply-only activation.

Real environment tested: Private Discord server with a private test channel and two OpenClaw Discord bot accounts. Server, channel, bot names, message IDs, and account IDs are intentionally omitted from this public proof.

Exact steps or command run after this patch:

  1. In the private test channel, send an anchor message from the target bot.
  2. Send a native Discord reply from a separate relay bot to that anchor message. The reply body contains no textual <@bot> mention.
  3. Observe whether the target bot wakes/responds.
  4. Repeat after applying this branch with implicitReplyMentions: { fromUsers: true, fromBots: false }.
  5. Send a separate control message from the relay bot that contains a real textual <@bot> mention and asks the target bot to reply with a known marker.

Evidence after fix: Redacted live output excerpt from the private Discord test channel:

after-fix native reply-only test:
relay bot | "oc-proof-80235-after4-231018 native-reply-no-explicit-mention" | ref=<target-bot-anchor>
UNEXPECTED_TARGET_RESPONSES=0

explicit mention control:
target bot | "oc-proof-80235-control-231107 explicit-mention-ok" | ref=<relay-bot-control-message>
EXPLICIT_CONTROL_OK=true

Observed result after fix: With fromBots:false, the bot-authored native reply-only message did not wake the target bot during the observation window. A real textual explicit mention still woke the target bot and produced the requested marker response.

What was not tested: Human-authored reply-only behavior was covered by unit tests but not repeated in the live Discord proof. PluralKit behavior was covered by unit tests but not repeated in the live Discord proof.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: discord Channel integration: discord size: M triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 10, 2026
@clawsweeper

clawsweeper Bot commented May 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed July 3, 2026, 11:47 PM ET / 03:47 UTC.

Summary
The PR adds channels.discord.implicitReplyMentions to let Discord deployments keep human native-reply activation while disabling bot-authored reply-only activation, with schema, docs, generated metadata, and preflight tests.

PR surface: Source +51, Tests +187, Docs +24, Generated 0. Total +262 across 11 files.

Reproducibility: yes. at source level: current main emits reply_to_bot when a Discord reply references the current bot id and lets that implicit mention satisfy the mention gate for accepted bot-authored messages. I did not rerun a live Discord replay in this read-only review, but the PR includes redacted live before/after output.

Review metrics: 1 noteworthy metric.

  • Discord config surface: 1 nested object added, 2 optional booleans. The added account-level policy changes upgrade and inheritance behavior, so maintainers should review the compatibility contract before merge.

Stored data model
Persistent data-model change detected: unknown-data-model-change: src/config/bundled-channel-config-metadata.generated.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #80234
Summary: This PR is the active candidate fix for the narrower Discord bot-authored native reply implicit mention issue; broader Discord routing reports overlap but are not fully solved by this policy knob.

Members:

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

Merge readiness
Overall: 🦐 gold shrimp
Proof: 🦞 diamond lobster
Patch quality: 🦐 gold shrimp
Result: needs maintainer review before merge.

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

Rank-up moves:

  • [P2] Add partial account/default inheritance coverage for implicitReplyMentions and repair the merge behavior.
  • Refresh the branch against current main so GitHub can produce a clean merge result.
  • Rerun the focused Discord preflight and config schema/docs/metadata checks after the refresh.

Risk before merge

  • [P1] The new nested Discord account config can shallow-replace channel-level implicitReplyMentions defaults when an account supplies only one subfield, changing which replies wake an agent.
  • [P1] Maintainers still need to accept the user-facing Discord config API shape because this is a new policy knob, not only an internal repair.
  • [P1] The branch is currently conflicting against main with old failing checks, so maintainers do not have a clean merge result or fresh current-head validation.

Maintainer options:

  1. Repair inheritance before merge (recommended)
    Add implicitReplyMentions to the Discord nested merge contract or flatten the API, cover partial account overrides, refresh the branch, and rerun focused checks.
  2. Sponsor a different policy shape
    Maintainers can choose a flatter or differently named Discord policy surface if nested account inheritance is not the desired long-term contract.
  3. Pause if the knob is not wanted
    If another Discord config option is not accepted, close or supersede this PR and keep the linked issue open for a different owner-approved routing fix.

Next step before merge

  • [P2] Maintainer review is needed for the new Discord config API shape, the branch conflict, and the compatibility repair before this can merge.

Security
Cleared: The diff changes Discord config/schema/docs/tests and preflight logic, with no dependency, workflow, secret, lockfile, or code-execution supply-chain changes found.

Review findings

  • [P1] Preserve account/default inheritance for reply policy — src/config/types.discord.ts:314-320
Review details

Best possible solution:

Accept the Discord policy only after maintainer API approval, preserve account/default inheritance for partial implicitReplyMentions overrides, refresh the branch, and rerun the focused Discord/config checks.

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

Yes, at source level: current main emits reply_to_bot when a Discord reply references the current bot id and lets that implicit mention satisfy the mention gate for accepted bot-authored messages. I did not rerun a live Discord replay in this read-only review, but the PR includes redacted live before/after output.

Is this the best way to solve the issue?

No, not as submitted. The policy is a plausible narrow fix if maintainers accept the config API, but the best merge shape must preserve partial account/default inheritance and be refreshed against main.

Full review comments:

  • [P1] Preserve account/default inheritance for reply policy — src/config/types.discord.ts:314-320
    implicitReplyMentions is a nested account config object, but Discord only deep-merges selected nested keys. If the channel config sets fromUsers: false and an account sets only fromBots: false, the account object replaces the channel object and human reply-only activation is enabled again for that account. Add this key to the nested merge contract or use a flat shape, with regression coverage for partial account overrides.
    Confidence: 0.91

Overall correctness: patch is incorrect
Overall confidence: 0.89

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 9d68f877ac3e.

Label changes

Label justifications:

  • P2: This is a normal-priority Discord multi-bot routing improvement with a clear linked issue and limited channel-specific blast radius.
  • merge-risk: 🚨 compatibility: The PR adds a new nested Discord account config surface whose partial account override behavior can change existing inherited settings unless repaired.
  • merge-risk: 🚨 message-delivery: The changed policy controls whether Discord replies wake an agent, so incorrect defaults or inheritance can suppress or trigger channel messages for the wrong bot.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (live_output): The PR body and follow-up comment include redacted live Discord output showing bot-authored reply-only activation suppressed with fromBots:false and explicit mentions still working.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body and follow-up comment include redacted live Discord output showing bot-authored reply-only activation suppressed with fromBots:false and explicit mentions still working.
Evidence reviewed

PR surface:

Source +51, Tests +187, Docs +24, Generated 0. Total +262 across 11 files.

View PR surface stats
Area Files Added Removed Net
Source 5 56 5 +51
Tests 1 190 3 +187
Docs 3 25 1 +24
Config 0 0 0 0
Generated 2 18 18 0
Other 0 0 0 0
Total 11 289 27 +262

What I checked:

Likely related people:

  • steipete: Peter Steinberger authored the central inbound mention policy and the shared account config merge helpers that shape both the reply-to-bot behavior and the nested config inheritance concern. (role: feature-history owner and recent area contributor; confidence: high; commits: 625fd5b3e3e2, 05d149a49b21, c74a50e4f1ca; files: src/channels/mention-gating.ts, extensions/discord/src/monitor/message-handler.preflight.ts, src/channels/plugins/account-helpers.ts)
  • thewilloftheshadow: Shadow authored the Discord allowBots mention-gating change that interacts with bot-authored reply activation. (role: adjacent Discord bot-message policy contributor; confidence: medium; commits: 65816657c2ae; files: src/config/types.discord.ts, src/config/zod-schema.providers-core.ts, extensions/discord/src/monitor/message-handler.preflight.ts)
  • scoootscooob: scoootscooob moved the Discord channel implementation into the current extensions/discord plugin boundary that owns this preflight path. (role: Discord plugin migration contributor; confidence: medium; commits: 5682ec37fada; files: extensions/discord/src/monitor/message-handler.preflight.ts, extensions/discord/src/accounts.ts)
  • vincentkoc: Vincent Koc appears in recent history for the affected Discord/config paths and authored the current latest release tag commit used for shipped-behavior comparison. (role: recent adjacent contributor; confidence: medium; commits: e085fa1a3ffd, 3d647f14d0da, 76c4ecd651e9; files: extensions/discord/src/monitor/message-handler.preflight.ts, src/config/types.discord.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.

@JiehoonKwak
JiehoonKwak force-pushed the feat/discord-implicit-reply-mentions-policy branch from 1e68c18 to 99deac3 Compare May 10, 2026 14:19
…-reply-mentions-policy

# Conflicts:
#	CHANGELOG.md
#	docs/.generated/config-baseline.sha256
@JiehoonKwak

JiehoonKwak commented May 10, 2026 •

Copy link
Copy Markdown
Author

Real Discord behavior proof from a private multi-bot test channel:

  • Baseline/current install: a bot-authored native Discord reply to a target OpenClaw bot message, with no textual <@bot> mention in the message body, woke the target bot via reply-only activation.
    • Observed target response: native-reply-ok
  • Patched branch with implicitReplyMentions: { fromUsers: true, fromBots: false }: the same bot-authored native reply-only message did not wake the target bot.
    • Observation window: 15s
    • Unexpected target responses: 0
  • Explicit mention control still works: a bot-authored message containing a real textual <@bot> mention woke the target bot and produced the requested response.
    • Observed target response: explicit-mention-ok

While doing the live test I found one Discord API wrinkle that the original unit-only version missed: native replies can include the replied-to bot in mentions[] even when the message body has no textual mention. I updated the branch so reply-generated mentions are suppressed only when they are reply-only and the relevant implicitReplyMentions.fromUsers/fromBots policy disables them; textual explicit mentions continue to pass.

Local verification after the update:

  • pnpm exec vitest run extensions/discord/src/monitor/message-handler.preflight.test.ts --maxWorkers=1 → 46 passed
  • pnpm config:schema:check → passed
  • pnpm config:docs:check → passed
  • node --import tsx scripts/generate-bundled-channel-config-metadata.ts --check → passed

I also merged current origin/main into the PR branch and resolved the generated config baseline conflict. CI was still running on my latest refresh, with no failed checks at that time.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 10, 2026
…-reply-mentions-policy

# Conflicts:
#	docs/.generated/config-baseline.sha256
#	src/config/bundled-channel-config-metadata.generated.ts
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 10, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 10, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 10, 2026
@JiehoonKwak

Copy link
Copy Markdown
Author

Addressed the ClawSweeper finding:

  • Preserved explicit textual Discord bot mentions on native replies by checking raw message.content instead of normalized baseText.
  • Added regression coverage for the bot-authored native-reply-plus-explicit-mention case with implicitReplyMentions.fromBots=false.
  • Merged current upstream main and regenerated config metadata/baseline after resolving conflicts.

Local verification after the update:

  • pnpm exec vitest run extensions/discord/src/monitor/message-handler.preflight.test.ts --maxWorkers=1 → 46 passed
  • pnpm config:schema:check → passed
  • pnpm config:docs:check → passed
  • pnpm check:bundled-channel-config-metadata → passed
  • git diff --check → passed

@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 11, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 11, 2026
@openclaw-barnacle

Copy link
Copy Markdown

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

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label May 26, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels May 26, 2026
@clawsweeper

clawsweeper Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg

✨ Hatched: 💎 rare Gilded Crabkin

Hatch command

Comment @clawsweeper hatch when this PR is hatchable.

Hatchability rules:

  • Merged PRs are hatchable.
  • Open PRs are hatchable when they are status: 👀 ready for maintainer look, status: 🚀 automerge armed, or labeled clawsweeper:automerge.
  • Closed unmerged PRs are hatchable only when one of those hatchable labels is still present in the durable record.

Rarity: 💎 rare.
Trait: keeps receipts.
Image traits: location status garden; accessory CI status badge; palette rose quartz and slate; mood sleepy but ready; pose curling around a status light; shell soft speckled shell; lighting calm overcast light; background gentle dashboard dots.
Share on X: post this hatch
Copy: My PR egg hatched a 💎 rare Gilded Crabkin in ClawSweeper.

What is this egg doing here?
  • Eggs appear after the PR passes real-behavior proof. It is here for vibes, not verdicts: it does not change labels, ratings, merge decisions, or automation.
  • The shell reacts to review momentum: open follow-up work warms it up, re-review makes it wobble, and a clean final review lets it hatch.
  • Hatchability usually comes from sufficient real-behavior proof, no blocking P0/P1/P2 findings, no security attention needed, and clean correctness. A merged PR is already final, so merge makes the egg hatchable independently.
  • The hatch is seeded from this repository and PR number, so the same PR keeps the same creature; the reviewed head SHA can only change safe visual details.
  • Rarity is just collectible sparkle: 🥚 common, 🌱 uncommon, 💎 rare, ✨ glimmer, and 🌈 legendary.

@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label May 27, 2026
@clawsweeper clawsweeper Bot removed the rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. label Jun 18, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Jun 18, 2026
@openclaw-barnacle

Copy link
Copy Markdown

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

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Jul 19, 2026
@clawsweeper

clawsweeper Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper status: review started.

I am starting a fresh review of this pull request: feat(discord): add implicit reply mention policy This is item 1/1 in the current shard. Shard 9/22.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@openclaw-barnacle

Copy link
Copy Markdown

Closing due to inactivity.
If you believe this PR should be revived, post in #clawtributors on Discord to talk to a maintainer.
That channel is the escape hatch for high-quality PRs that get auto-closed.

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

Labels

channel: discord Channel integration: discord docs Improvements or additions to documentation 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. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M stale Marked as stale due to inactivity 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.

Discord bot replies can trigger implicit reply-to-bot mentions

1 participant