Problem
After auto-compaction, the agent wakes up with only a (often thin) summary and recent messages. The pre-compaction memoryFlush successfully writes state to disk files, but nothing triggers the agent to read those files back after compaction completes.
This creates an amnesia gap: the agent responds to follow-up messages without context of what it was just working on, despite that context existing in memory files.
Current Behavior
- Session nears context limit
memoryFlush triggers → agent writes to memory/active_work.json, daily notes, etc. ✅
- Compaction runs → older messages summarized
- User sends follow-up message
- Agent responds without reading memory files ❌
- User experiences amnesia/context loss
Proposed Solution
Add a compaction.postCompactionPrompt config option (parallel to memoryFlush):
{
"compaction": {
"memoryFlush": { ... },
"postCompaction": {
"enabled": true,
"prompt": "Context was just compacted. Read memory/active_work.json and memory/YYYY-MM-DD.md to restore state before responding to any user messages.",
"systemPrompt": "You were just compacted. Restore context from memory files."
}
}
}
When compaction completes, Clawdbot would inject this prompt as the next turn (similar to how memoryFlush injects a pre-compaction turn). The agent reads its files, restores context, then handles the pending user message.
Workaround
Currently working around this by adding detection rules to AGENTS.md ("if summary seems thin or message seems like follow-up, read memory files first"). This is fragile and relies on the agent recognizing it was compacted.
Impact
This would close the loop on anti-compaction measures:
- Before: memoryFlush writes state ✅
- After: postCompaction reads state ✅
Would significantly improve continuity for long-running sessions.
Discussed with @joetomasone on 2026-02-03.
Problem
After auto-compaction, the agent wakes up with only a (often thin) summary and recent messages. The pre-compaction
memoryFlushsuccessfully writes state to disk files, but nothing triggers the agent to read those files back after compaction completes.This creates an amnesia gap: the agent responds to follow-up messages without context of what it was just working on, despite that context existing in memory files.
Current Behavior
memoryFlushtriggers → agent writes tomemory/active_work.json, daily notes, etc. ✅Proposed Solution
Add a
compaction.postCompactionPromptconfig option (parallel tomemoryFlush):{ "compaction": { "memoryFlush": { ... }, "postCompaction": { "enabled": true, "prompt": "Context was just compacted. Read memory/active_work.json and memory/YYYY-MM-DD.md to restore state before responding to any user messages.", "systemPrompt": "You were just compacted. Restore context from memory files." } } }When compaction completes, Clawdbot would inject this prompt as the next turn (similar to how memoryFlush injects a pre-compaction turn). The agent reads its files, restores context, then handles the pending user message.
Workaround
Currently working around this by adding detection rules to AGENTS.md ("if summary seems thin or message seems like follow-up, read memory files first"). This is fragile and relies on the agent recognizing it was compacted.
Impact
This would close the loop on anti-compaction measures:
Would significantly improve continuity for long-running sessions.
Discussed with @joetomasone on 2026-02-03.