Repository navigation
Description
Bug: ACP thread-bound session replies generated but not delivered to Discord thread
Environment
- OpenClaw version: 2026.6.10 (git sha:
97aaf2a) - Node.js: v24.14.1
- OS: Linux 6.8.0-106-generic (x64)
- Channel: Discord
- ACP backend: acpx (Claude Agent SDK)
- Claude model: claude-opus-4-8
Summary
When spawning a Claude Code ACP session with sessions_spawn(runtime="acp", thread=true, mode="session"), the ACP session internally processes user messages and generates correct replies, but the replies are never delivered back to the Discord thread. The user sees no response in the thread despite Claude Code having responded successfully.
Reproduction Steps
- Configure Discord channel with
threadBindings.enabled: trueandthreadBindings.spawnSessions: true - In Discord, trigger a Claude Code ACP thread spawn (e.g. ask the main agent to start a coding task with Claude Code)
- The thread is created and the initial ACP response may or may not appear
- Send a follow-up message in the thread (e.g. "你是什么模型?")
- Expected: Claude Code's reply appears in the thread
- Actual: No reply appears in the thread
Evidence from session data
1. ACP session transcript confirms replies were generated
Session file: ~/.openclaw/agents/claude/sessions/<session-id>.jsonl
[1782312859974] user: 你是什么模型呢?
[1782312859977] assistant: 我是 Claude Opus 4.8(模型 ID: claude-opus-4-8)...
[1782312881932] user: 你用的是什么模型?
[1782312881937] assistant: 我当前使用的是 Opus 4.8 模型...
[1782313113861] user: 你可以做什么呢?
[1782313113865] assistant: 作为 AI 助手,我可以帮你处理各种软件工程任务...
All user messages received replies. The ACP session internally works correctly.
2. Session metadata shows correct delivery context
From sessions.json:
{
"sessionKey": "agent:claude:acp:ee6778d0-...",
"status": "running",
"route": {
"channel": "discord",
"accountId": "default",
"thread": { "id": "1519354938080235580" }
},
"deliveryContext": {
"channel": "discord",
"to": "channel:1519354938080235580",
"accountId": "default",
"threadId": "1519354938080235580"
},
"originatingThreadId": "1519354938080235580"
}The delivery context is correctly populated with the Discord thread ID.
3. Bot CAN send messages to the thread
When the parent agent uses the message tool directly to send a test message to the thread, it succeeds. The bot has proper permissions.
4. ACP sessionKey lacks :thread: suffix
The ACP session key is agent:claude:acp:ee6778d0-... — it does not contain a :thread: suffix. This is notable because resolveRoutedDeliveryThreadId falls back to parseSessionThreadInfoFast(sessionKey), which extracts thread IDs from the session key's :thread: suffix.
Code path analysis
The delivery goes through:
dispatch-acpmodule →createAcpDispatchDeliveryCoordinator()deliver(kind, payload)function- When
shouldRouteToOriginatingis true → callsrouteReply() threadIdis resolved via:params.originatingThreadId(from session metadata)- OR
resolveRoutedDeliveryThreadId()which tries:sessionCtx.MessageThreadId(from inbound message transport)sessionCtx.TransportThreadId(from transport layer)parseSessionThreadInfoFast(sessionKey)(parses:thread:suffix)
The delivery failure appears to happen inside routeReply(), but the error is only logged via logVerbose() which outputs to gateway stdout. Since the gateway's stdout is piped to a socket, these logs are not easily accessible for debugging.
Relevant code in dispatch-acp-CFUMtx6P.js:572:
if (!result.ok) {
logVerbose(`dispatch-acp: route-reply (acp/${kind}) failed: ${result.error ?? "unknown error"}`);
return false;
}Observations
- Initial task completion (
mode="run"style) may deliver the first reply, but follow-up messages in the thread never get replies delivered lastInteractionAtis not updated when follow-up messages arrive (stays at spawn time), even thoughupdatedAtis- The issue affects
accountId: "default"sessions;accountId: "coder"sessions need further verification - Two currently running ACP sessions (
a0cbaf86,6eb2eda6) exhibit the same behavior
Debugging suggestions
- Expose
logVerboseoutput fordispatch-acp: route-replyfailures — pipe to a log file or make it accessible via the API - Add a metric/counter for ACP delivery failures so they're visible in
/status - Check if
shouldRouteToOriginatingis correctly set totruefor follow-up ACP runs - Verify
originatingThreadIdpropagation from session metadata to the delivery coordinator for follow-up runs (not just the initial spawn)
Related issues
- [Feature]: Visible agent-to-agent messaging for ACP thread-bound sessions (proxy-only delivery without main session creation) #50798 — Visible agent-to-agent messaging for ACP thread-bound sessions
- Decouple mode="session" from thread binding requirement #53548 — Decouple mode="session" from thread binding requirement
- ACP: keep thread-bound follow-ups parent-orchestrated by default, not raw pass-through #69669 — ACP: keep thread-bound follow-ups parent-orchestrated by default
- ACP bound sessions: relay progress events to channel draft (streamTo:"parent" in binding config) #80556 — ACP bound sessions: relay progress events to channel draft
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon Jun 25, 2026
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 29, 2026, 12:29 PM ET / 16:29 UTC.
Summary
Keep open: current main still lacks the stored ACP delivery-context thread fallback needed for this Discord thread-delivery report, and the related focused fix PR is open but not merged and has its own review blockers.
Reproducibility: no. live reproduction was run, but the issue is source-reproducible: current main cannot recover
deliveryContext.threadIdfor ACP session keys that lack a:thread:suffix on the visible ACP dispatch path.Root-cause cluster
Relationship:
canonicalCanonical: #96665
Summary: This issue is the canonical concrete Discord/ACP delivery report; the related open PR is a candidate fix but is not merged or sufficient yet.
Members:
fixed_by_candidate: fix(acp): resolve delivery threadId from session deliveryContext for ACP sessions #97633 - The PR explicitly targets the missing ACPdeliveryContext.threadIdfallback described by this issue, but it remains open and reviewed as incomplete.partial_overlap: [Feature]: Visible agent-to-agent messaging for ACP thread-bound sessions (proxy-only delivery without main session creation) #50798 - That issue concerns visible ACP thread-bound messaging and route pollution, but it asks for a broader product capability rather than this final-reply delivery failure.adjacent_distinct: ACP: keep thread-bound follow-ups parent-orchestrated by default, not raw pass-through #69669 - That issue concerns parent-orchestrated semantics for ACP follow-ups, while this issue concerns generated replies not reaching Discord.adjacent_distinct: ACP bound sessions: relay progress events to channel draft (streamTo:"parent" in binding config) #80556 - That issue concerns live progress/draft streaming for ACP sessions, not final follow-up reply delivery to the Discord thread.Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.
Ways to help us reproduce this
Next step
No new repair job should be queued while the issue is already paired with the open focused candidate PR.
Review details
Best possible solution:
Keep this issue as the canonical user report until a PR wires a trusted ACP stored thread id into visible ACP dispatch, preserves the stale-route guard, adds focused regression coverage, and provides redacted Discord/ACP proof.
Do we have a high-confidence way to reproduce the issue?
No live reproduction was run, but the issue is source-reproducible: current main cannot recover
deliveryContext.threadIdfor ACP session keys that lack a:thread:suffix on the visible ACP dispatch path.Is this the best way to solve the issue?
Yes for the direction, not for closing yet: the narrow maintainable fix is to pass a trusted ACP stored thread id into pre-dispatch ACP delivery while preserving the stale-route guard, then prove it with regression and live Discord/ACP evidence.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
Codex review notes: model internal, reasoning high; reviewed against 6de357ad4772.
Label changes
Label changes:
maturity:stable: Discord is scored M4 Stable, and the affected taxonomy feature includes Discord thread-bound session routing and ACP agent routing.Label justifications:
P2: This is a bounded but user-visible ACP Discord delivery bug rather than a core-wide outage.impact:message-loss: The reported failure is generated ACP replies not appearing in the bound Discord thread.impact:session-state: The bug depends on ACP thread-bound session routing metadata and stored delivery context.maturity:stable: Discord is scored M4 Stable, and the affected taxonomy feature includes Discord thread-bound session routing and ACP agent routing.Evidence reviewed
What I checked:
--threadshould route follow-up messages directly to the ACP session and deliver ACP output back to the same channel/thread/topic. Public docs:docs/tools/acp-agents.md. (docs/tools/acp-agents.md:621, 6de357ad4772)resolveRoutedDeliveryThreadIdonly checks inboundMessageThreadId, inboundTransportThreadId, and the session-key thread suffix; ACP keys likeagent:<id>:acp:<uuid>do not carry that suffix. (src/auto-reply/reply/routed-delivery-thread.ts:5, 6de357ad4772)src/auto-reply/reply/dispatch-from-config.ts:1301, 6de357ad4772)reply_dispatchpassesoriginatingThreadId: routeReplyThreadIdinto the ACP hook, so visible ACP delivery can be controlled before the later normal reply-run path executes. (src/auto-reply/reply/dispatch-from-config.ts:2636, 6de357ad4772)originatingThreadIdis absent, ACP delivery callsresolveRoutedDeliveryThreadIdwith onlyctxandsessionKey, not the stored session entry that containsdeliveryContext.threadId. (src/auto-reply/reply/dispatch-acp-delivery.ts:429, 6de357ad4772)deliveryContext.threadIdobservation. (src/gateway/server-methods/agent.ts:1910, 6de357ad4772)Likely related people:
dispatch-from-config,dispatch-acp-delivery, andget-reply-run. (role: recent area contributor; confidence: medium; commits: c67dc59b02b0; files:src/auto-reply/reply/dispatch-from-config.ts,src/auto-reply/reply/dispatch-acp-delivery.ts,src/auto-reply/reply/get-reply-run.ts)src/auto-reply/reply/dispatch-acp-delivery.ts,src/auto-reply/reply/dispatch-from-config.ts,src/auto-reply/reply/effective-reply-route.ts)deliveryContextfrom request channel/to/threadId, which is the stored source needed here. (role: delivery-context seeding contributor; confidence: medium; commits: ac13b09b742d; files:src/gateway/server-methods/agent.ts,src/gateway/server.agent.subagent-delivery-context.test.ts)src/gateway/server-methods/agent.ts)How this review workflow works
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.openclaw-barnacle commentedon Jul 14, 2026
This issue has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.
openclaw-barnacle commentedon Jul 21, 2026
Closing due to inactivity.
If this is still an issue, please retry on the latest OpenClaw release and share updated details.
If you are absolutely sure it still happens on the latest release, open a new issue with fresh steps to reproduce.