Skip to content

/reload changes the stable snapshot system prompt when memory is unchanged #37

Description

@CrazyCoder

What happened?

pi-memory 0.4.2 changes the model-visible system prompt after every Pi /reload, even when the memory files are unchanged. This invalidates provider prompt-prefix caches for the remaining conversation history.

The stable snapshot header includes a second-level capture timestamp:

Before: Snapshot session_start at 2026-08-28 09:20:32.
After:  Snapshot session_start at 2026-08-28 09:21:08.

Pi recreates extensions during /reload and emits session_start with reason: "reload". The handler calls refreshMemorySnapshot("session_start"). before_agent_start then injects snapshotTakenAt into the system prompt.

This defeats the byte-stability goal introduced for #12. The reported 299k-token OpenAI Codex session then had a full cache miss.

Steps to reproduce

  1. Use the default PI_MEMORY_SNAPSHOT=stable mode with non-empty memory.
  2. Enable Pi's showCacheMissNotices setting.
  3. Start a long session and warm the prompt cache.
  4. Run /reload without changing memory or configuration.
  5. Send another prompt.
  6. Compare the system prompt or provider cache-read usage before and after reload.

Expected behavior

A no-change /reload rebuilds the same memory system-prompt bytes. The provider can reuse the existing prompt prefix.

Actual behavior

The capture timestamp changes. The provider cannot match the conversation prefix after that system-prompt token.

Suggested fix

Do not include snapshotTakenAt in the model-visible snapshot caveat. Keep snapshotTakenOnDate for day-rollover detection and keep the stable reason text:

Snapshot session_start. Use memory_read / memory_search for the authoritative latest state; recent writes may also be visible in tool-call history.

A regression test can set two different system times. It emits session_start for startup and reload. The test then compares both before_agent_start system prompts.

Environment

Pi: 0.84.3
pi-memory: 0.4.2
Snapshot mode: stable
Provider: openai-codex
Model: gpt-5.6-sol
Operating system: Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions