If you give a team of AI agents access to a single shared knowledge base, each agent's contributions will eventually degrade the quality of every other agent's context. This isn't a hypothetical failure mode — it's something we observed directly when building Grain.
How memory pollution happens
Consider a system where a coding agent and a marketing agent share the same memory store. The coding agent writes notes about a recurring null pointer exception in the API layer. The marketing agent writes notes about which subject lines are performing well in outbound campaigns. Over time, the coding agent's retrieval results start including campaign subject lines. The marketing agent's context starts including stack traces.
Neither piece of information is useful to the other agent. But if they're sharing a vector store or a knowledge graph, semantic search will surface them anyway — because the queries are close enough in embedding space to pull in adjacent but irrelevant results.
Domains as the unit of sharing
Our solution was to organize memory around functional domains rather than individual agents or a global pool. Agents that work on related problems — multiple coding agents, for example — share a domain-scoped memory. Agents in different functional areas have completely separate memory spaces.
Within a domain, sharing is valuable: a coder who figures out why a particular service is slow should be able to pass that context to the next coder who touches the same service. Across domains, sharing creates noise.
Continuity across time
Agent memory isn't just about sharing context between agents in the same moment — it's about preserving useful context across time. An agent that starts a task fresh, with no memory of what previous agents learned, will repeat investigations that have already been done.
Domain-scoped memory gives agents institutional knowledge: the accumulated learnings of every agent that has worked in that domain before. A coding agent joining a codebase can see that previous agents already identified a particular pattern as error-prone. A support agent can see that a particular issue has a known workaround.
Integration with external knowledge sources
We found that structured external knowledge bases — documentation, codebase notes, architectural decisions — are more valuable as agent context than unstructured memory when they're kept up to date. The challenge is keeping them current.
Our approach was to give agents both the ability to read from and write to these knowledge bases as part of their task execution. An agent that discovers something worth knowing should document it immediately, not rely on a future process to extract and store that knowledge separately.
