Skip to content

[Bug] Memory flush does not write daily memory when compaction triggers #79022

Description

@bizzle12368239

Bug Description

memoryFlush.enabled: true. Compaction fires reliably at the token threshold, but the configured flush turn does not write any content to memory/YYYY-MM-DD.md. Daily memory file remains empty after compaction.

This occurs whether or not memoryFlush.prompt is explicitly configured — the issue reproduces with the built-in default prompt and with an explicitly configured prompt.

Environment

  • Channel: Telegram
  • OpenClaw: 2026.4.15

Configuration (tried both ways)

Without explicit prompt (using built-in default):

"compaction": {
  "mode": "safeguard",
  "memoryFlush": {
    "enabled": true,
    "softThresholdTokens": 8000
  }
}

Built-in default prompt: "Write any lasting notes to memory/YYYY-MM-DD.md; reply with the exact silent token NO_REPLY if nothing to store."

With explicit prompt:

"compaction": {
  "mode": "safeguard",
  "keepRecentTokens": 30000,
  "reserveTokensFloor": 30000,
  "maxHistoryShare": 0.8,
  "memoryFlush": {
    "enabled": true,
    "softThresholdTokens": 8000,
    "prompt": "We are nearing a context limit. Summarize our progress today into memory/YYYY-MM-DD.md. If the file already exists, APPEND new content only."
  }
}

Expected flush trigger: 162,000 tokens (safeguard floor 170k − softThreshold 8k).

Steps to Reproduce

  1. Continue a conversation until compaction fires (~170k tokens out of 200k)
  2. Observe: compaction message appears in chat ("🧹 Compacting context (636 messages)...")
  3. Check memory/YYYY-MM-DD.md — no new entry written
  4. Repeat after gateway restart — same result

Compaction fires correctly at the expected threshold. The issue is specifically that the memory-flush turn does not write to disk.

Expected Behavior

When compaction fires, the silent memory-flush turn should write a summary to memory/YYYY-MM-DD.md before the transcript is compacted.

Relevant Log Extract

16:14:00+00:00 <compaction fires — context ~148k tokens, 72% of 200k, 636 messages>
[Compaction message visible in Telegram: "🧹 Compacting context (636 messages) so I can continue without losing history…"]
[memory/YYYY-MM-DD.md — no new entry, file modified timestamp unchanged since earlier]

File modified timestamps confirm no write occurred to daily memory file during compaction. No error messages appear in logs — the flush silently fails.

Additional Context

  • Daily memory writes work correctly when triggered manually (e.g., via heartbeat)
  • The issue is specific to the automatic flush on compaction
  • Workspace is read-write; no workspaceAccess restrictions in effect

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions