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
- Use the default
PI_MEMORY_SNAPSHOT=stable mode with non-empty memory.
- Enable Pi's
showCacheMissNotices setting.
- Start a long session and warm the prompt cache.
- Run
/reload without changing memory or configuration.
- Send another prompt.
- 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
What happened?
pi-memory0.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:
Pi recreates extensions during
/reloadand emitssession_startwithreason: "reload". The handler callsrefreshMemorySnapshot("session_start").before_agent_startthen injectssnapshotTakenAtinto 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
PI_MEMORY_SNAPSHOT=stablemode with non-empty memory.showCacheMissNoticessetting./reloadwithout changing memory or configuration.Expected behavior
A no-change
/reloadrebuilds 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
snapshotTakenAtin the model-visible snapshot caveat. KeepsnapshotTakenOnDatefor day-rollover detection and keep the stable reason text:A regression test can set two different system times. It emits
session_startfor startup and reload. The test then compares bothbefore_agent_startsystem prompts.Environment