Agent记忆越多,知道越少:模式约束是关键
The more your agent remembers, the less it knows.
The more your agent remembers, the less it knows.
This sounds counterintuitive, but it is actually a direct result of how agent memory is built today.
Most agent memory systems optimize for recall. The harder problem is what to forget, or more precisely, what to never store in the first place.
The default agent memory pipeline hands an LLM raw text and asks it to extract entities and relationships. The model decides the types, the labels, and the attributes, all on its own.
This typically gives a knowledge graph that behaves like an expensive vector store. Entity types collapse into generic labels. Relationships flatten into a single "RELATES_TO."
The graph has the data, but no query can reach it with precision.
This is not a retrieval problem but rather a structure problem. And the fix is the same pattern that already works everywhere else in the AI stack, i.e., constrain the output space before generation, not after.
> Entities define what the agent is allowed to remember. Pydantic models with typed fields and descriptive docstrings replace the LLM's guesswork with domain vocabulary it was never trained on.
> Edges define how things connect. Source/target constraints on relationship types mean the graph can only form valid connections. If your schema has no edge connecting Project to Competitor, that relationship cannot exist in memory.
> Temporal resolution handles what was true versus what is true. Fact resolution invalidates outdated edges while preserving history, so the graph never silently serves a stale state.
The schema guides extraction at two points in the pipeline (entity extraction and fact extraction) while resolution and temporal processing run automatically downstream.
You define what to look for. The system handles deduplication, contradiction detection, and time-windowing without additional configuration.
A useful constraint is to have just 10 entity types, 10 edge types, and 10 fields per type.
That forces you to model the 80% that matters rather than attempting completeness. Start with 3-4 of each and expand only when retrieval fails.
Graphiti does all of this as a fully open-source (with 29k stars) temporal knowledge graph library.
It implements Pydantic-based ontology definition, schema-guided extraction, entity resolution, fact resolution, and temporal windowing that I described above.
Graphiti Repo: http://github.com/getzep/graphiti
(don't forget to star 🌟)
Agent memory without schema discipline is storage without structure. The schema is what turns a pile of facts into a queryable model of your domain.
So if you are building agent memory with any kind of domain specificity, schemas are a must. My co-founder covered this topic in more depth in an article.
Read it below.
更进一步:量化金融体系
看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力