Skip to content

[Bug]: Group/channel Discord sessions get new sessionId on every incoming message (Windows) #17971

@ben-g-innoiso

Description

@ben-g-innoiso

Summary

Environment
OpenClaw version: 2026.2.14 & 2026.2.15
OS: Windows (PowerShell)
Channel: Discord (guild channel + possibly threads)
Gateway mode/bind: loopback (127.0.0.1:18789)
Install type: (npm/git) + whether openclaw gateway install is used (Scheduled Task) or manual openclaw gateway
Note: openclaw gateway install fails with Access is denied unless run as Administrator (Windows).

Symptom
In Discord, the agent appears to “forget” context after every message or every few messages.
This looks like either:
Session churn (same sessionKey but sessionId changes), and/or
Session switching (messages sometimes land in a different sessionKey due to threads/parent channel mapping).
What I expected
Messages in the same Discord channel/thread should reuse the same session (same sessionKey and stable sessionId over time).

What I observed (redacted)

  1. Session reset behavior
    Session keys involved:
    agent:main:discord:channel:<REDACTED_CHANNEL_ID_1>
    agent:main:discord:channel:<REDACTED_CHANNEL_ID_2> (unexpected / appears intermittently)
    In some runs, the sessionId for <REDACTED_CHANNEL_ID_1> changes between adjacent messages even without gateway restart.
    (If this is “session switching” instead, note that here.)

  2. Reset config check
    I set:
    session: {
    resetByChannel: {
    discord: { mode: "idle", idleMinutes: 10080 } // 7 days
    }
    }

Verified via:
openclaw config get session.resetByChannel.discord
openclaw config get session

  1. Gateway process / port sanity checks (Windows)
    At various points I found multiple gateway-related Node processes.
    I used these commands to debug:
    Get-NetTCPConnection -LocalPort 18789 -State Listen |
    Select-Object LocalAddress,LocalPort,OwningProcess

Get-CimInstance Win32_Process |
Where-Object { $.CommandLine -and $.CommandLine -match "openclaw.*gateway" } |
Select-Object ProcessId,ParentProcessId,CommandLine

Sometimes this produced two PIDs, and in at least one case there were two independent gateway instances vs a normal parent/child pair.

Steps to reproduce

Reproduction steps (minimal)

  1. Start gateway (openclaw gateway) and connect Discord bot.
  2. Send message A in a Discord channel/thread.
  3. Send message B in the same place.
  4. Inspect sessions:
    openclaw sessions --active 10 --json
  5. Observe whether:
    same Discord place → same sessionKey, stable sessionId (expected), or
    sessionId changes / multiple discord:channel keys get updated unexpectedly (bug).

Expected behavior

Expected behavior:
When a Discord message triggers a run in a group/channel session, the gateway should
reuse the existing sessionId for that channel's session key (e.g.
agent:main:discord:channel:). The conversation transcript should accumulate across
messages, allowing the bot to remember prior context. The sessionId should only change
when an explicit reset policy triggers (daily reset, idle timeout, /new command, or
context limit reached).

Actual behavior

Actual behavior
Observed Behavior

134+ orphaned .jsonl transcript files in the sessions directory — one per minted sessionId
Each transcript contains only a single exchange (1 user message + 1 assistant response)
sessions.preview returns only 4 items (latest exchange), no prior history
Bot explicitly states: "this is a fresh conversation with no prior messages in it"
Session is stable when idle — sessionId only changes when a Discord message triggers a run
Rotation happens even 6-8 seconds apart between consecutive messages

OpenClaw version

2026.2.13 & 2026.2.14 & 2026.2.15

Operating system

Windows 11

Install method

(npm/git) + whether openclaw gateway install is used (Scheduled Task) or manual openclaw gateway

Logs, screenshots, and evidence

Impact and severity

No response

Additional information

Evidence (sanitized) Paste a short excerpt from openclaw sessions --active 10 --json with: key: "agent:main:discord:channel:" sessionId: "<REDACTED_UUID>" updatedAt, ageMs (Optional) any second agent:main:discord:channel: entry that appears Example (sanitized): { "key": "agent:main:discord:channel:", "sessionId": "", "updatedAt": , "ageMs": }

Shoutout @er1c001. Had it first and helped me give up on fixing my bot
#17520

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions