Repository navigation
Description
Summary
On Slack, when an agent posts a reply, the outbound delivery-mirror persists a brand-new session record keyed agent:<id>:slack:channel:<cid>:thread:<ts> for that reply, rather than appending to the conversation's existing thread session. Each reply carries a distinct timestamp, so a steady stream of single-message sessions accumulates: each contains only the bot's outgoing message (a session header plus one assistant delivery-mirror message, with no inbound user turn), or an empty transcript. An active agent accumulates dozens of these near-empty session records.
A secondary observation: the minted mirror entry has no spawnedCwd, so the session transcript header cwd can fall back to process.cwd() (the gateway process working directory) rather than the agent workspace directory.
Environment
- OpenClaw
2026.6.1, host-native Node 24 install, gateway runningdist/index.js gateway. @openclaw/slackchannel plugin2026.6.1.- Still present on the latest release
v2026.6.10: no functional change to the outbound mirror session path landed in2026.6.5through2026.6.10.
Steps to reproduce
- Configure a Slack channel with an agent that replies in threads (normal threaded behavior).
- Have the agent post several replies on the channel.
- Inspect the agent session store (
sessions.json) and the*.jsonltranscripts.
Expected vs actual
- Expected: an outbound reply in a thread is mirrored into that thread's existing session (
:thread:<rootTs>), so one thread maps to one session. - Actual: each outbound reply persists a separate session keyed
:thread:<ts>containing only the bot's message, so a single conversation accumulates many assistant-only session records.
Evidence from a live deployment
- Across the fleet, dozens of
:thread:<ts>session entries appear only for Slack-active agents; on one channel a single agent accumulated 21 such entries. - The large majority are single-message records: a header plus one assistant message tagged
model: "delivery-mirror"with an idempotency key of the form<...>:message-tool:call_<...>, and no inbound user turn; some have an empty transcript. - The suffixes are distinct, tightly spaced timestamps (seconds apart) within a continuous exchange. One minted session's outbound reply timestamp was observed becoming the
:thread:suffix of the next minted session. - One minted key carried
thread:/dev/nullas its thread id, indicating a non-timestamp value reached the session-key suffix without validation.
Pointers for triage (verified present in the deployed build, not a claimed root cause)
Filenames are build-hashed esbuild chunk names; line numbers are from the deployed 2026.6.1 build.
- The outbound delivery-mirror is rebuilt and persisted on every send:
prepareOutboundMirrorRoutecallsensureOutboundSessionEntryand writes the mirror under the resolved route's session key (dist/message-action-runner-<hash>.js, around lines 565-590). ensureOutboundSessionEntrycallsrecordSessionMetaFromInboundwith nocreateIfMissingargument (dist/outbound-session-<hash>.js, around lines 122-141), and that defaultscreateIfMissing = params.createIfMissing ?? true(dist/store-<hash>.js:1254; the only skip isif (!existing && !createIfMissing)at line 1283), so a route key with no existing entry mints a new session.- The thread-suffixed key is built by
resolveThreadSessionKeysas`${baseSessionKey}:thread:${normalizedThread}`(dist/session-key-<hash>.js, around lines 182-192). - The cwd fallback: the transcript header sets
cwd: params.cwd ?? process.cwd()(dist/transcript-<hash>.js, around line 142); the mirror append passescwd: entry.spawnedCwd(around line 745), which is absent on the mirror entry.
Related (not duplicate)
- #80091 (Slack DM delivery mirrors split sessions; its fix PR #80111 was closed without merging). Same delivery-mirror routing area, but that report is a DM peer mis-classification.
- #78505 (outbound thread reply does not promote the session key; closed). Closest conceptual match.
- #87019 (Slack DM session fan-out; open) and umbrella #69208 (cross-channel transcript and session duplication).
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon Jun 24, 2026
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 24, 2026, 3:27 PM ET / 19:27 UTC.
Summary
Keep open: current main and the latest release still have a source-reproducible Slack outbound mirror path where an inherited child reply timestamp can win over the existing thread session and create a fresh mirror-only session entry.
Reproducibility: yes. at source level: an inherited Slack child reply timestamp can enter outbound mirror routing and win over the recovered current thread session before ensureOutboundSessionEntry creates the missing mirror session. I did not run a live Slack workspace replay.
Next step
The source path, likely files, and focused regression tests are clear enough for one narrow fix PR, and no open PR currently owns this exact symptom.
Review details
Best possible solution:
Fix Slack outbound mirror routing so inherited same-thread replies mirror into the canonical/current Slack thread session while preserving explicit reply/thread targets and ordinary top-level channel sessions.
Do we have a high-confidence way to reproduce the issue?
Yes, at source level: an inherited Slack child reply timestamp can enter outbound mirror routing and win over the recovered current thread session before ensureOutboundSessionEntry creates the missing mirror session. I did not run a live Slack workspace replay.
Is this the best way to solve the issue?
Yes, the narrow maintainable direction is to canonicalize Slack inherited same-thread reply routing to the thread root or existing thread session for delivery mirrors, rather than adding a config flag or changing generic precedence for every channel.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
Codex review notes: model internal, reasoning high; reviewed against 7e2b2d2987b2.
Label changes
Label justifications:
P2: The issue is a normal-priority Slack channel/session bug with limited blast radius to outbound delivery-mirror state.impact:session-state: The reported behavior creates near-empty sibling sessions instead of updating the intended Slack thread session.impact:message-loss: Outbound mirror records are associated away from the conversation thread, leaving persisted channel-message history incomplete for that thread.Evidence reviewed
Acceptance criteria:
What I checked:
AGENTS.md:1, 7e2b2d2987b2)src/infra/outbound/message-action-threading.ts:193, 7e2b2d2987b2)extensions/slack/src/channel.ts:309, 7e2b2d2987b2)src/plugin-sdk/core.ts:443, 7e2b2d2987b2)src/config/sessions/store.ts:1868, 7e2b2d2987b2)src/plugin-sdk/core.ts:443, aa69b12d0086)Likely related people:
extensions/slack/src/channel.ts,src/infra/outbound/message-action-threading.ts)src/infra/outbound/message-action-threading.ts,extensions/mattermost/src/session-route.ts)src/config/sessions/store.ts)extensions/slack/src/channel.ts,src/plugin-sdk/core.ts)extensions/slack/src/channel.ts,src/infra/outbound/message-action-threading.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.