Repository navigation
fix(discord): subagent results posted into a Discord thread requester are marked failed - #163756
Conversation
…n thread
A requester living in a Discord thread posts its verified result with the
message tool and ends with NO_REPLY. Discord addresses a thread by its own
channel id, so the send was recorded as channel:<T> with no thread evidence
and never matched the requester route {to: channel:<T>, threadId: <T>}; every
child completion was marked failed.
Discord now implements threading.resolveAutoThreadId, returning the current
thread only when the send targets that thread's own channel. Parent and
sibling channels gain no thread evidence, and the send target is unchanged.
Related to openclaw#163724
|
🦞👀 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 October 2, 2026, 6:29 PM ET / 22:29 UTC (Revision 2). ClawSweeper reviewWhat this changesDiscord now identifies message-tool sends to the requester’s own thread so successfully posted subagent results count as delivered, with resolver and settlement regression coverage. Merge readiness✅ Ready for maintainer review This remains a useful, focused fix absent from current main and the latest release. The new Gateway and HTTP traces satisfy the earlier proof request, and no blocking patch defect was found. Priority: P1 Review scores
Verification
How this fits togetherDiscord’s channel plugin supplies conversation identity to OpenClaw’s shared message tool. Subagent completion accounting uses that identity to determine whether the requester actually delivered its result. flowchart TD
A[Child task finishes] --> B[Requester resumes in Discord thread]
B --> C[Message tool sends result]
C --> D[Discord resolves thread identity]
D --> E[Discord transport posts message]
E --> F[Completion checks delivery evidence]
F --> G[Child delivery recorded]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +10, Tests +97. Total +107 across 3 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Keep thread identity in Discord’s existing adapter so settlement recognizes successful same-thread delivery without weakening shared destination checks. Do we have a high-confidence way to reproduce the issue? Yes: current source explains the missing thread evidence, and the supplied red/green Gateway trace exercises the reported spawn, yield, message-tool send, and silent settlement flow. This reviewer did not execute a current-main reproduction. Is this the best way to solve the issue? Yes: implementing Discord’s existing thread resolver repairs the producer of delivery identity while preserving the shared matcher, destination, and unrelated inbound context behavior. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 1b986492be2c. LabelsLabel changes:
Label 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)
|
|
Landed as 782abf3. Thanks @MertBasar0! |
… are marked failed (openclaw#163756) Fixes openclaw#163724. A requester session in a Discord thread that posts a subagent result with the message tool and then replies `NO_REPLY` had the child completion marked as failed, even though the post appeared in the thread. Discord now implements `threading.resolveAutoThreadId`. It returns the current thread only when the send targets that thread's own channel, so the delivery matcher credits the post. Sends to parent or sibling channels get no thread evidence and are not credited. Proof: a built Gateway ran the real Discord plugin against a local Discord stand-in (Crabline) with `visibleReplies=message_tool`. Base reported failed/intentional_non_delivery, and this change reports delivered. Both posted once to `channel:T`. Parent and sibling sends were not credited. Normal threaded finals and automatic mode delivered on both. When the thread has a webhook binding, the message-tool send now uses that webhook with `thread_id=T`, which matches the session's normal threaded replies; the destination is unchanged. The regression test fails on base and passes here. A live gpt-5-mini call passed. Co-authored-by: Ayaan Zaidi <[email protected]>
… are marked failed (openclaw#163756) Fixes openclaw#163724. A requester session in a Discord thread that posts a subagent result with the message tool and then replies `NO_REPLY` had the child completion marked as failed, even though the post appeared in the thread. Discord now implements `threading.resolveAutoThreadId`. It returns the current thread only when the send targets that thread's own channel, so the delivery matcher credits the post. Sends to parent or sibling channels get no thread evidence and are not credited. Proof: a built Gateway ran the real Discord plugin against a local Discord stand-in (Crabline) with `visibleReplies=message_tool`. Base reported failed/intentional_non_delivery, and this change reports delivered. Both posted once to `channel:T`. Parent and sibling sends were not credited. Normal threaded finals and automatic mode delivered on both. When the thread has a webhook binding, the message-tool send now uses that webhook with `thread_id=T`, which matches the session's normal threaded replies; the destination is unchanged. The regression test fails on base and passes here. A live gpt-5-mini call passed. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 782abf3) Co-authored-by: RomneyDa <[email protected]>
Closes #163724
What Problem This Solves
Fixes: a requester session that lives in a Discord thread posts its result with the message tool and ends with
NO_REPLY, the post shows up in the thread, and every child completion is still markeddeliveryStatus=failed.User Impact
User impact: subagent results posted into the requester's own Discord thread are now counted as delivered, instead of showing as failed tasks with a misleading "recovered requester" error.
Why This Change Was Made
Discord addresses a thread by its own channel id. The settle turn's requester route is
{to: channel:T, threadId: T}, but the message-tool send was recorded as plainchannel:Twith no thread evidence, sosourceDeliveryTargetsMatchrejected it. Other threaded channels (Slack, Telegram, Matrix, MSTeams, Mattermost) supply that evidence throughthreading.resolveAutoThreadId. Discord didn't implement it.Discord now implements
resolveAutoThreadId. It returns the current thread only when the send's target normalizes to that thread's own channel (channel:<currentThreadTs>). The shared matcher is unchanged.{to: channel:T, threadId: T}tochannel:T, and the outbound session route is keyed on the same peer id. One routing difference: whenThas a webhook thread binding, the message-tool send now uses the same binding path as the session's normal threaded replies.buildToolContextis intentionally left alone. Passing inboundMessageThreadIdthrough there would change source-reply mirror placement for inbound thread turns, and the settle turn already getscurrentThreadTsandcurrentChannelIdfrom its run context (threadId/tofrom the announce dispatch).Out of scope: the issue's secondary wording point ("recovered requester…" text for runs with no restart).
Evidence
Real behavior proof: isolated mock-Gateway channel boundary (Crabline)
There's no live Discord here, so this is an isolated mock-Gateway channel boundary proof. A real QA Gateway runs the real bundled Discord plugin against a Crabline local Discord REST + Gateway WS server.
mock-openaiscripts the reported requester flow:parent_id).sessions_spawn(run mode), thensessions_yield.message(action="send", target="channel:<thread>")and repliesNO_REPLY.Config:
messages.groupChat.visibleReplies: message_tool, the setup where group replies go through the message tool. The proof-only harness (mock planner, scenario, Windows-host staging workarounds) isn't part of this PR.Both runs use the same harness. RED reverts only
extensions/discord/src/channel.tsto base87af5763bb; GREEN is this PR's head96806b7. In both, the real Discord plugin recordsrequesterOrigin = {to: "channel:159028662354834067", threadId: "159028662354834067"}, the shape from the issue.POST /api/v10/channels/<thread>/messages)QA-163724-THREAD-SETTLE-OK …)NO_REPLYcontinuation, 2 settled-turn finalization passes, heartbeat)failed/intentional_non_delivery/message_tool_onlydelivered, 4.3 s after the settle postRED / GREEN suite output
RED's error text is
message_tool_onlyrather than the issue's "recovered requester completed without durable final delivery evidence". That's a different classifier branch on currentmain, with the same outcome: the child is marked failed even though the thread post landed.Webhook-bound thread branch
Crabline has no Discord webhook endpoints, so this branch is proven one layer down, still over real HTTP. The pieces are:
resolveAndApplyOutboundThreadId, whichmessage-action-send.tsruns before it passesthreadIdto the send;outbound.sendText;T;DISCORD_API_URL.The same send is then passed to the settle credit check.
resolvedThreadId: T. OnePOST /api/v10/webhooks/<id>/<token>?wait=true&thread_id=Tand no bot send. The extracted send is{to: channel:T, threadId: T, threadImplicit: true}, and the credit check returnstrue.resolvedThreadId: null. The send goes out as a botPOST /api/v10/channels/T/messages, the extracted send is{to: channel:T}, and the credit check returnsfalse.So in a webhook-bound thread, the settle send now takes the binding's webhook/persona path, the same one the session's normal threaded replies use. It lands in the same channel and is credited.
Tests in this PR
src/agents/subagents/announce/subagent-announce-delivery.discord-thread.test.ts: composed regression with the real Discord plugin. RED without the fix, GREEN with it (2 tests).pnpm test <file> --maxWorkers=1wall time is about 26–31 s, almost all vitest transform; the tests take under 40 ms.extensions/discord/src/channel.test.ts: resolver cases for the same thread (channel:Tand bareT), a sibling channel, a user target, and no current thread. 40/40.source-delivery-plan,source-reply-mirror,subagent-announce-direct-delivery,subagent-announce-delivery.yielded-settle,embedded-agent-subscribe.tools.extract,message-action-threading,extensions/discord/src/outbound-adapter(183 tests).threading.registry-backed-shard-a..hare green as well.oxlint,oxfmt --checkandgit diff --checkare clean. CI is green on96806b7.extensions/discord/src/channel.tssince 2026-01-18, Discord never hadresolveAutoThreadId. This adds a missing hook; it doesn't bring back a removed one.Observed, out of scope: with the default
visibleReplies: automatic, this flow doesn't endfailedon either head. AfterNO_REPLY, the existing settled-turn finalization re-prompts; if the model stays silent, it posts "The tool run finished, but no final summary was produced…", and that visible reply is credited. This PR doesn't change that path.Independent verification (2026-10-03)
Verified unchanged head
96806b7fe59343784ba4f0c68efe9ff50987cff3in secretless Node 24 Docker isolation. No additional source changes were needed. Thanks @MertBasar0 for the fix and @stuart-minion-ai for the report.extensions/discord/src/channel.tsto PR parent87af5763bbc0bd1febc08d78eedc7fafd9eb5225, then rebuilt/finalized the plugin runtime. This is a discriminating revert baseline, not a whole-current-main execution.visibleReplies: message_tool, both versions posted the settle result exactly once to the samePOST /api/v10/channels/T/messages. Baseline persisted child delivery asfailed/intentional_non_delivery; candidate persisteddelivered/delivered. Baseline consumed the scriptedNO_REPLYand finalization continuations; candidate completed at the successful message-tool send.thread_id=Tand the bound persona. Destination stayed T, matching normal bound-thread reply routing.gpt-5-minirequest through the built Gateway returnedP163724-LIVE-OK; utility jobs were disabled. This was a provider smoke, not live Discord proof. The credential file and live container were removed.CI run 37058065890 succeeded on this exact head; no jobs were rerun. The exact-head ClawSweeper review remains ready for maintainer review.