Skip to content

[Feature]: Pre-reset agentic memory flush #4

@kamikariat

Description

@kamikariat

Upstream: openclaw#45608

Summary

Run a silent agentic memory flush before /new, /reset, and the daily reset destroy the session — same mechanism that already runs before compaction.

The asymmetry

  • Compaction → agentic flush (agent curates what to save) ✅
  • /new / /reset → mechanical dump (raw 15 messages, no curation) ❌
  • Daily reset → same mechanical dump, silently, every morning ❌

The daily reset is the default for every user (mode: "daily", atHour: 4). Any context not written to disk before 4 AM is gone.

Proposed solution

Before destroying the session, run a silent agentic turn (reusing runMemoryFlushIfNeeded) that lets the agent write durable notes to memory/YYYY-MM-DD.md or MEMORY.md, then NO_REPLY.

Most infrastructure exists:

  • runMemoryFlushIfNeeded (src/auto-reply/reply/agent-runner-memory.ts:253)
  • before_reset plugin hook (src/plugins/types.ts:541)
  • NO_REPLY suppression
  • Daily memory checkpoint (shouldRunDailyMemoryCheckpoint)

Main work: wire flush into the reset path before session destruction.

Open questions

  1. Blocking vs background flush on /new
  2. Config location: compaction.memoryFlush.onReset vs session.reset.memoryFlush
  3. Daily reset: proactive "bedtime flush" via heartbeat, background flush on next message, or accept daily checkpoint is good enough
  4. Keep session-memory hook alongside (raw audit trail + curated memory)

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions