Repository navigation
fix: inject memory as a system prompt section instead of replacing the prompt - #52
felipeadeildo wants to merge 1 commit into
Conversation
…e prompt Signed-off-by: Adeildo <adeildo@ranqia.com>
|
One more case for this PR, seen on Pi 1.5.2 with pi-memory 0.4.2. With the replacement
Repro: the pstack-claude Pi extension writes a
The session transcript records the section in the first case too. Only the provider request loses it. Moving pi-memory to the end of |
Fixes #50. Covers the part of #37 that
mainstill has.before_agent_startnow writes the memory block toevent.systemPromptOptions.sections.memorywhen pi exposes sections, instead of returning a replacementsystemPrompt. When the block changes, pi appends it as a system message and keeps the cached prefix. Older pi versions, which have no sections, andper-turnmode keep the replacement, with the same bytes as before.mainalready drops the snapshot timestamp, so a/reloadwith unchanged memory keeps the cache. The block still changes when anything was written since the last snapshot, a daily entry for example. With a replacement prompt, that rewrites the whole prompt.Measured
Pi 1.2.0,
claude-haiku-5-5, synthetic memory inPI_MEMORY_DIR. Twopi -pruns on one session, with a daily-log line appended between them. Usage of the second run's request:mainOn 0.4.2 and
main, only the tools stay cached. With the section, the second run reads the whole previous prompt and writes the new memory block.Tests
main:npm test197 pass,npm run buildandnpm run lintclean.test/unit.test.ts: the block goes to the section and nothing is returned, empty memory removes the section,per-turnstill replaces the prompt. The first two failed before the change.npm test200 pass,npm run buildandnpm run lintclean.No change to on-disk memory formats or qmd behavior.