openclaw - 💡(How to fix) Fix Resume chain broken: cliSessionId / previousSessionIds / transcriptPath remain null in agent session record [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#76986Fetched 2026-05-04 04:59:44
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
2
Author
Timeline (top)
closed ×1commented ×1mentioned ×1subscribed ×1

~/.openclaw/agents/<name>/sessions/sessions.json keeps cliSessionId, previousSessionIds, and transcriptPath as null indefinitely on the main agent record. As a result, when the runtime spawns a fresh claude -p for the same agent (e.g. after a cron callback or compaction-induced restart), it can't --resume the prior CLI session — every CLI process exit becomes a context wipe.

Root Cause

Workaround in place

At the content layer, installed a Claude Code SessionStart hook in ~/.claude/settings.json that reads STATE.md and MEMORY.md from the workspace and emits them via hookSpecificOutput.additionalContext. Plus overrode agents.defaults.heartbeat.prompt in ~/.openclaw/openclaw.json because the default prompt (in dist/heartbeat-BARAswcJ.js) contains "Do not infer or repeat old tasks from prior chats" — which directly contradicted the hook-injected continuity context.

Fix Action

Fix / Workaround

Workaround in place

At the content layer, installed a Claude Code SessionStart hook in ~/.claude/settings.json that reads STATE.md and MEMORY.md from the workspace and emits them via hookSpecificOutput.additionalContext. Plus overrode agents.defaults.heartbeat.prompt in ~/.openclaw/openclaw.json because the default prompt (in dist/heartbeat-BARAswcJ.js) contains "Do not infer or repeat old tasks from prior chats" — which directly contradicted the hook-injected continuity context.

These workarounds restore summarized continuity. They can't substitute for actual --resume because STATE.md only captures the current state, not the conversation history (intermediate tool calls, sub-agent reasoning, etc.).

RAW_BUFFERClick to expand / collapse

Summary

~/.openclaw/agents/<name>/sessions/sessions.json keeps cliSessionId, previousSessionIds, and transcriptPath as null indefinitely on the main agent record. As a result, when the runtime spawns a fresh claude -p for the same agent (e.g. after a cron callback or compaction-induced restart), it can't --resume the prior CLI session — every CLI process exit becomes a context wipe.

Versions

  • openclaw 2026.4.21
  • claude CLI 2.1.114
  • macOS Darwin 25.3.0

Repro

  1. Run main agent for an extended session via claude -p. Confirm transcript accumulates under ~/.claude/projects/<workspace-path>/<sessionId>.jsonl.
  2. Trigger a fresh CLI process (cron callback with wakeMode: now, or let the underlying CLI session rotate from a config change / plugin reload).
  3. Inspect ~/.openclaw/agents/<name>/sessions/sessions.json for the agent.

Observed: ```json { "sessionId": "41eda629-c62a-4e36-a98c-86653422682a", "cliSessionId": null, "previousSessionIds": null, "transcriptPath": null, "sessionFile": "/Users/.../agents/main/sessions/41eda629-...jsonl" } ```

The runtime never populated the resume-chain fields, even though the actual CLI transcripts exist on disk under ~/.claude/projects/.

Expected

On each CLI process spawn, the runtime should:

  • Capture the new claude -p session ID into cliSessionId
  • Append the prior cliSessionId to previousSessionIds (or maintain a chain)
  • Resolve and store the transcript path so resume can be reattempted

When spawning a fresh CLI for the same agent (e.g. cron callback), pass --resume <cliSessionId> so the new process inherits the prior session's history.

Real-world impact

Today's session went: long productive run ended at session 3b7fe27b... (982KB transcript, 18:22 EDT) → cron callback at 18:23 EDT spawned 6d0a999c... with no resume → user's next message in 336dcf95... at 18:26 EDT had zero context for the immediately-prior conversation. From the user's perspective: "are you sure the callbacks need to be that long?" → "what callbacks?"

Workaround in place

At the content layer, installed a Claude Code SessionStart hook in ~/.claude/settings.json that reads STATE.md and MEMORY.md from the workspace and emits them via hookSpecificOutput.additionalContext. Plus overrode agents.defaults.heartbeat.prompt in ~/.openclaw/openclaw.json because the default prompt (in dist/heartbeat-BARAswcJ.js) contains "Do not infer or repeat old tasks from prior chats" — which directly contradicted the hook-injected continuity context.

These workarounds restore summarized continuity. They can't substitute for actual --resume because STATE.md only captures the current state, not the conversation history (intermediate tool calls, sub-agent reasoning, etc.).

Suggested fix scope

  • Where the runtime invokes claude -p, capture the resulting session ID (visible via Claude Code SDK output / transcript filename) and persist it onto the agent record before any subsequent spawn.
  • On subsequent spawns, prefer --resume <previous> and only fall back to fresh-session when resume fails (e.g. transcript was rotated/cleaned up).

Happy to provide more transcripts or a minimal repro on request.

extent analysis

TL;DR

The issue can be resolved by modifying the runtime to capture and persist the cliSessionId and transcriptPath when invoking claude -p, and then passing --resume <previous> on subsequent spawns.

Guidance

  • Identify where the runtime invokes claude -p and capture the resulting session ID from the transcript filename or Claude Code SDK output.
  • Persist the captured session ID onto the agent record in ~/.openclaw/agents/<name>/sessions/sessions.json.
  • Modify the runtime to pass --resume <previous> when spawning a new CLI process for the same agent, falling back to a fresh session only when resume fails.
  • Verify that the cliSessionId, previousSessionIds, and transcriptPath fields are correctly populated in the agent record after implementing the fix.

Example

No code snippet is provided as the issue does not contain sufficient information about the runtime's implementation details.

Notes

The suggested fix scope provided in the issue is a good starting point, but the actual implementation may vary depending on the runtime's architecture and the Claude Code SDK's capabilities.

Recommendation

Apply the workaround of capturing and persisting the session ID, and passing --resume <previous> on subsequent spawns, as it directly addresses the issue and provides a clear path to resolving the problem.

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

openclaw - 💡(How to fix) Fix Resume chain broken: cliSessionId / previousSessionIds / transcriptPath remain null in agent session record [1 comments, 2 participants]