Memory digest: option to omit (why: …) from injected instructions
Current behavior
On v0.1.4823, digestOf in internal/memory/digest.go (around L64–67) appends (why: …) to every entry that has a stored rationale, and that length counts against the digest budget. The only way to drop the suffix today is to clear the entry's why, which also deletes the rationale from the Memory library.
In one setup with about 35 active memories, the rationale suffixes make up roughly 38% of the injected memory section, about 1.7k tokens loaded at the start of every session.
Requested behavior
An option to omit the (why: …) suffix from the injected digest while keeping why in the stored entries, so it can still be reviewed in the Memory tab. Since the suffix counts against the budget, omitting it would also leave room for more entries.
Acceptance check
With the option on, the memory section of the generated CLAUDE.md / AGENTS.md contains no (why: suffixes, the stored entries still show their rationale in the Memory tab, and turning the option off restores the current output.
Per-project scoping of the digest is tracked in #7653.
Fix branch: https://github.com/qq01-hub/magpie/tree/fix/memory-digest-omit-why (d7c663182)
Compare: https://github.com/yetone/magpie/compare/main...qq01-hub:magpie:fix/memory-digest-omit-why
Changes:
internal/memory(memory.go,store.go,digest.go): persistdigestNoWhyinmeta.json, apply it inrenderbefore counting line lengths against the digest budget (so omitting(why: ...)frees budget room for more entries), keep every memory's storedWhyuntouched, and addDigestOmitWhy/SetDigestOmitWhy.internal/library/instructions.go: extractsyncPublishedMemoryand addSetMemoryDigestOmitWhyso toggling the option immediately updates ticked agents'CLAUDE.md/AGENTS.md.internal/gui/memory.go,internal/gui/assets/plugins/library/client.js,internal/gui/assets/plugins/library/i18n.js: exposedigestOmitWhyinGET /api/memory, accept{"omitWhy": true|false}onPOST /api/memory/digest(keeping{"on": ...}compatible), add the "Include reasons in summary" toggle below "In the agents' instructions" when digest injection is on, and add translations forzh,zh-TW,ja, andde.- Tests:
TestDigestOmitWhy(internal/memory/digest_test.go),TestMemoryDigestOmitWhyInInstructions(internal/library/memory_digest_test.go),TestMemoryDigestOmitWhyRoute(internal/gui/memory_test.go), plus mock route update ininternal/gui/tests/library-memory.test.cjs.
Verification (Windows 11 amd64, Go 1.26.8, Node):
go test -count=1 ./internal/memory(54/54),go test -count=5 ./internal/memory -run 'TestDigest'(20/20),go test -count=5 ./internal/library -run 'TestMemoryDigest'(10/10),go test -count=5 ./internal/gui -run 'TestMemory'(15/15) all passed.node --test internal/gui/tests/i18n-keys.test.cjs internal/gui/tests/i18n-en-no-cjk.test.cjs(8/8) andnode --checkon edited JS files passed. (Playwright browser testlibrary-memory.test.cjswas not run locally.)go vetpassed on Windows (./internal/memory ./internal/library ./internal/gui), Linux (-tags noguion all 3), and macOS (-tags noguion./internal/memory ./internal/library).
@laweit-lxy this is in v0.1.4845 (88222ca34), from @qq01-hub's branch, thanks to both!
Library → Memory → Advanced (below the Memory card, shown while the summary is in the instructions) has Include reasons in summary. Turn it off and the summary written into your agents' instructions leaves out each memory's (why: …), so the room goes to more memories; the why stays in the memory itself. It's on by default, so nobody's summary changes unless they turn it off.
Leaving this open until you've tried it.
Thanks for adding this! I tested Include reasons in summary on Windows with Magpie v0.1.4866.
Turning it off immediately updated both Claude’s CLAUDE.md and Codex’s AGENTS.md. Each file lost exactly 41 (why: …) suffixes and shrank by 5,290 bytes. Everything else was byte-for-byte unchanged.
Turning it back on restored both files byte-for-byte to their original contents. I checked the files on disk, so the switch works as expected for me. Feel free to close the issue.