openclaw - 💡(How to fix) Fix [Bug]: sessions.json sessionId/sessionFile null for heartbeat-origin sessions [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#51066Fetched 2026-04-08 01:04:39
View on GitHub
Comments
1
Participants
2
Timeline
1
Reactions
0
Author
Participants
Timeline (top)
commented ×1

Sessions initialized via origin.provider=heartbeat do not write sessionId or sessionFile back to sessions.json. This causes sessions_history to return empty [] despite real transcript content existing on disk.

Root Cause

Sessions initialized via origin.provider=heartbeat do not write sessionId or sessionFile back to sessions.json. This causes sessions_history to return empty [] despite real transcript content existing on disk.

Fix Action

Workaround

Reading transcript .jsonl files directly from disk. Manual sessions.json patches are overwritten on gateway restart.

RAW_BUFFERClick to expand / collapse

Description

Sessions initialized via origin.provider=heartbeat do not write sessionId or sessionFile back to sessions.json. This causes sessions_history to return empty [] despite real transcript content existing on disk.

Steps to Reproduce

  1. Agent session initialized by heartbeat cron (not Telegram/webchat)
  2. Check agents/{agent}/sessions/sessions.json
  3. Observe sessionId: null, sessionFile: null
  4. Call sessions_history → returns empty []

Expected Behavior

sessions.json should have sessionId and sessionFile populated regardless of how the session was first initialized.

Actual Behavior

Only sessions first triggered via Telegram or webchat write correctly. Heartbeat-origin sessions never get the pointer set.

Affected Agents

  • agent:jake:mainsessionId=null, sessionFile=null (transcript exists: 0b9dc2ef...jsonl, 38 messages)
  • agent:jaynus:main — same pattern

Working Example

  • agent:solomon:main — correctly has sessionId and sessionFile populated (first triggered via webchat/telegram)

Impact

  • sessions_history returns empty for affected agents
  • Cross-agent memory/retro systems cannot read session transcripts via API
  • Memory checkpoint crons fail, MEMORY.md goes stale
  • 8+ days unresolved in our fleet

Workaround

Reading transcript .jsonl files directly from disk. Manual sessions.json patches are overwritten on gateway restart.

Environment

  • OpenClaw gateway (container)
  • Node.js v24.14.0
  • Multiple agents affected

extent analysis

Fix Plan

To fix the issue of sessions initialized via origin.provider=heartbeat not writing sessionId or sessionFile back to sessions.json, we need to modify the session initialization logic.

Here are the concrete steps:

  • Update the heartbeat cron job to include the necessary logic to populate sessionId and sessionFile in sessions.json.
  • Modify the sessions.json writing function to handle sessions initialized by heartbeat cron.

Example code snippet:

// Update the session initialization function to handle heartbeat cron
function initSession(origin) {
  if (origin.provider === 'heartbeat') {
    // Generate sessionId and sessionFile
    const sessionId = generateSessionId();
    const sessionFile = `sessions/${sessionId}.jsonl`;
    
    // Write sessionId and sessionFile to sessions.json
    const sessionsJson = readSessionsJson();
    sessionsJson.sessionId = sessionId;
    sessionsJson.sessionFile = sessionFile;
    writeSessionsJson(sessionsJson);
  }
}

// Helper function to generate sessionId
function generateSessionId() {
  return crypto.randomUUID();
}

// Helper functions to read and write sessions.json
function readSessionsJson() {
  // Read sessions.json from file
}

function writeSessionsJson(sessionsJson) {
  // Write sessionsJson to file
}

Verification

To verify that the fix worked:

  • Initialize a new session via heartbeat cron.
  • Check sessions.json to ensure sessionId and sessionFile are populated.
  • Call sessions_history to verify it returns the expected session history.

Extra Tips

  • Ensure the generateSessionId function generates unique IDs to avoid conflicts.
  • Consider adding error handling to the initSession function to handle cases where writing to sessions.json fails.
  • Review the sessions.json writing function to ensure it handles concurrent updates correctly.

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 [Bug]: sessions.json sessionId/sessionFile null for heartbeat-origin sessions [1 comments, 2 participants]