openclaw - 💡(How to fix) Fix Slack: thread replies should optionally route to parent session (thread.sessionMode) [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#50988Fetched 2026-04-08 01:05:52
View on GitHub
Comments
1
Participants
2
Timeline
1
Reactions
0
Participants
Timeline (top)
commented ×1

Code Example

{
  channels: {
    slack: {
      thread: {
        sessionMode: "parent"  // "parent" | "separate" (default: "parent")
      }
    }
  }
}

---

const threadKeys = resolveThreadSessionKeys({
    baseSessionKey,
    threadId: isThreadReply ? threadTs : undefined,
    parentSessionKey: isThreadReply && ctx.threadInheritParent ? baseSessionKey : undefined,
    useSuffix: ctx.threadSessionMode !== "parent",  // NEW
});
RAW_BUFFERClick to expand / collapse

Problem

When a Slack message has a thread_ts, Clawdbot creates a separate session key (baseKey:thread:{threadTs}) via resolveThreadSessionKeys() in routing/session-key.js. This means:

  1. Any bot reply using replyTo creates a Slack thread
  2. Every subsequent message in that thread spawns a separate session per bot listening to the channel
  3. Each separate session has its own context window and burns its own tokens
  4. In multi-bot setups, a single threaded reply can double or triple token spend

This is the #1 token waste issue for multi-agent Slack deployments.

Current behavior

  • resolveThreadSessionKeys() always appends :thread:{threadTs} to the session key (Slack)
  • Discord already passes useSuffix: false, routing thread messages to the parent session
  • channels.slack.thread.inheritParent only sets parentSessionKey — it does NOT prevent the separate session from being created
  • channels.slack.replyToMode: "off" prevents auto-threading but agents can still thread via replyTo in message tool calls

Proposed solution

Add channels.slack.thread.sessionMode config:

{
  channels: {
    slack: {
      thread: {
        sessionMode: "parent"  // "parent" | "separate" (default: "parent")
      }
    }
  }
}
  • "parent" (proposed default): Thread messages route to the parent channel session. Same behavior as Discord's useSuffix: false. Thread context is still available in the message metadata but doesn't create a separate session.
  • "separate" (current behavior): Thread messages create separate sessions as they do today.

Implementation

In slack/monitor/message-handler/prepare.js, pass useSuffix based on the new config:

const threadKeys = resolveThreadSessionKeys({
    baseSessionKey,
    threadId: isThreadReply ? threadTs : undefined,
    parentSessionKey: isThreadReply && ctx.threadInheritParent ? baseSessionKey : undefined,
    useSuffix: ctx.threadSessionMode !== "parent",  // NEW
});

Per-message opt-in (stretch goal)

For cases where separate thread sessions ARE useful (e.g., parallel work items), allow agents to request thread separation explicitly via a message tag or tool parameter like separateSession: true. This inverts the current model: threads are merged by default, separated only on intent.

Environment

  • Clawdbot version: 2026.1.24-3+
  • Channel: Slack (Socket Mode)
  • Multi-agent setup: 5 bots on 2 servers

Related

  • openclaw/openclaw#50984 (thread reply session cost)
  • Discord already uses useSuffix: false for threads

extent analysis

Fix Plan

To address the token waste issue in multi-bot Slack deployments, we will implement the proposed solution by adding a new config option channels.slack.thread.sessionMode.

Here are the steps:

  • Add the following configuration to your Clawdbot settings:
{
  "channels": {
    "slack": {
      "thread": {
        "sessionMode": "parent"
      }
    }
  }
}
  • Update the slack/monitor/message-handler/prepare.js file to pass useSuffix based on the new config:
const threadKeys = resolveThreadSessionKeys({
  baseSessionKey,
  threadId: isThreadReply ? threadTs : undefined,
  parentSessionKey: isThreadReply && ctx.threadInheritParent ? baseSessionKey : undefined,
  useSuffix: ctx.threadSessionMode !== "parent",
});
  • Optionally, to allow agents to request thread separation explicitly, add a message tag or tool parameter like separateSession: true.

Verification

To verify that the fix worked, monitor your token usage and session creation in your multi-bot Slack deployment. You should see a reduction in token waste and separate session creation for threaded messages.

Extra Tips

  • Make sure to update your Clawdbot version to 2026.1.24-3 or later to ensure compatibility with the new config option.
  • If you have existing threaded conversations, you may need to restart your Clawdbot instances or manually update the session keys to reflect the new configuration.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING