I’ve been working through this while rolling out agentic coding workflows across a fairly large engineering organization. The rule that has held up best is: don’t try to preserve everything Codex learned. Preserve only what should still be true for the next engineer.
Raw session summaries feel useful at first, but after a few weeks they become a second, less reliable codebase. They retain dead ends, assumptions, and details whose source has moved. More memory can make the next run worse.
For a mature multi-service system, I use four layers:
- Root
AGENTS.md: only stable cross-repo rules. Build and test commands, architectural invariants, safety boundaries, and the definition of done.
- Service-local
AGENTS.md files: ownership, public interfaces, schema and migration rules, local commands, and the few non-obvious constraints that repeatedly matter.
- Canonical engineering artifacts: protobuf schemas, ADRs, API contracts, and integration tests. These remain the source of truth.
- A task packet: the issue, acceptance criteria, expected affected services, and required evidence. This is intentionally disposable.
For .NET and gRPC specifically, I would make the protobuf definitions first-class and keep a small producer/consumer map beside them. Before allowing edits, I ask Codex to produce an “impact manifest” containing:
- affected services
- contracts or events that may change
- persistence and migration implications
- tests that prove compatibility
- known facts versus inferences, with a source path for each
A human approves that scope before implementation. In practice, this catches more mistakes than simply giving the model more context.
My usual first instruction is close to this:
Before editing, list the affected services, contracts, persistence layers, and tests. Cite the file path supporting each item. Separate known facts from inferences. Stop if a public contract or migration policy is unclear.
I use a similarly strict closeout. Instead of asking for a general session summary, I ask:
Which verified facts from this task would help any future maintainer? Cite the source for each one. Propose the smallest update to the nearest AGENTS.md or ADR. Do not preserve task-specific history.
The proposed update still gets human review.
Things that have not worked well for me:
- a giant root
AGENTS.md
- storing raw chat logs as memory
- broad RAG before the system boundaries are clear
- generated architecture maps with no freshness check
- asking every new session to rediscover the whole system
I would not start with a graph database. For dozens of services and indirect dependencies, a graph can become a useful derived index, but it should always point back to source files and commits. It should not become another source of truth.
The metric I care about is not “did Codex remember the codebase?” It is “can Codex produce a correct, evidence-backed impact plan before it edits anything?” If it can, the context system is working. If it cannot, the repository is not agent-readable yet.
Are your protobuf definitions and consumer compatibility rules centralized anywhere today? For the stack you described, that might be the highest-leverage place to start.