Skip to content

fix(claude-code-memory-plugin): avoid persisting compressor sessions - #5697

Open
anhtahaylove wants to merge 1 commit into
volcengine:mainfrom
anhtahaylove:fix/claude-code-compressor-no-session-persistence
Open

anhtahaylove wants to merge 1 commit into
volcengine:mainfrom
anhtahaylove:fix/claude-code-compressor-no-session-persistence

Conversation

@anhtahaylove

Copy link
Copy Markdown

Description

The Claude Code memory plugin can compress recalled context locally with claude -p. That one-shot compressor child is internal utility work, but Claude Code persists print-mode sessions by default. Each local compression can therefore leave a resumable transcript in the user's Claude Code project history, beginning with “You are a memory relevance compressor utility”.

This PR adds --no-session-persistence to the compressor's Claude Code invocation. The rest of the existing isolation stays unchanged: OpenViking hooks are disabled in the child environment, and MCP servers are emptied with --strict-mcp-config plus an empty --mcp-config.

Behavior:

  • Before: every successful local compressor call creates a local .jsonl transcript.
  • After: the call still returns its output on stdout and creates no local transcript.

Human Involvement

  • A human participated in the implementation or review loop
  • This PR was generated entirely by AI agents without human participation in the loop

Related Issue

N/A. Observed while checking Claude Code session history after enabling local recall compression.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test update

Changes Made

  • Add --no-session-persistence to the claude -p arguments in examples/claude-code-memory-plugin/scripts/lib/host-compressor.mjs.
  • Keep the compressor contract unchanged: same model and effort settings, same timeout, and the same fallback behavior when the CLI fails.

Testing

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have tested this on the following platforms:
    • Linux
    • macOS
    • Windows

Validation on Windows with Claude Code 2.1.291 and Node v26.7.0:

  • Real host-compressor reproduction through the exported createHostCompressor() function, using a temporary state directory and the real local Claude Code installation:
    • before this change: returned OK, and transcript count changed 0 -> 1;
    • after this change: returned OK, and transcript count stayed 1 -> 1.
  • npm test in examples/claude-code-memory-plugin: 5/5 passed.
  • node --check examples/claude-code-memory-plugin/scripts/lib/host-compressor.mjs: passed.
  • I also ran scripts/*.test.mjs plus scripts/lib/*.test.mjs in this environment. auto-capture.test.mjs produces the same 6 failures repeatedly with and without this one-file change, so those failures are not introduced here. The same broader run also has 4 marketplace/package failures in my sparse checkout before and after this change; this PR does not touch those files.

Checklist

  • My code follows the project's coding style
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

Additional Notes

--no-session-persistence is available in Claude Code 2.x releases from 2.1.0 onward. I checked published npm packages: it is absent from 2.0.30 and present in 2.1.0, 2.1.30, 2.1.50, 2.1.72, and the locally installed 2.1.291. The existing compressor already relies on --effort, which was absent from 2.1.30 and present from 2.1.50, so this flag does not raise the plugin's effective Claude Code requirement.

No new automated test is added because this is a single CLI argument whose observable effect depends on the external Claude Code persistence implementation. Mocking the argument list would only test field forwarding; the reproduction above checks the actual filesystem side effect.

Run the one-shot recall compressor with --no-session-persistence so successful local compression does not leave a resumable Claude Code transcript.

This branch has not been deployed

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

Labels

agent-plugins Agent harness and plugin integrations

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

2 participants