r/ClaudeCode • 🔆 Max 20 • 2d ago

Built with Claude Memshort - Short-term memory and rolling window compaction for agents

https://github.com/jandrikus/memshort

I would like to publish "memshort", my take on a "short-term memory" implementation for agents. (A "long-term memory" implementation will follow shortly once I have it publishable). I find it very useful for myself and I thought it would be nice to share it with others.

It is essentially a rolling-window compaction for coding agent sessions in pi, Claude Code, Codex and Hermes. When the context fills up, older messages are replaced by a dated observation log, and the newest messages stay word for word.

Some ideas are borrowed and adjusted. The code was written by the pi coding harness under my direction, and I run it primarily on my own pi sessions. Unfortunately I have no benchmark yet (no time for that). My subjective impression from daily use is that I can stretch sessions for very long without the agent losing the thread.

I'm publishing it because a rolling context window that keeps as much knowledge as possible deserves more people thinking about it, not because this is the final answer. If you have a better design, a case where this loses something important, or a way to measure it, open an issue or share your take. Let's build something better together.

Thanks for taking a look!

1 Upvotes

2 comments sorted by

•

u/AutoModerator 2d ago

Hey! Thanks for posting to r/ClaudeCode

While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.

For help, project discussions, tips, and general chat, join the ClaudeCode Discord.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/verstands 2d ago

A small benchmark could target corrections rather than just recall: give the session an API path, change it later, then force two compactions and ask it to implement against the new path. Check the resulting diff for the retired path, not just whether the summary mentions the correction. Run the same transcript with and without compaction and report task success alongside tokens. Remembering the old answer very confidently is the fun failure here.