openclaw - ✅(Solved) Fix Memory flush write sandbox blocks SESSION_HANDOFF.md despite prompt instruction [1 pull requests, 1 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#66612Fetched 2026-04-15 06:25:24
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Participants
Timeline (top)
cross-referenced ×1referenced ×1

Error Message

However, the runtime tool sandbox during flush turns restricts writes to only memory/YYYY-MM-DD.md, blocking the SESSION_HANDOFF.md write with an error like:

Fix Action

Workaround

SESSION_HANDOFF.md gets written in the next normal turn after the flush, but this is fragile — if the session resets immediately after flush, the handoff is lost.

PR fix notes

PR #66765: fix(memory-flush): allow additional write paths beyond daily notes

Description (problem / solution / changelog)

Summary

The memory flush sandbox restricts tool writes to a single path (memory/YYYY-MM-DD.md), but the default flush prompt instructs writing to SESSION_HANDOFF.md as well. This causes the handoff write to fail silently during compaction, breaking session continuity.

Changes

  • extensions/memory-core/src/flush-plan.ts: buildMemoryFlushPlan() now detects SESSION_HANDOFF references in the resolved prompt/system prompt and returns additionalWritePaths
  • src/agents/pi-tools.read.ts: wrapToolMemoryFlushAppendOnlyWrite() accepts an array of additional paths with full overwrite (not append-only) access via writeFileWithinRoot
  • src/agents/pi-tools.ts: Threads memoryFlushAdditionalWritePaths through createOpenClawCodingTools
  • src/agents/pi-embedded-runner/run/params.ts: Adds memoryFlushAdditionalWritePaths to RunEmbeddedPiAgentParams
  • src/plugins/memory-state.ts: MemoryFlushPlan type gains additionalWritePaths: string[]

Design Decisions

  • Additional paths use full overwrite (writeFileWithinRoot) rather than append, since SESSION_HANDOFF.md is meant to be replaced each flush cycle
  • Detection is prompt-based (checks for SESSION_HANDOFF in resolved prompt text), keeping it backward-compatible — existing configs without the handoff instruction see no behavior change
  • The approach is generic: additionalWritePaths can support future multi-file flush scenarios beyond just SESSION_HANDOFF

Testing

Tested against a live OpenClaw deployment with memoryFlush.enabled: true and softThresholdTokens: 8000. Before fix: SESSION_HANDOFF.md write fails with sandbox error. After fix: both memory/YYYY-MM-DD.md (append) and SESSION_HANDOFF.md (overwrite) succeed during flush.

Fixes #66612

Changed files

  • extensions/memory-core/src/flush-plan.ts (modified, +13/-2)
  • src/agents/pi-embedded-runner/run/params.ts (modified, +2/-0)
  • src/agents/pi-tools.read.ts (modified, +44/-20)
  • src/agents/pi-tools.ts (modified, +6/-0)
  • src/plugins/memory-state.ts (modified, +1/-0)
RAW_BUFFERClick to expand / collapse

Bug

The pre-compaction memory flush prompt explicitly instructs the agent to update SESSION_HANDOFF.md:

ALSO: Update SESSION_HANDOFF.md with current session state (what was being worked on, background processes, pending tasks, key decisions, file paths). This is critical for session continuity — the next session reads this first. Overwrite the entire file with fresh content.

However, the runtime tool sandbox during flush turns restricts writes to only memory/YYYY-MM-DD.md, blocking the SESSION_HANDOFF.md write with an error like:

Memory flush writes are restricted to memory/YYYY-MM-DD.md; use that path only.

Expected Behavior

The flush write sandbox should allow writes to both:

  • memory/YYYY-MM-DD.md (daily notes)
  • SESSION_HANDOFF.md (session continuity file)

...or any path explicitly mentioned in the user-configured memoryFlush.prompt.

Reproduction

  1. Configure agents.defaults.compaction.memoryFlush.prompt to include SESSION_HANDOFF.md instruction (this is the default/recommended setup)
  2. Let a session reach the soft compaction threshold
  3. Observe that the flush turn writes to memory/YYYY-MM-DD.md successfully but fails to write SESSION_HANDOFF.md

Workaround

SESSION_HANDOFF.md gets written in the next normal turn after the flush, but this is fragile — if the session resets immediately after flush, the handoff is lost.

Environment

  • OpenClaw: latest (as of 2026-04-14)
  • Config: memoryFlush.enabled: true, softThresholdTokens: 8000

extent analysis

TL;DR

The flush write sandbox needs to be updated to allow writes to SESSION_HANDOFF.md in addition to memory/YYYY-MM-DD.md.

Guidance

  • Review the memoryFlush.prompt configuration to ensure it includes the instruction to update SESSION_HANDOFF.md.
  • Verify that the runtime tool sandbox is correctly interpreting the memoryFlush.prompt configuration and allowing writes to the specified paths.
  • Consider modifying the flush write sandbox to allow writes to any path explicitly mentioned in the memoryFlush.prompt configuration.
  • Test the updated configuration to ensure that both memory/YYYY-MM-DD.md and SESSION_HANDOFF.md are being written correctly during the flush turn.

Example

No code snippet is provided as the issue does not imply a specific code change, but rather a configuration or sandbox update.

Notes

The current workaround of writing SESSION_HANDOFF.md in the next normal turn after the flush is fragile and may not be reliable. A more robust solution is needed to ensure session continuity.

Recommendation

Apply a workaround by modifying the flush write sandbox to allow writes to SESSION_HANDOFF.md, as this is a critical file for session continuity and the current restriction is causing errors.

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 - ✅(Solved) Fix Memory flush write sandbox blocks SESSION_HANDOFF.md despite prompt instruction [1 pull requests, 1 participants]