alias: GitHub-Issue-Session-Compaction-Bug
created: 2026-02-13T21:31+10:00
status: submitted
tags: [openclaw, bug-report, github, session-compaction]
GitHub Issue: Session Context Compaction Bug
Status: submitted
Created: 2026-02-13 21:31 AEST
Target: https://github.com/openclaw/openclaw/issues
Copy the contents below into a new GitHub issue.
Description
During an active session, the "Reduce Context" compaction process deleted the session transcript file (*.jsonl) while the session was still alive, causing session corruption and complete loss of conversation history. The session remained registered in the system but became unusable because the transcript file was missing.
System Details
- OpenClaw Version: 2026.2.12 (runtime) / 2026.2.9 (wizard last run)
- Default Model: openrouter/stepfun/step-3.5-flash:free
- Compaction Mode:
safeguard (from openclaw.json)
- Platform: Mac Mini 16GB (Apple Silicon), Darwin 25.2.0, Node v25.6.0
- Channel: webchat (primary), also configured for Telegram
- Compaction Config:
"compaction": {
"mode": "safeguard"
}
Steps to Reproduce
- Start a new session (via webchat or Telegram)
- Have a conversation spanning multiple turns
- Wait for automatic "Reduce Context" compaction to trigger (appears to run periodically)
- Observe that the session transcript file is deleted while session is still active
- Attempt to continue conversation - agent fails with ENOENT errors when trying to read session history
- Session becomes unresponsive; gateway restart required
Expected Behavior
- Compaction should only process sessions that are
completed or aborted, never sessions in processing or idle state
- Active sessions should never have their transcript files deleted
- The
safeguard mode should provide strong protection against this
Observed Behavior
- Session transcript file deleted 45 seconds after session creation
- Session registry still listed the session as active
- Log errors:
ENOENT: no such file or directory, access '/Users/cdi/.openclaw/workspace/<session-id>.jsonl'
- Session becomes corrupted and unusable
- Gateway restart required to recover
Log Evidence
2026-02-13T10:33:55 - Session 2d204cc2-e0b6-431a-9ec2-ace99d6b0e53 created
2026-02-13T10:33:59 - First run completed successfully
2026-02-13T10:34:27 - Second run started
2026-02-13T10:34:38 - sessions_list tool executed successfully
2026-02-13T10:34:40.457 - ERROR: read failed: ENOENT: no such file or directory, access '/Users/cdi/.openclaw/workspace/2d204cc2-e0b6-431a-9ec2-ace99d6b0e53.jsonl'
2026-02-13T10:34:45 - Gateway restart triggered
# Compaction runs logged just before session creation:
2026-02-13T10:32:27 - embedded run compaction start: runId=2d78a865...
2026-02-13T10:33:08 - embedded run compaction start: runId=7a35987b...
2026-02-13T10:33:24 - embedded run compaction start: runId=f7f1136d...
Root Cause
The compaction logic does not adequately check session state or age before deleting transcript files. Despite being in safeguard mode, the process deleted a session that was:
- Less than 60 seconds old
- In
idle state (between runs)
- Still registered and used by the webchat channel
The compaction likely incorrectly classified the session as "expired" due to a bug in age calculation or state checking.
Impact
- High severity: complete loss of conversation history within affected sessions
- Session corruption requires manual intervention (gateway restart)
- User experience: agent appears to stop responding with no clear error
- Potential data loss if important context was in the transcript
Proposed Fix
- Add minimum age threshold: Never compact sessions younger than 10 minutes (configurable)
- Check session state explicitly: Only compact sessions with state
completed or aborted, exclude processing and idle
- Add file lock/check: Verify transcript file is not currently in use before deletion
- Add safety logging: Log warning if attempting to delete a session that appears active
- Consider
compaction.mode implementations:
safe: Only compact completed/aborted sessions older than threshold
safeguard: Current behavior appears broken; review implementation
disabled: No automatic compaction (manual cleanup only)
Workaround
As an immediate measure, users can disable compaction:
openclaw config.patch agents.defaults.compaction.mode disabled
openclaw gateway restart
alias: GitHub-Issue-Session-Compaction-Bug
created: 2026-02-13T21:31+10:00
status: submitted
tags: [openclaw, bug-report, github, session-compaction]
GitHub Issue: Session Context Compaction Bug
Status: submitted
Created: 2026-02-13 21:31 AEST
Target: https://github.com/openclaw/openclaw/issues
Description
During an active session, the "Reduce Context" compaction process deleted the session transcript file (
*.jsonl) while the session was still alive, causing session corruption and complete loss of conversation history. The session remained registered in the system but became unusable because the transcript file was missing.System Details
safeguard(from openclaw.json)Steps to Reproduce
Expected Behavior
completedoraborted, never sessions inprocessingoridlestatesafeguardmode should provide strong protection against thisObserved Behavior
ENOENT: no such file or directory, access '/Users/cdi/.openclaw/workspace/<session-id>.jsonl'Log Evidence
Root Cause
The compaction logic does not adequately check session state or age before deleting transcript files. Despite being in
safeguardmode, the process deleted a session that was:idlestate (between runs)The compaction likely incorrectly classified the session as "expired" due to a bug in age calculation or state checking.
Impact
Proposed Fix
completedoraborted, excludeprocessingandidlecompaction.modeimplementations:safe: Only compact completed/aborted sessions older than thresholdsafeguard: Current behavior appears broken; review implementationdisabled: No automatic compaction (manual cleanup only)Workaround
As an immediate measure, users can disable compaction: