Skip to content

feat(compaction): optional memory flush before manual /compact#14021

Closed
phenomenoner wants to merge 1 commit into
openclaw:mainfrom
phenomenoner:feat/manual-compact-memory-flush
Closed

feat(compaction): optional memory flush before manual /compact#14021
phenomenoner wants to merge 1 commit into
openclaw:mainfrom
phenomenoner:feat/manual-compact-memory-flush

Conversation

@phenomenoner

@phenomenoner phenomenoner commented Feb 11, 2026

Copy link
Copy Markdown

Adds an optional pre-compaction memory flush turn before manual /compact.\n\n- New config: agents.defaults.compaction.memoryFlush.onManualCompact (default: false)\n- When enabled, /compact runs a memory flush agent turn first, then compacts\n- Skips flush when workspace is read-only (sandbox workspaceAccess != rw) or when using CLI providers\n- Fail-open: if the flush run throws, compaction still proceeds\n\nDocs: updated configuration reference (EN + zh-CN).\nTests: added e2e coverage to ensure flush runs before compact when enabled.

Greptile Overview

Greptile Summary

This PR adds an optional pre-compaction memory flush feature for manual /compact commands. When agents.defaults.compaction.memoryFlush.onManualCompact is enabled (default: false), the system runs a memory flush agent turn before compacting the session, allowing the agent to store durable memories to disk. The feature intelligently skips the flush when the workspace is read-only or when using CLI providers (which don't support tool runs), and follows a fail-open pattern where compaction proceeds even if the flush fails.

Key changes:

  • Added onManualCompact config field to AgentCompactionMemoryFlushConfig with proper TypeScript types and Zod validation
  • Updated commands-compact.ts to conditionally run runEmbeddedPiAgent before compaction
  • Implemented proper guard checks for workspace access (rw only) and CLI provider detection
  • Added comprehensive e2e test coverage verifying flush runs before compact and ordering is correct
  • Updated documentation in both English and Chinese (zh-CN)

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The implementation is well-designed with proper guard rails, fail-open error handling, comprehensive test coverage, and follows existing codebase patterns. All changes are backward-compatible (feature is opt-in with default: false), and the code includes proper checks for edge cases like read-only workspaces and CLI providers.
  • No files require special attention

(2/5) Greptile learns from your feedback when you react with thumbs up/down!

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime labels Feb 11, 2026
@phenomenoner phenomenoner force-pushed the feat/manual-compact-memory-flush branch from 697d48c to 57c54be Compare February 11, 2026 10:18
@phenomenoner phenomenoner force-pushed the feat/manual-compact-memory-flush branch from 57c54be to 632e7f8 Compare February 14, 2026 19:11
@phenomenoner phenomenoner force-pushed the feat/manual-compact-memory-flush branch from 632e7f8 to 5f514ba Compare February 15, 2026 02:38
@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Feb 15, 2026
@phenomenoner phenomenoner force-pushed the feat/manual-compact-memory-flush branch from 5f514ba to 96eba68 Compare February 15, 2026 03:37
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Feb 15, 2026
@phenomenoner phenomenoner force-pushed the feat/manual-compact-memory-flush branch from 96eba68 to 62f8663 Compare February 15, 2026 03:39
@openclaw-barnacle openclaw-barnacle Bot removed scripts Repository scripts agents Agent runtime and tooling labels Feb 15, 2026
@phenomenoner phenomenoner force-pushed the feat/manual-compact-memory-flush branch from 62f8663 to 537ac86 Compare February 15, 2026 04:14
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added stale Marked as stale due to inactivity and removed stale Marked as stale due to inactivity labels Feb 21, 2026
@phenomenoner

Copy link
Copy Markdown
Author

Probably oudated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant