Skip to content

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

Open
phenomenoner wants to merge 1 commit intoopenclaw:mainfrom
phenomenoner:feat/manual-compact-memory-flush
Open

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

Conversation

@phenomenoner
Copy link

@phenomenoner phenomenoner commented Feb 11, 2026

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
TWFBusiness added a commit to TWFBusiness/openclaw-tw that referenced this pull request Feb 11, 2026
- openclaw#14019: prevent cron jobs from skipping execution (nextRunAtMs regression)
- openclaw#13931: drain active agent turns before gateway restart
- openclaw#14023: filter skills watcher file types to prevent FD exhaustion
- openclaw#13983: use requested agentId for isolated cron job auth resolution
- openclaw#13956: fix Grok web search returning empty content (xAI Responses API)
- openclaw#14018: auto-remind AI to check workspace context files on session reset
- openclaw#13960: preserve structured config validation errors in UI
- openclaw#13951: improve provider error logging in gateway logs
- openclaw#14021: optional memory flush before manual /compact command

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@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
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

Comments