openclaw - 💡(How to fix) Fix Thread-bound Discord chat sessions lose context: claude-cli spawned without --resume, topic-bound transcript jsonl never written [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#81439Fetched 2026-05-14 03:32:14
View on GitHub
Comments
1
Participants
2
Timeline
3
Reactions
2
Author
Timeline (top)
commented ×1mentioned ×1subscribed ×1

For Discord thread chat sessions on agent main (runtime claude-cli), conversation context is lost between turns. Each new user message in a thread results in claude-cli starting cold, only seeing the latest message. DM sessions on the same agent retain context correctly.

Root Cause

For Discord thread chat sessions on agent main (runtime claude-cli), conversation context is lost between turns. Each new user message in a thread results in claude-cli starting cold, only seeing the latest message. DM sessions on the same agent retain context correctly.

Fix Action

Workaround

Pinning agents.list[<main>].model so it matches claude-cli's internal default eliminates a secondary symptom (model swap between openclaw 4.6 and claude-cli 4.7) but does not fix the missing-context bug; thread sessions still lose continuity.

Code Example

pid 3126613 (DM):           claude -p ... --resume 6e49f4b1-... --model opus ...
pid 3126037 (thread child):  claude -p ...                       --model opus ...
pid 3123748 (thread child):  claude -p ...                       --model opus ...
RAW_BUFFERClick to expand / collapse

Summary

For Discord thread chat sessions on agent main (runtime claude-cli), conversation context is lost between turns. Each new user message in a thread results in claude-cli starting cold, only seeing the latest message. DM sessions on the same agent retain context correctly.

Version

OpenClaw 2026.5.7 (commit eeef486).

Symptoms

In a Discord thread, the assistant frequently replies "I don't have context" / "fresh session" — sometimes mid-conversation, sometimes on the second user turn. Same agent, same user, in DM: context is retained across turns.

Evidence

1. Running claude-cli processes differ in --resume handling

pid 3126613 (DM):           claude -p ... --resume 6e49f4b1-... --model opus ...
pid 3126037 (thread child):  claude -p ...                       --model opus ...
pid 3123748 (thread child):  claude -p ...                       --model opus ...

Only the DM child is invoked with --resume <cliSessionId>. Thread children are spawned without it, so claude-cli starts a fresh internal conversation each turn.

2. claude-cli's per-session jsonl exists and has history

For thread 1504119148773642340 ("Issue 3004: Auto Favorites"), the cliSessionId f21b4496-26fe-489e-a0e4-b792c729aa5b has a populated jsonl:

``` $ wc -l ~/.claude/projects/<workspace>/f21b4496-26fe-489e-a0e4-b792c729aa5b.jsonl 164 ... ```

The history exists — openclaw just isn't telling claude-cli to resume it.

3. OpenClaw's topic-bound transcript jsonl is never written

sessions.json references a file that doesn't exist:

```json "agent:main:discord:channel:1504119148773642340": { "sessionId": "a662d685-4139-4d54-94ed-1efb27b9f83e", "sessionFile": "/home/.../sessions/a662d685-...-topic-1504119148773642340.jsonl" } ```

``` $ ls .../sessions/a662d685* ls: cannot access ...: No such file or directory ```

The .deleted.<timestamp> rename convention is in use elsewhere in that directory (3 examples), so this isn't a deletion — the file simply was never written. Other thread sessions on the same agent do have their topic-bound jsonl present (e.g. 34ffc4d8-...-topic-1503891910912118875.jsonl — 60K), so the write path is not universally broken, only for some thread sessions.

4. sessions_history MCP tool reconstructs only what claude-cli imported

When the harness eventually imports turns from claude-cli into the openclaw store, each entry has:

  • api: \"anthropic-messages\", provider: \"claude-cli\", importedFrom: \"claude-cli\", same cliSessionId across turns.

The cliSessionId is consistent, suggesting the harness knows the prior CLI session id, but isn't passing it to the next claude invocation.

Expected behavior

For chat sessions where a prior cliSessionId is recorded, subsequent invocations of claude-cli should be passed --resume <cliSessionId> (as DM sessions already do), and the openclaw-side topic-bound transcript jsonl should be written for every turn.

Workaround

Pinning agents.list[<main>].model so it matches claude-cli's internal default eliminates a secondary symptom (model swap between openclaw 4.6 and claude-cli 4.7) but does not fix the missing-context bug; thread sessions still lose continuity.

Repro

Open a Discord thread with the gateway, exchange 3+ messages with the agent over a span. By turn 2 or 3 the assistant will commonly report no prior context, despite the cliSessionId being unchanged in the openclaw-side metadata.


Authored by Merlin 🪄

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…

FAQ

Expected behavior

For chat sessions where a prior cliSessionId is recorded, subsequent invocations of claude-cli should be passed --resume <cliSessionId> (as DM sessions already do), and the openclaw-side topic-bound transcript jsonl should be written for every turn.

Still need to ship something?

×6

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

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix Thread-bound Discord chat sessions lose context: claude-cli spawned without --resume, topic-bound transcript jsonl never written [1 comments, 2 participants]