r/opencode • • 25d ago

How are you handling cross-session memory in large repos once AGENTS.md gets too bloated?

I use coding agents daily on a ~120k LOC repository. For code search, ripgrep / agentic search works great for finding what is currently in the codebase.

My real pain point is episodic and architectural memory across sessions: remembering why we rejected a specific library three weeks ago, subtle business invariants that aren't obvious in the code, or stopping the agent from repeating the same debugging dead-ends in a new chat.

Right now:

  1. If I dump everything into AGENTS.md / CLAUDE.md, it quickly turns into a bloated wall of text that eats up context tokens and the agent starts ignoring half of it.
  2. I tried a couple of MCP memory servers, but most of them just do naive vector RAG—after a few weeks they inject stale or contradictory memories from old refactors and actually make the agent dumber.

For those working on medium/large projects over several months:

  • Are you using any local MCP memory tool that actually handles deduplication and superseding old decisions when architecture changes?
  • Or are you still curating markdown files manually because existing memory tools pollute the context too much?
6 Upvotes

14 comments sorted by

5

u/trashbytes 25d ago edited 25d ago

You could try splitting it up into parts and reference those in AGENTS.md or CLAUDE.md.

References:

Read docs/libraries.md for decisions on approved or rejected libraries and the reasoning behind it before doing anything related to that.

Read docs/whatever.md for whatever.

Keep the docs updated.

Maybe try that, I'm using this approach on Hermes quite successfully. Even skills are made like this, as there's a soft character limit.

This way the agent will only read those parts when it actually has to as part of the task, not always by default.

1

u/trashbytes 25d ago

And yes, I hate using memory providers. They're a black box full of outdated or irrelevant data. I haven't found it useful at all. Quite the contrary actually.

If you want a best friend use memory. If you want a productive agent keep the knowledge in docs scoped to your projects and have memory only contain some basic global guidelines or pointers.

5

u/Primary-Meal-2264 25d ago

If you have a bloated AGENTS.md, you’re probably not using it correctly. It should contain only the core principles of your project, rather than serve as a journal of what happened. Extract important decisions into a separate ADR management system instead.

2

u/ThankGodImBipolar 25d ago

I've found Karpathy's LLM Wiki to be a good starting point for memory/LLM notes. Write dev logs that summarize meaningful sessions, and dump them in the LLM wiki. You can improve your ability to index/search the wiki as it gets unruly.

1

u/brycehamrick 25d ago

Hindsight is best for this, but not through the mcp use a plugin. The official plugin has some limitations I use one I wrote that adds several improvements. Hindsight configuration matters as well.

But also your workflow matters. I turn most repeatable processes into an agent, a skill or multiple hierarchical skills and decisions are often embedded in skill/agent files.

1

u/PanPanForReal 25d ago

I use graphify + agentmemory + obsidian

1

u/lincolnthalles 25d ago

Only codegraph in the harness plus ADRs in the repo, with the codebase-design skill.

Enforce it via AGENTS.md with something like this: durable _why_ goes todocs/adr/only when hard to reverse, surprising, and traded off. This triple gate overrules any skill suggestion to record more.

AGENTS.md must remain a router, never a dumpster. The only thing worse than filling the context with data irrelevant to the task is filling it with contradictory or stale data.

Remember that models think everything is important and love to write walls of text, which only makes them dumber over time, so you must give them a followable procedure with focus and hard bans before delegating all the upkeep to them.

1

u/gkbrk 25d ago

I use something similar to Uniichat (from Victor Taelin) as a custom OpenCode plugin. It keeps message summaries as a binary tree, older stuff gets more compressed, recent stuff is less compressed, and context is managed automatically.

When the agents wants more detail about something, it can zoom into older messages to expand them and make them less summarized. This can go all the way to raw messages that are not summarized.

If you don't want to, you don't even need to start new sessions. You can keep one chat going essentially forever.

1

u/for4f 25d ago

man i hit this exact wall a few months back. what finally worked for me was keeping AGENTS.md tiny, like it just points at stuff instead of holding everything. the actual why-we-did-it decisions live in small skill files per workflow, and those only load when relevant so they don't eat context the whole session. tried one of those mcp memory servers too and yeah, same experience, after a few weeks it started surfacing calls from refactors i'd already undone. curating by hand is honestly less work than cleaning up after the memory server lol

1

u/letuslisp 25d ago

Simple - as other pointed it out. Write in your prompt:

My AGENTS.md is very bloated and not token-efficient. Please make it drastically token-efficient by exporting parts which have not to be read for every prompt to other .md files and referring to them from my AGENTS.md.
Please ask me if you want to make sentences more dense for token-efficiency. But I would prefer you to distribute it over several md files which are only read when needed for the task.

1

u/ichisay 25d ago

Mempalace (mcp y plugin), curion y session state manager.

1

u/RedditAPIBlackout24 19d ago

code search and decision history are different jobs. i'd keep superseded decisions searchable but label what replaced them, so old reasoning doesn't become today's instruction. how do u track that now? client disclosure: i'm helping promote everos, so not an independent recommendation.