Skip to content

fix(discord): preserve native replies in bound threads - #129801

Merged
steipete merged 2 commits into
mainfrom
codex/qa-discord-thread-webhook-explicit-replies-20260826
Oct 24, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/qa-discord-thread-webhook-explicit-replies-20260826

Conversation

@steipete

@steipete steipete commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes explicit and configured native replies losing their reply relationship in Discord sessions bound to a thread with a webhook persona.

User Impact

Native replies use the bot identity and require its permission to send in the thread. Ordinary non-reply messages retain their webhook persona. Missing bot permission remains a visible failure.

Why This Change Was Made

extensions/discord/src/outbound-adapter.ts:87 selected the bound webhook even when a native reply was requested. Execute Webhook does not support native message references, so adding message_reference there could not create the requested reply.

The adapter now uses the existing bot sender whenever an effective reply reference is present. Unsupported webhook reply arguments, request fields and misleading reply receipts are removed. The existing bot sender continues to own chunk scope, authorization, progress receipts and uncertain-delivery behavior.

Evidence

A production-adapter reproduction with a real thread binding and loopback Discord HTTP endpoint fails on current main: an explicit reply sends two webhook requests rather than native messages. The same reproduction checks explicit replies with mode off, implicit first-chunk replies, per-chunk receipt references, a visible native 403 without webhook fallback, and ordinary webhook-persona delivery.

The loopback reproduction passes all four checks with the fix: explicit/default-off native replies, implicit/first native replies, visible native permission failure with no fallback, and ordinary webhook-persona delivery. It uses the real binding manager, outbound adapter, REST sender and receipts. The regression groups also exercise the plugin message adapter and retire the unsupported webhook expectation.

Targeted syntax lint, oxfmt and diff whitespace checks pass. Production +2/-18 (net -16), tests +81/-8 (net +73), documentation +1/-1. All 37 local tests pass across the message-adapter, outbound-adapter and webhook chunk-limit files, including both new native-reply regressions. The shared worker build took 579 seconds; Vitest reported 927.51 seconds including startup. Independent Codex review found no actionable P0–P2 issue. Final-head CI 40075018843 is green, including all 13 durable line-limit scenarios in checks-node-compact-small-2 (job 120816718041).

No live Discord or Gateway was exercised under the scoped instruction to use local focused proof and PR CI.

The first exact-head run, 40073068349, found six sibling durable-delivery fixtures still requiring a webhook while unconditionally requesting replies. Their setup now uses reply-free messages for webhook line/fence/mention checks and explicitly requires the bot endpoint for the existing bound-thread native-reply case. The focused local rerun completed worker compilation but stalled before assertions under both Bun and Node, so it was stopped through the managed runner after CI supplied the passing result. The test-only follow-up passed independent P0–P2 review with no findings; no production behavior changed.

Captured production-adapter HTTP boundary trace

The following is captured from the same production binding → outbound adapter → REST sender path on final head d2102b76ac96d7d104604ecf52c98f336f0cc59c. All IDs and content are synthetic; the endpoint is local. The fixture responds with HTTP 200 for permitted sends and HTTP 403/code 50013 for the denial. This proves the production caller propagates that denial without a webhook retry; it does not claim to exercise Discord's live permission service.

fixture endpoint listening on loopback
production adapter imported
{"scenario":"explicit","method":"POST","path":"/api/v10/channels/123456789012345678/messages","status":200,"contentLength":2000,"replyToId":"223456789012345678","error":null}
{"scenario":"explicit","method":"POST","path":"/api/v10/channels/123456789012345678/messages","status":200,"contentLength":1,"replyToId":"223456789012345678","error":null}
PASS explicit native reply endpoints, chunk scope, receipts
{"scenario":"implicit","method":"POST","path":"/api/v10/channels/123456789012345678/messages","status":200,"contentLength":2000,"replyToId":"223456789012345678","error":null}
{"scenario":"implicit","method":"POST","path":"/api/v10/channels/123456789012345678/messages","status":200,"contentLength":1,"replyToId":null,"error":null}
PASS implicit native reply endpoints, chunk scope, receipts
{"scenario":"permission-denied","method":"POST","path":"/api/v10/channels/123456789012345678/messages","status":403,"contentLength":18,"replyToId":"223456789012345678","error":{"code":50013,"message":"Missing Permissions"}}
PASS native permission failure remains visible; native POSTs=1; webhook POSTs=0
{"scenario":"ordinary-persona","method":"POST","path":"/api/v10/webhooks/323456789012345678/[redacted]?wait=true&thread_id=123456789012345678","status":200,"contentLength":24,"replyToId":null,"error":null}
PASS ordinary message keeps webhook persona

ClawSweeper's final-head review reports no remaining code finding and requests inspectable boundary evidence; the trace above supplies the recorded requests and responses. Live Discord remains untested under phase-one scope. No new permission gate or fallback is added.

@clawsweeper

clawsweeper Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added channel: discord Channel integration: discord size: S maintainer Maintainer-authored PR labels Aug 26, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 26, 2026
@clawsweeper

clawsweeper Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

Routes native replies in bound Discord threads through the bot sender and removes unsupported webhook reply fields.

Example: Send 2,001 characters in thread-1 with an explicit reply to parent-message and reply mode off.

  • Before: The webhook persona sends messages without a native reply relationship.
  • After: The bot sends native reply chunks with matching reply receipts, or reports a permission failure.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The focused implementation has no remaining code finding; inspectable evidence for the changed identity boundary is still required.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Explicit and configured native replies lose their reply relationship when a Discord session uses a bound-thread webhook persona.
Reason: Restores the documented reply contract through an existing transport, with the identity and permission tradeoff explicitly accepted by the maintainer-authored PR.

Merge readiness

⛔ Blocked before merge - 3 items remain

Keep open: this PR fixes a current Discord reply-routing defect, and the latest commit resolves the previous finding without introducing another code defect.

Priority: P2
Reviewed head: d2102b76ac96d7d104604ecf52c98f336f0cc59c

Before merge

  • Add real behavior proof - Authority-chain proof required: the maintainer reports a real-binding, production-adapter loopback run covering explicit/default-off replies, implicit/first replies, receipts, a native 403 without fallback, and ordinary webhook delivery, but provides no captured output or artifact for that run. Attach a redacted HTTP trace showing allowed native delivery and rejection of a bot lacking thread permission without a subsequent webhook send; redact credentials, IPs, and non-public endpoints. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Resolve security concern: Substantiate permission rejection after the identity switch - The body reports the relevant loopback scenario, while the committed negative regression supplies a mocked REST rejection; neither supplies an inspectable request/response trace for the reported run.
  • Resolve merge risk - Before merge, the PR owner must substantiate final-effect permission enforcement for the switch from webhook identity to bot identity.

Findings

  • [medium] Substantiate permission rejection after the identity switch — extensions/discord/src/outbound-adapter.ts:88

Tests

  • Missing end-to-end proof: Provide captured production-adapter HTTP evidence for allowed bot replies and a permission-denied bot send with no webhook fallback; a live Gateway is unnecessary for this focused boundary.
Agent review details

How this fits together

The Discord outbound adapter receives delivery context, selects the bot or bound-thread webhook transport, and returns platform receipts to the shared delivery lifecycle.

flowchart TD
  A[Shared delivery lifecycle] --> B[Discord outbound adapter]
  B --> C[Effective native reply]
  C --> D[Bot message sender]
  B --> E[Reply-free webhook persona]
  D --> F[Discord HTTP endpoint]
  E --> F
  F --> G[Delivery receipts]
Loading

Technical review

Best possible solution:

Keep native replies with the existing bot sender and ordinary persona messages with the webhook sender, retaining the current authorization and receipt owners.

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

Current main routes reply-bearing bound-thread text through Execute Webhook, whose documented request contract lacks native message references; no target code was executed during this review.

Is this the best way to solve the issue?

The patch is the smallest complete repair: select the existing native sender for effective replies and remove unsupported webhook reference handling without adding another delivery owner.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 651f9701c17e.

Merge-risk options

Maintainer options:

  1. Supply the permission-boundary trace (recommended)
    The PR owner should attach redacted output from the reported production-adapter loopback run showing allowed native delivery and a bot thread-permission denial without webhook fallback.

Provenance checked

  • Bound-thread webhook selection changes intended behavior with a stated reason (feat: thread-bound subagents on Discord #21805: Thread-bound subagents route outbound messages into their thread with a webhook persona; later delivery refactors retained that behavior.)
  • Webhook physical-chunk reply scope changes intended behavior with a stated reason (d6be581: Preserve requested first/all reply scope while keeping line-limit resolution with the Discord sender.)
  • Webhook reply receipt metadata and documentation changes intended behavior with a stated reason (7890ce9: Retain each requested reply target in aggregate and progress receipts, without establishing Discord acceptance of that webhook field.)

Testing

Proof path: in-process harness.

Security

Needs attention: Existing authorization checks remain intact, but the changed sending principal needs final-effect permission evidence.

Evidence

Security concerns:

  • [medium] Substantiate permission rejection after the identity switch — extensions/discord/src/outbound-adapter.ts:88
    The body reports the relevant loopback scenario, while the committed negative regression supplies a mocked REST rejection; neither supplies an inspectable request/response trace for the reported run.
    Confidence: 0.95

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 7890ce9 adds extensions/discord/src/send.webhook.ts:127 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 7890ce92cf1b; files: extensions/discord/src/send.webhook.ts)
  • JC: Raw commit d6be581 adds extensions/discord/src/outbound-adapter.ts:49 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: d6be5810d9ed; files: extensions/discord/src/outbound-adapter.ts)

PR surface

Source -16, Tests +73, Docs 0. Total +57 across 7 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 2 18 -16
Tests 4 81 8 +73
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 84 27 +57

Review metrics

Metric Value Why it matters
Production versus regression code Production +2/-18; tests +81/-8 The change removes unsupported transport machinery while adding coverage for native reply scope, receipts, and permission rejection.

Labels

Label changes:

  • add P2: Native reply relationships fail in the limited bound-thread persona path.
  • add merge-risk: 🚨 security-boundary: The selected sending principal changes, and final-effect permission-denial evidence remains unsubstantiated by a captured transport trace.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.
  • remove P1: Current review triage priority is P2, so this older priority label is no longer current.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🧂 unranked krab, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 📣 needs proof.

Label justifications:

  • P2: Native reply relationships fail in the limited bound-thread persona path.
  • merge-risk: 🚨 compatibility: Native replies change visible sender identity and require bot thread-send permission; the maintainer-authored body explicitly accepts this tradeoff.
  • merge-risk: 🚨 security-boundary: The selected sending principal changes, and final-effect permission-denial evidence remains unsubstantiated by a captured transport trace.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Attach the reported production-adapter request/response trace showing permitted native replies and a thread-permission 403 with no webhook fallback.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (6 earlier review cycles)
  • reviewed 2026-08-26T03:10:09.309Z sha 47b5e56 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-26T03:48:38.890Z sha f48384b :: needs maintainer review before merge. :: none
  • reviewed 2026-09-04T18:38:27.354Z sha f48384b :: blocked before merge. :: none
  • reviewed 2026-09-22T11:51:08.008Z sha f48384b :: blocked before merge. :: none
  • reviewed 2026-10-07T07:15:04.305Z sha f48384b :: blocked before merge. :: none
  • reviewed 2026-10-24T07:15:57.333Z sha 26c432b :: needs changes before merge. :: [P2] Update durable webhook scenarios for reply-aware routing

Reviewed October 24, 2026, 3:45 AM ET / 07:45 UTC (Revision 7).

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 26, 2026
@fuller-stack-dev fuller-stack-dev self-assigned this Sep 17, 2026
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 7, 2026
@steipete
steipete force-pushed the codex/qa-discord-thread-webhook-explicit-replies-20260826 branch from f48384b to 26c432b Compare October 24, 2026 07:10
@steipete steipete changed the title fix(discord): preserve explicit replies on thread-bound sessions fix(discord): preserve native replies in bound threads Oct 24, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 24, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 24, 2026
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Oct 24, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed P1 High-priority user-facing bug, regression, or broken workflow. 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. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 24, 2026
@steipete
steipete merged commit 305b0d7 into main Oct 24, 2026
156 of 158 checks passed
@steipete
steipete deleted the codex/qa-discord-thread-webhook-explicit-replies-20260826 branch October 24, 2026 12:51
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 25, 2026
* fix(discord): preserve native replies in bound threads

* test(discord): distinguish persona sends from native replies
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 maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants