Repository navigation
fix(discord): restore session resets for sender aliases - #140637
Conversation
Normalize documented command sender aliases and mentions before shared authorization so native reset commands clear channel context and acknowledge success. Preserve the existing Doctor migration boundary for global owner entries and third-party native identities. Related: #140535. Reported by @chrismanderson. Verified with 112 focused tests, check:changed, and independent review.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 6, 2026, 10:46 PM ET / September 7, 2026, 02:46 UTC. ClawSweeper reviewWhat this changesNormalizes Discord sender aliases so authorized session resets succeed, preserves legacy owner migration rules, adds regression coverage and documentation, and simplifies a prompt helper. Merge readiness✅ Ready for maintainer review This PR remains useful: current main and v2026.9.2 retain the sender-alias mismatch. No actionable introduced defect was found, consistent with the previous review of this head. The linked report’s exact cause remains unconfirmed. Priority: P1 Review scores
Verification
How this fits togetherDiscord’s native command handler passes sender identity and command access into OpenClaw’s shared reply pipeline. Shared authorization determines whether the routed conversation can reset and receive an acknowledgement. flowchart TD
A[Discord reset command] --> B[Channel access checks]
C[Configured sender aliases] --> D[Discord identity normalization]
B --> E[Shared command authorization]
D --> E
E -->|Allowed| F[Reset routed session and acknowledge]
E -->|Denied| G[Preserve session]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource -2, Tests +145, Docs +1. Total +144 across 6 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep Discord identity normalization in its existing config adapter so native and shared authorization agree without changing session routing, stored settings, or reset policy. Do we have a high-confidence way to reproduce the issue? Yes, source establishes a concrete path: configure commands.allowFrom.discord with user:<id>, then invoke native /new or /reset; native admission accepts it while current shared authorization mismatches the bare sender ID. This review did not execute tests, and the linked reporter’s exact configuration remains unknown. Is this the best way to solve the issue? Yes, this repairs the normalization owner using an existing SDK option and preserves the documented Doctor migration boundary; routing changes or retries would not address the mismatch. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e13c0c6c44da. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Merged via squash.
|
) Normalize documented command sender aliases and mentions before shared authorization so native reset commands clear channel context and acknowledge success. Preserve the existing Doctor migration boundary for global owner entries and third-party native identities. Related: openclaw#140535. Reported by @chrismanderson. Verified with 112 focused tests, check:changed, and independent review.
Related: #140535
What Problem This Solves
Fixes an issue where Discord users invoking
/newor/resetreceive “No reply was generated” and retain their conversation context when the command allowlist uses the documenteduser:<id>form. The same normalization gap affects existingdiscord:andpk:aliases and Discord mentions. This reproduces the symptom reported by @chrismanderson in #140535; the report does not include its exact allowlist configuration.Why This Change Was Made
Discord's native command authorizer recognizes sender prefixes, but the shared Discord config adapter only lowercased the entries. Core reset authorization therefore compared a prefixed allowlist entry with the bare sender ID and rejected an already admitted command (
extensions/discord/src/shared.ts:93,src/auto-reply/command-auth.ts:359,src/auto-reply/reply/commands-reset.ts:44). Normalize the existing aliases and mentions in the owning adapter, using the same SDK formatter option already used by Telegram. Preserve the existing Doctor-only migration of retired bundled-channel owner entries in the canonical core owner parser, without changing third-party native identities.The reset target is already carried correctly, so changing slash-session routing or adding a retry/fallback would not repair this failure. #137313 is not the introduction: its merge commit is not an ancestor of the 2026.9.2 release commit. The adjacent group-system-prompt helper now returns its single trimmed value directly instead of constructing, filtering, and joining a one-element array.
User Impact
Authorized Discord reset commands clear the routed channel context and return their normal acknowledgement. Durable session IDs remain stable; the lifecycle revision and reset event prove the context reset. Explicit denial still prevents reset. Retired global-owner entries still require
openclaw doctor --fix, and native third-party owner identities remain supported. The command documentation now names the supported user-ID aliases.Evidence
Head: 5f4815f
user:,discord:, andpk:each return the generic fallback with the original lifecycle revision unchanged./newand/reset, durable reset events, normal acknowledgements, a mismatched sender, and an empty allowlist.OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs src/auto-reply/command-control.test.ts extensions/discord/src/monitor/native-command.reset.test.ts extensions/discord/src/monitor/native-command.commands-allowfrom.test.ts extensions/discord/src/monitor/inbound-context.test.ts extensions/discord/src/shared.test.ts: 112 passed across five files (52 core authorization tests and 60 Discord tests).pnpm check:changed: passed.git diff --check: clean.No live Discord or full mock Gateway socket proof is claimed. There is no existing Discord native reset socket harness; this covers the handler-to-durable-reset boundary with isolated state. Guild-wide command authorization and generic denial-message wording are separate observed gaps and are not fixed here. No new configuration options, schema, SDK, protocol, dependency, or changelog changes.
Thanks to @chrismanderson for the report.