{
  "source_file": "0930",
  "source_platform": "Ghost",
  "author": "Avi Chawla / Daily Dose of Data Science",
  "title_listed": "Hands On Agent Memory Is Only As Good As Its Schema",
  "keywords": "",
  "domain": "大模型算法",
  "content_type": "深度技术解析",
  "is_paid_flag": "否",
  "url": "https://www.dailydoseofds.com/p/hands-on-agent-memory-is-only-as-good-as-its-schema/",
  "publish_date": "2026-06-12",
  "corpus_stage": "",
  "notes": "",
  "id": "7c0726acba87",
  "collected_at": "2026-10-02T13:47:09",
  "title": "[Hands-on] Agent memory is only as good as its schema",
  "body_markdown": "[ Skip to main content  ](https://www.dailydoseofds.com/p/hands-on-agent-memory-is-only-as-good-as-its-schema/#sx-main)\n[ ![Daily Dose of Data Science](https://storage.ghost.io/c/3f/df/3fdf6ed2-17ac-4b12-a693-8078bd13e748/content/images/2025/12/dailyds-logo-transparent-1.png) ](https://www.dailydoseofds.com)\n  * [ Newsletter ](https://dailydoseofds.github.io/ai-engg-book/)\n  * [ Archive ](https://www.dailydoseofds.com/archive/)\n  * Guidebooks \n    * [ MCP Guidebook ](https://www.dailydoseofds.com/what-is-mcp/)\n[ Agents Guidebook ](https://drive.google.com/file/d/1Th8mN_IF7Ttc8bI_OLtUuQ7Mjx3aJ6Hi/view)\n[ AI Engineering Guidebook ](https://drive.google.com/file/d/1_s2UaD7tEPECjgC5YMOa1LIOB9HUWFO-/view)\n[ DS Guidebook ](https://drive.google.com/file/d/1ZunUHwkD2Ut0_LrgDTDmlQRQkfT2lkVf/view)\n[ Courses ](https://www.dailydoseofds.com/)\n[ MLOps/LLMOps Course ](https://www.dailydoseofds.com/mlops-crash-course-part-1/)\n[ Reinforcement Learning Course ](https://www.dailydoseofds.com/rl-course-part-1/)\n[ AI Agents Course ](https://www.dailydoseofds.com/ai-agents-crash-course-part-1-with-implementation/)\n[ MCP Course ](https://www.dailydoseofds.com/model-context-protocol-crash-course-part-1/)\n[ RAG Systems Course ](https://www.dailydoseofds.com/a-crash-course-on-building-rag-systems-part-1-with-implementations/)\n  * Courses \n    * [ MLOps/LLMOps Course ](https://www.dailydoseofds.com/mlops-crash-course-part-1/)\n[ Reinforcement Learning Course ](https://www.dailydoseofds.com/rl-course-part-1/)\n[ AI Agents Course ](https://www.dailydoseofds.com/ai-agents-crash-course-part-1-with-implementation/)\n[ MCP Course ](https://www.dailydoseofds.com/model-context-protocol-crash-course-part-1/)\n[ RAG Systems Course ](https://www.dailydoseofds.com/a-crash-course-on-building-rag-systems-part-1-with-implementations/)\n[ LLM and Fine-tuning ](https://www.dailydoseofds.com/bi-encoders-and-cross-encoders-for-sentence-pair-similarity-scoring-part-1/)\n[ Classical ML and Deep Learning ](https://www.dailydoseofds.com/where-did-the-assumptions-of-linear-regression-originate-from/)\n[ Engineering Best Practices ](https://www.dailydoseofds.com/8-fatal-yet-non-obvious-pitfalls-and-cautionary-measures-in-data-science/)\n  *     * [ Newsletter ](https://dailydoseofds.github.io/ai-engg-book/)\n[ Archive ](https://www.dailydoseofds.com/archive/)\nGuidebooks \n      * [ MCP Guidebook ](https://www.dailydoseofds.com/what-is-mcp/)\n      * [ Agents Guidebook ](https://drive.google.com/file/d/1Th8mN_IF7Ttc8bI_OLtUuQ7Mjx3aJ6Hi/view)\n      * [ AI Engineering Guidebook ](https://drive.google.com/file/d/1_s2UaD7tEPECjgC5YMOa1LIOB9HUWFO-/view)\n      * [ DS Guidebook ](https://drive.google.com/file/d/1ZunUHwkD2Ut0_LrgDTDmlQRQkfT2lkVf/view)\n      * [ Courses ](https://www.dailydoseofds.com/)\n      * [ MLOps/LLMOps Course ](https://www.dailydoseofds.com/mlops-crash-course-part-1/)\n      * [ Reinforcement Learning Course ](https://www.dailydoseofds.com/rl-course-part-1/)\n      * [ AI Agents Course ](https://www.dailydoseofds.com/ai-agents-crash-course-part-1-with-implementation/)\n      * [ MCP Course ](https://www.dailydoseofds.com/model-context-protocol-crash-course-part-1/)\n      * [ RAG Systems Course ](https://www.dailydoseofds.com/a-crash-course-on-building-rag-systems-part-1-with-implementations/)\nCourses \n      * [ MLOps/LLMOps Course ](https://www.dailydoseofds.com/mlops-crash-course-part-1/)\n      * [ Reinforcement Learning Course ](https://www.dailydoseofds.com/rl-course-part-1/)\n      * [ AI Agents Course ](https://www.dailydoseofds.com/ai-agents-crash-course-part-1-with-implementation/)\n      * [ MCP Course ](https://www.dailydoseofds.com/model-context-protocol-crash-course-part-1/)\n      * [ RAG Systems Course ](https://www.dailydoseofds.com/a-crash-course-on-building-rag-systems-part-1-with-implementations/)\n      * [ LLM and Fine-tuning ](https://www.dailydoseofds.com/bi-encoders-and-cross-encoders-for-sentence-pair-similarity-scoring-part-1/)\n      * [ Classical ML and Deep Learning ](https://www.dailydoseofds.com/where-did-the-assumptions-of-linear-regression-originate-from/)\n      * [ Engineering Best Practices ](https://www.dailydoseofds.com/8-fatal-yet-non-obvious-pitfalls-and-cautionary-measures-in-data-science/)\n\n\nSign In  [ Get Started ](https://www.dailydoseofds.com/membership)\n/\n  * [ Newsletter ](https://dailydoseofds.github.io/ai-engg-book/)\n  * [ Archive ](https://www.dailydoseofds.com/archive/)\n  * Guidebooks \n    * [ MCP Guidebook ](https://www.dailydoseofds.com/what-is-mcp/)\n    * [ Agents Guidebook ](https://drive.google.com/file/d/1Th8mN_IF7Ttc8bI_OLtUuQ7Mjx3aJ6Hi/view)\n    * [ AI Engineering Guidebook ](https://drive.google.com/file/d/1_s2UaD7tEPECjgC5YMOa1LIOB9HUWFO-/view)\n    * [ DS Guidebook ](https://drive.google.com/file/d/1ZunUHwkD2Ut0_LrgDTDmlQRQkfT2lkVf/view)\n    * [ Courses ](https://www.dailydoseofds.com/)\n    * [ MLOps/LLMOps Course ](https://www.dailydoseofds.com/mlops-crash-course-part-1/)\n    * [ Reinforcement Learning Course ](https://www.dailydoseofds.com/rl-course-part-1/)\n    * [ AI Agents Course ](https://www.dailydoseofds.com/ai-agents-crash-course-part-1-with-implementation/)\n    * [ MCP Course ](https://www.dailydoseofds.com/model-context-protocol-crash-course-part-1/)\n    * [ RAG Systems Course ](https://www.dailydoseofds.com/a-crash-course-on-building-rag-systems-part-1-with-implementations/)\n  * Courses \n    * [ MLOps/LLMOps Course ](https://www.dailydoseofds.com/mlops-crash-course-part-1/)\n    * [ Reinforcement Learning Course ](https://www.dailydoseofds.com/rl-course-part-1/)\n    * [ AI Agents Course ](https://www.dailydoseofds.com/ai-agents-crash-course-part-1-with-implementation/)\n    * [ MCP Course ](https://www.dailydoseofds.com/model-context-protocol-crash-course-part-1/)\n    * [ RAG Systems Course ](https://www.dailydoseofds.com/a-crash-course-on-building-rag-systems-part-1-with-implementations/)\n    * [ LLM and Fine-tuning ](https://www.dailydoseofds.com/bi-encoders-and-cross-encoders-for-sentence-pair-similarity-scoring-part-1/)\n    * [ Classical ML and Deep Learning ](https://www.dailydoseofds.com/where-did-the-assumptions-of-linear-regression-originate-from/)\n    * [ Engineering Best Practices ](https://www.dailydoseofds.com/8-fatal-yet-non-obvious-pitfalls-and-cautionary-measures-in-data-science/)\n  * Sign In \n\n\nMay 23, 2026  Memory \n#  [Hands-on] Agent memory is only as good as its schema \nA deep dive on building production-grade memory for Agents. \n![Avi Chawla](../images/000.jpg)\nAvi Chawla \n👉\n* * *\nWhen you give an agent a knowledge graph for memory, the default behavior is that the LLM handling extraction decides the structure on its own.\nIt picks the entity types, the relationship labels, and the attributes.\nThe results are generic.\nEverything becomes a `Topic` or `Object` and every connection is labeled `RELATES_TO`, resulting in a graph that can’t be queried meaningfully.\n[​**Zep’s Graphiti (open-source with 26k+ GitHub stars)** ​](https://github.com/getzep/graphiti?ref=dailydoseofds.com) fixes this with a prescribed ontology.\n![](../images/001.png)\nYou can define entity types and edge types as Pydantic models, and the extraction model classifies against these definitions instead of guessing.\nLet’s look at why this matters, how the extraction pipeline works, with code!\n* * *\n#### Why flat retrieval breaks on multi-hop reasoning\nVector-based memory stores facts as text chunks and retrieves them by semantic similarity. That works until a query requires connecting facts that don’t appear in the same chunk.\nConsider three facts stored about a project.\n  * Alice manages Project Atlas\n  * Project Atlas runs on PostgreSQL\n  * The PostgreSQL cluster went down Tuesday\n\n\nA query like “`was Alice’s project affected by Tuesday’s outage`” needs all three.\n![](../images/002.png)\nVector search will retrieve just facts 1 and 3 because both mention relevant terms. Fact 2 is the bridge connecting Alice to PostgreSQL through Project Atlas, but it mentions neither Alice nor Tuesday. Similarity search misses it.\nA knowledge graph stores entities as nodes and relationships as edges. Instead of matching text, it traverses connections.\nThat chain (Alice → manages → Project Atlas → runs on → PostgreSQL) is what makes multi-hop reasoning work, and it is invisible to flat vector retrieval.\n* * *\n#### Where extraction fits in the pipeline\nEvery graph-based memory system follows the same pipeline. LLM accepts the raw data and extracts entities and relationships.\nThese get stored as nodes and edges, and at query time, the system searches the graph and injects relevant facts into the agent’s prompt.\nThe extraction step determines everything downstream. It decides what the graph contains, how it’s structured, and what can be queried.\nWhen extraction is unstructured, the LLM picks entity types and relationship labels on its own.\n![](../images/003.png)\nA developer conversation about building a web app called Nexus with Python, TypeScript, React, and Docker produces nodes labeled `Topic` and `Object` with `RELATES_TO` edges across the board.\nTwo things break without proper structure:\n  * Retrieval collapses to semantic similarity because it can’t filter by type when everything shares the same label.\n  * Domain constraints disappear because there are no structured attributes like `status` or `category` to distinguish “active vs. completed” or “frontend framework vs. database.”\n\n\n* * *\n#### Defining the schema with Pydantic\nThe fix is the same pattern used everywhere in the AI stack.\n  * FastAPI endpoints get Pydantic response models.\n  * Function calling tools get Pydantic schemas.\n  * Agent memory works the same way in Zep.\n\n\nDefine custom entity types using `EntityModel` (a subclass of Pydantic’s `BaseModel`) with `EntityText` fields and descriptions that guide the extraction model.\n![](../images/004.jpg)\nThe docstrings and field descriptions are important here because good descriptions with concrete examples give the extractor enough signal to classify accurately.\nThe Pydantic descriptions above aren’t just classification instructions. They teach the extractor vocabulary it doesn’t know.\nA Technology entity follows the same pattern.\n![](../images/005.jpg)\nEdge types use `EdgeModel` and carry their own attributes.\n![](../images/006.jpg)\nFinally, wire these into the graph with source/target constraints using `EntityEdgeSourceTarget`, which defines which entity types can connect through which edge types:\n![](../images/007.jpg)\nThe code enforces that:\n  * `WORKS_ON` can only connect a `User` to a `Project`\n  * `USES_TECHNOLOGY` can only connect a `User` to a `Technology`.\n  * Any relationship that doesn't match these constraints won't produce a typed edge.\n\n\n#### Under the hood\nWhen a conversation is ingested with a schema, Zep’s extraction pipeline runs through five steps:\n![](../images/008.png)\n  1. Entity extraction identifies named entities in the text and classifies them against the defined types\n  2. Entity resolution merges duplicates (”Nexus” and “the Nexus project” become one node)\n  3. Fact extraction identifies relationships and outputs them as typed edges using the source/target constraints\n  4. Fact resolution detects contradictions and invalidates outdated facts, preserving history through Graphiti’s bi-temporal model, which tracks both event time and ingestion time\n  5. Temporal extraction parses time references and maps them to validity windows on each edge\n\n\nThe Pydantic schema defined above guides steps 1 and 3.\nEntity types tell the extractor what to look for. Edge types with their constraints tell it what relationships to classify. Resolution and temporal processing happen automatically.\nEvery edge also carries explicit validity intervals (`t_valid`, `t_invalid`). When information changes (”Alex moved from Project Atlas to Project Nexus”), the old fact is invalidated, not deleted.\nThis way, you can query what’s true now as well as reconstruct what the state would have been at any point in time.\n#### The output in practice\nWe ingest a conversation where a developer named Alex discusses their work (an active web app called Nexus, their tech stack, proficiency levels):\n![](../images/009.png)\nQuerying for `Project` nodes returns Nexus with populated `project_status` and `project_type` attributes.\n![](https://substackcdn.com/image/fetch/$s_!F1gH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6a1f879-cc56-4d2e-8010-e04fedcf9871_1456x134.png)\nThe node isn’t a generic “Topic” or “Object.” It’s a `Project` with structured fields as defined in the schema.\nThe edges are typed too.\n  * `WORKS_ON` carries `role: lead developer`\n\n![](../images/010.png)\n  * `USES_TECHNOLOGY` carries `proficiency: advanced` for Python and Docker, `proficiency: intermediate` for TypeScript.\n\n![](../images/011.png)\nThis can now filter projects by status, technologies by category, and query “which active projects use PostgreSQL” with a precise answer.\n#### Context templates\nThe final piece is context templates, which assemble typed facts into a prompt-ready block.\nYou can define which edge types and entity types to include, and Zep formats them with temporal annotations into a single string injected into the agent’s prompt.\n![](https://embed.filekitcdn.com/e/k7YHPN24SoxyM8nGKZnDxa/ruQ3fXbQn2isXezR1Qeo26/email)\nIt looks like this:\n![](../images/012.png)\nEvery entry in the resulting context block is typed, temporally annotated, and carries the attributes defined. Save the template once, reference it by ID in agent calls.\n* * *\n#### The 10/10/10 constraint and schema as a reasoning boundary\nZep enforces a hard limit of 10 custom entity types, 10 custom edge types, and 10 fields per type.\n![](../images/013.png)\nThat’s intentional to force a dev to think about what matters in a domain rather than modeling everything.\nThe source/target constraints also act as guardrails on what an agent is allowed to remember. If a schema doesn’t include an edge type connecting `Project` to `Competitor`, the extraction model won’t create that relationship, even if a conversation mentions both.\nThe schema defines the space of valid memories.\nThis is the same principle behind typed function calling, where we constrain the LLM’s output space so that it can’t produce invalid arguments. Memory schemas apply that same constraint to what the agent stores.\nStart with 3-4 entity types and 3-4 edge types that capture 80% of your domain logic, and add complexity incrementally.\n* * *\nAgent memory without schema discipline is a graph that behaves like a vector store.\nIn a way, you pay the cost of graph construction without getting the benefit of structured retrieval.\nThe schema is how you get that benefit back, and the fact that it’s Pydantic means there’s nothing new to learn.\n[​**You can find Zep’s GitHub repo here →** ​](https://github.com/getzep/graphiti?ref=dailydoseofds.com) (don’t forget to star 🌟)\nThanks for reading!\nPublished on May 23, 2026 \nComments \nShare \nCopy link [ Share to X ](https://x.com/intent/tweet?url=https%3A%2F%2Fwww.dailydoseofds.com%2Fp%2Fhands-on-agent-memory-is-only-as-good-as-its-schema%2F&text=%5BHands-on%5D%20Agent%20memory%20is%20only%20as%20good%20as%20its%20schema) [ Share to Facebook ](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fwww.dailydoseofds.com%2Fp%2Fhands-on-agent-memory-is-only-as-good-as-its-schema%2F) [ Share to Linkedin ](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fwww.dailydoseofds.com%2Fp%2Fhands-on-agent-memory-is-only-as-good-as-its-schema%2F)\nCopied \n[ Previous  Model-Free Learning  ](https://www.dailydoseofds.com/rl-course-part-4/) [ Next  Function Approximation  ](https://www.dailydoseofds.com/rl-course-part-5/)\n[ ![Daily Dose of Data Science](https://storage.ghost.io/c/3f/df/3fdf6ed2-17ac-4b12-a693-8078bd13e748/content/images/2025/12/dailyds-logo-transparent-1.png) ](https://www.dailydoseofds.com)\nA daily column with insights, observations, tutorials and best practices on python and data science. Read by industry professionals at big tech, startups, and engineering students. \n  * Menu \n  * [ Contact ](https://www.dailydoseofds.com/contact/)\n  * [ FAQ ](https://www.dailydoseofds.com/faq/)\n\n\n[Daily Dose of Data Science](https://www.dailydoseofds.com) © 2026 \n[ ](https://x.com/_avichawla \"X \\(Formerly Twitter\\)\")\n",
  "metadata": {
    "title": "[Hands-on] Agent memory is only as good as its schema",
    "description": "A deep dive on building production-grade memory for Agents.",
    "keywords": null,
    "author": null,
    "og:site_name": "Daily Dose of Data Science",
    "og:type": "article",
    "og:title": "[Hands-on] Agent memory is only as good as its schema",
    "og:description": "A deep dive on building production-grade memory for Agents.",
    "og:url": "https://www.dailydoseofds.com/p/hands-on-agent-memory-is-only-as-good-as-its-schema/",
    "og:image": "https://storage.ghost.io/c/3f/df/3fdf6ed2-17ac-4b12-a693-8078bd13e748/content/images/2026/06/990fe7c9-7c72-49c9-8fb4-ea0b9cc8e01b.jpg",
    "og:image:width": "1200",
    "og:image:height": "1195",
    "twitter:card": "summary_large_image",
    "twitter:title": "[Hands-on] Agent memory is only as good as its schema",
    "twitter:description": "A deep dive on building production-grade memory for Agents.",
    "twitter:url": "https://www.dailydoseofds.com/p/hands-on-agent-memory-is-only-as-good-as-its-schema/",
    "twitter:image": "https://storage.ghost.io/c/3f/df/3fdf6ed2-17ac-4b12-a693-8078bd13e748/content/images/2026/06/990fe7c9-7c72-49c9-8fb4-ea0b9cc8e01b.jpg",
    "twitter:label1": "Written by",
    "twitter:data1": "Avi Chawla",
    "twitter:label2": "Filed under",
    "twitter:data2": "Memory, Agents",
    "twitter:site": "@_avichawla",
    "article:published_time": "2026-05-22T21:48:00.000Z",
    "article:modified_time": "2026-06-12T22:01:21.000Z",
    "article:tag": "Agents"
  },
  "paywall": {
    "listed_paid": false,
    "detected": false,
    "marker": "",
    "public_only": false,
    "policy": "付费/会员内容只保留页面公开可见部分，不绕过付费墙"
  },
  "crawl": {
    "success": true,
    "status_code": 200,
    "error": ""
  },
  "code_blocks": [],
  "images": [
    {
      "src": "https://storage.ghost.io/c/3f/df/3fdf6ed2-17ac-4b12-a693-8078bd13e748/content/images/size/w400/2026/03/avi-google.jpg",
      "alt": "Avi Chawla",
      "local_path": "attachments/7c0726acba87/images/000.jpg",
      "bytes": 11344,
      "downloaded": true,
      "status": "ok",
      "url": "https://storage.ghost.io/c/3f/df/3fdf6ed2-17ac-4b12-a693-8078bd13e748/content/images/size/w400/2026/03/avi-google.jpg",
      "reused": true,
      "retried_at": "2026-10-18T17:12:06Z"
    },
    {
      "src": "https://substackcdn.com/image/fetch/$s_!W4Jh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff24d8488-abf4-452f-a130-d72f9c8a4e17_1240x782.png",
      "alt": "",
      "local_path": "attachments/7c0726acba87/images/001.png",
      "bytes": 57710,
      "downloaded": true,
      "status": "ok",
      "url": "https://substackcdn.com/image/fetch/$s_!W4Jh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff24d8488-abf4-452f-a130-d72f9c8a4e17_1240x782.png",
      "reused": true,
      "retried_at": "2026-10-18T17:12:06Z"
    },
    {
      "src": "https://substackcdn.com/image/fetch/$s_!m9Pb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc929820-281f-4b0b-a551-f770a9d4624a_1456x829.png",
      "alt": "",
      "local_path": "attachments/7c0726acba87/images/002.png",
      "bytes": 297247,
      "downloaded": true,
      "status": "ok",
      "url": "https://substackcdn.com/image/fetch/$s_!m9Pb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc929820-281f-4b0b-a551-f770a9d4624a_1456x829.png",
      "reused": true,
      "retried_at": "2026-10-18T17:12:06Z"
    },
    {
      "src": "https://substackcdn.com/image/fetch/$s_!jdHD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F986e63b0-0ae5-46a0-8674-5c55f6da69c2_1456x788.png",
      "alt": "",
      "local_path": "attachments/7c0726acba87/images/003.png",
      "bytes": 243124,
      "downloaded": true,
      "status": "ok",
      "url": "https://substackcdn.com/image/fetch/$s_!jdHD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F986e63b0-0ae5-46a0-8674-5c55f6da69c2_1456x788.png",
      "reused": true,
      "retried_at": "2026-10-18T17:12:06Z"
    },
    {
      "src": "https://embed.filekitcdn.com/e/k7YHPN24SoxyM8nGKZnDxa/tnksXtZqbdehntsj2qqkdq/email",
      "alt": "",
      "local_path": "attachments/7c0726acba87/images/004.jpg",
      "bytes": 193126,
      "downloaded": true,
      "status": "ok",
      "url": "https://embed.filekitcdn.com/e/k7YHPN24SoxyM8nGKZnDxa/tnksXtZqbdehntsj2qqkdq/email",
      "reused": true,
      "retried_at": "2026-10-18T17:12:06Z"
    },
    {
      "src": "https://embed.filekitcdn.com/e/k7YHPN24SoxyM8nGKZnDxa/5a4icZSqcNb1kN1rqz9ihT/email",
      "alt": "",
      "local_path": "attachments/7c0726acba87/images/005.jpg",
      "bytes": 121210,
      "downloaded": true,
      "status": "ok",
      "url": "https://embed.filekitcdn.com/e/k7YHPN24SoxyM8nGKZnDxa/5a4icZSqcNb1kN1rqz9ihT/email",
      "reused": true,
      "retried_at": "2026-10-18T17:12:06Z"
    },
    {
      "src": "https://embed.filekitcdn.com/e/k7YHPN24SoxyM8nGKZnDxa/hmuYRQu8oea4hE35RyrATM/email",
      "alt": "",
      "local_path": "attachments/7c0726acba87/images/006.jpg",
      "bytes": 178103,
      "downloaded": true,
      "status": "ok",
      "url": "https://embed.filekitcdn.com/e/k7YHPN24SoxyM8nGKZnDxa/hmuYRQu8oea4hE35RyrATM/email",
      "reused": true,
      "retried_at": "2026-10-18T17:12:06Z"
    },
    {
      "src": "https://embed.filekitcdn.com/e/k7YHPN24SoxyM8nGKZnDxa/sFaWtzJcqJiMYkuMjamWSs/email",
      "alt": "",
      "local_path": "attachments/7c0726acba87/images/007.jpg",
      "bytes": 170049,
      "downloaded": true,
      "status": "ok",
      "url": "https://embed.filekitcdn.com/e/k7YHPN24SoxyM8nGKZnDxa/sFaWtzJcqJiMYkuMjamWSs/email",
      "reused": true,
      "retried_at": "2026-10-18T17:12:06Z"
    },
    {
      "src": "https://substackcdn.com/image/fetch/$s_!VPK6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F089cd292-dcce-4ecb-823b-a5b41a2c1637_1456x697.png",
      "alt": "",
      "local_path": "attachments/7c0726acba87/images/008.png",
      "bytes": 237443,
      "downloaded": true,
      "status": "ok",
      "url": "https://substackcdn.com/image/fetch/$s_!VPK6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F089cd292-dcce-4ecb-823b-a5b41a2c1637_1456x697.png",
      "reused": true,
      "retried_at": "2026-10-18T17:12:06Z"
    },
    {
      "src": "https://substackcdn.com/image/fetch/$s_!z9Te!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4087687-6628-4776-b403-50ef3be315b2_1456x589.png",
      "alt": "",
      "local_path": "attachments/7c0726acba87/images/009.png",
      "bytes": 131341,
      "downloaded": true,
      "status": "ok",
      "url": "https://substackcdn.com/image/fetch/$s_!z9Te!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4087687-6628-4776-b403-50ef3be315b2_1456x589.png",
      "reused": true,
      "retried_at": "2026-10-18T17:12:06Z"
    },
    {
      "src": "https://substackcdn.com/image/fetch/$s_!bfM3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0892db25-cac1-4540-8dc3-ce0194ec2efb_1456x163.png",
      "alt": "",
      "local_path": "attachments/7c0726acba87/images/010.png",
      "bytes": 92684,
      "downloaded": true,
      "status": "ok",
      "url": "https://substackcdn.com/image/fetch/$s_!bfM3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0892db25-cac1-4540-8dc3-ce0194ec2efb_1456x163.png",
      "reused": true,
      "retried_at": "2026-10-18T17:12:06Z"
    },
    {
      "src": "https://substackcdn.com/image/fetch/$s_!QHDB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb5039f38-73fb-44f9-bd99-83e8dc47ae6c_1456x410.png",
      "alt": "",
      "local_path": "attachments/7c0726acba87/images/011.png",
      "bytes": 252807,
      "downloaded": true,
      "status": "ok",
      "url": "https://substackcdn.com/image/fetch/$s_!QHDB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb5039f38-73fb-44f9-bd99-83e8dc47ae6c_1456x410.png",
      "reused": true,
      "retried_at": "2026-10-18T17:12:06Z"
    },
    {
      "src": "https://substackcdn.com/image/fetch/$s_!Rvoj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca065bfa-4a46-46a0-8d1e-a087e415fd8a_1456x481.png",
      "alt": "",
      "local_path": "attachments/7c0726acba87/images/012.png",
      "bytes": 217813,
      "downloaded": true,
      "status": "ok",
      "url": "https://substackcdn.com/image/fetch/$s_!Rvoj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca065bfa-4a46-46a0-8d1e-a087e415fd8a_1456x481.png",
      "reused": true,
      "retried_at": "2026-10-18T17:12:06Z"
    },
    {
      "src": "https://substackcdn.com/image/fetch/$s_!Cpke!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e178618-4c13-4a6b-929e-cb17de03bf72_1758x982.png",
      "alt": "",
      "local_path": "attachments/7c0726acba87/images/013.png",
      "bytes": 332108,
      "downloaded": true,
      "status": "ok",
      "url": "https://substackcdn.com/image/fetch/$s_!Cpke!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e178618-4c13-4a6b-929e-cb17de03bf72_1758x982.png",
      "reused": true,
      "retried_at": "2026-10-18T17:12:06Z"
    }
  ],
  "audio": [],
  "videos": [],
  "links": [
    {
      "type": "internal",
      "href": "https://www.dailydoseofds.com/p/hands-on-agent-memory-is-only-as-good-as-its-schema/"
    },
    {
      "type": "internal",
      "href": "https://www.dailydoseofds.com"
    },
    {
      "type": "internal",
      "href": "https://www.dailydoseofds.com/archive/"
    },
    {
      "type": "internal",
      "href": "https://www.dailydoseofds.com/what-is-mcp/"
    },
    {
      "type": "internal",
      "href": "https://www.dailydoseofds.com/"
    },
    {
      "type": "internal",
      "href": "https://www.dailydoseofds.com/mlops-crash-course-part-1/"
    },
    {
      "type": "internal",
      "href": "https://www.dailydoseofds.com/rl-course-part-1/"
    },
    {
      "type": "internal",
      "href": "https://www.dailydoseofds.com/ai-agents-crash-course-part-1-with-implementation/"
    },
    {
      "type": "internal",
      "href": "https://www.dailydoseofds.com/model-context-protocol-crash-course-part-1/"
    },
    {
      "type": "internal",
      "href": "https://www.dailydoseofds.com/a-crash-course-on-building-rag-systems-part-1-with-implementations/"
    },
    {
      "type": "internal",
      "href": "https://www.dailydoseofds.com/bi-encoders-and-cross-encoders-for-sentence-pair-similarity-scoring-part-1/"
    },
    {
      "type": "internal",
      "href": "https://www.dailydoseofds.com/where-did-the-assumptions-of-linear-regression-originate-from/"
    },
    {
      "type": "internal",
      "href": "https://www.dailydoseofds.com/8-fatal-yet-non-obvious-pitfalls-and-cautionary-measures-in-data-science/"
    },
    {
      "type": "internal",
      "href": "https://www.dailydoseofds.com/membership"
    },
    {
      "type": "internal",
      "href": "https://www.dailydoseofds.com/rl-course-part-4/"
    },
    {
      "type": "internal",
      "href": "https://www.dailydoseofds.com/rl-course-part-5/"
    },
    {
      "type": "internal",
      "href": "https://www.dailydoseofds.com/contact/"
    },
    {
      "type": "internal",
      "href": "https://www.dailydoseofds.com/faq/"
    },
    {
      "type": "external",
      "href": "https://dailydoseofds.github.io/ai-engg-book/"
    },
    {
      "type": "external",
      "href": "https://drive.google.com/file/d/1Th8mN_IF7Ttc8bI_OLtUuQ7Mjx3aJ6Hi/view"
    },
    {
      "type": "external",
      "href": "https://drive.google.com/file/d/1_s2UaD7tEPECjgC5YMOa1LIOB9HUWFO-/view"
    },
    {
      "type": "external",
      "href": "https://drive.google.com/file/d/1ZunUHwkD2Ut0_LrgDTDmlQRQkfT2lkVf/view"
    },
    {
      "type": "external",
      "href": "https://github.com/getzep/graphiti"
    },
    {
      "type": "external",
      "href": "https://x.com/intent/tweet?text=%5BHands-on%5D+Agent+memory+is+only+as+good+as+its+schema&url=https%3A%2F%2Fwww.dailydoseofds.com%2Fp%2Fhands-on-agent-memory-is-only-as-good-as-its-schema%2F"
    },
    {
      "type": "external",
      "href": "https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fwww.dailydoseofds.com%2Fp%2Fhands-on-agent-memory-is-only-as-good-as-its-schema%2F"
    },
    {
      "type": "external",
      "href": "https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fwww.dailydoseofds.com%2Fp%2Fhands-on-agent-memory-is-only-as-good-as-its-schema%2F"
    },
    {
      "type": "external",
      "href": "https://x.com/_avichawla"
    }
  ],
  "repair_version": 2,
  "repaired_at": "2026-10-20T17:25:32Z",
  "source_url": "https://www.dailydoseofds.com/p/hands-on-agent-memory-is-only-as-good-as-its-schema/",
  "delivery_status": "unverified",
  "discovery_status": "short_or_dynamic",
  "missing_reason": "正文过短或动态页面，未确认完整",
  "source_body_markdown": "[ Skip to main content  ](https://www.dailydoseofds.com/p/hands-on-agent-memory-is-only-as-good-as-its-schema/#sx-main)\n[ ![Daily Dose of Data Science](https://storage.ghost.io/c/3f/df/3fdf6ed2-17ac-4b12-a693-8078bd13e748/content/images/2025/12/dailyds-logo-transparent-1.png) ](https://www.dailydoseofds.com)\n  * [ Newsletter ](https://dailydoseofds.github.io/ai-engg-book/)\n  * [ Archive ](https://www.dailydoseofds.com/archive/)\n  * Guidebooks \n    * [ MCP Guidebook ](https://www.dailydoseofds.com/what-is-mcp/)\n[ Agents Guidebook ](https://drive.google.com/file/d/1Th8mN_IF7Ttc8bI_OLtUuQ7Mjx3aJ6Hi/view)\n[ AI Engineering Guidebook ](https://drive.google.com/file/d/1_s2UaD7tEPECjgC5YMOa1LIOB9HUWFO-/view)\n[ DS Guidebook ](https://drive.google.com/file/d/1ZunUHwkD2Ut0_LrgDTDmlQRQkfT2lkVf/view)\n[ Courses ](https://www.dailydoseofds.com/)\n[ MLOps/LLMOps Course ](https://www.dailydoseofds.com/mlops-crash-course-part-1/)\n[ Reinforcement Learning Course ](https://www.dailydoseofds.com/rl-course-part-1/)\n[ AI Agents Course ](https://www.dailydoseofds.com/ai-agents-crash-course-part-1-with-implementation/)\n[ MCP Course ](https://www.dailydoseofds.com/model-context-protocol-crash-course-part-1/)\n[ RAG Systems Course ](https://www.dailydoseofds.com/a-crash-course-on-building-rag-systems-part-1-with-implementations/)\n  * Courses \n    * [ MLOps/LLMOps Course ](https://www.dailydoseofds.com/mlops-crash-course-part-1/)\n[ Reinforcement Learning Course ](https://www.dailydoseofds.com/rl-course-part-1/)\n[ AI Agents Course ](https://www.dailydoseofds.com/ai-agents-crash-course-part-1-with-implementation/)\n[ MCP Course ](https://www.dailydoseofds.com/model-context-protocol-crash-course-part-1/)\n[ RAG Systems Course ](https://www.dailydoseofds.com/a-crash-course-on-building-rag-systems-part-1-with-implementations/)\n[ LLM and Fine-tuning ](https://www.dailydoseofds.com/bi-encoders-and-cross-encoders-for-sentence-pair-similarity-scoring-part-1/)\n[ Classical ML and Deep Learning ](https://www.dailydoseofds.com/where-did-the-assumptions-of-linear-regression-originate-from/)\n[ Engineering Best Practices ](https://www.dailydoseofds.com/8-fatal-yet-non-obvious-pitfalls-and-cautionary-measures-in-data-science/)\n  *     * [ Newsletter ](https://dailydoseofds.github.io/ai-engg-book/)\n[ Archive ](https://www.dailydoseofds.com/archive/)\nGuidebooks \n      * [ MCP Guidebook ](https://www.dailydoseofds.com/what-is-mcp/)\n      * [ Agents Guidebook ](https://drive.google.com/file/d/1Th8mN_IF7Ttc8bI_OLtUuQ7Mjx3aJ6Hi/view)\n      * [ AI Engineering Guidebook ](https://drive.google.com/file/d/1_s2UaD7tEPECjgC5YMOa1LIOB9HUWFO-/view)\n      * [ DS Guidebook ](https://drive.google.com/file/d/1ZunUHwkD2Ut0_LrgDTDmlQRQkfT2lkVf/view)\n      * [ Courses ](https://www.dailydoseofds.com/)\n      * [ MLOps/LLMOps Course ](https://www.dailydoseofds.com/mlops-crash-course-part-1/)\n      * [ Reinforcement Learning Course ](https://www.dailydoseofds.com/rl-course-part-1/)\n      * [ AI Agents Course ](https://www.dailydoseofds.com/ai-agents-crash-course-part-1-with-implementation/)\n      * [ MCP Course ](https://www.dailydoseofds.com/model-context-protocol-crash-course-part-1/)\n      * [ RAG Systems Course ](https://www.dailydoseofds.com/a-crash-course-on-building-rag-systems-part-1-with-implementations/)\nCourses \n      * [ MLOps/LLMOps Course ](https://www.dailydoseofds.com/mlops-crash-course-part-1/)\n      * [ Reinforcement Learning Course ](https://www.dailydoseofds.com/rl-course-part-1/)\n      * [ AI Agents Course ](https://www.dailydoseofds.com/ai-agents-crash-course-part-1-with-implementation/)\n      * [ MCP Course ](https://www.dailydoseofds.com/model-context-protocol-crash-course-part-1/)\n      * [ RAG Systems Course ](https://www.dailydoseofds.com/a-crash-course-on-building-rag-systems-part-1-with-implementations/)\n      * [ LLM and Fine-tuning ](https://www.dailydoseofds.com/bi-encoders-and-cross-encoders-for-sentence-pair-similarity-scoring-part-1/)\n      * [ Classical ML and Deep Learning ](https://www.dailydoseofds.com/where-did-the-assumptions-of-linear-regression-originate-from/)\n      * [ Engineering Best Practices ](https://www.dailydoseofds.com/8-fatal-yet-non-obvious-pitfalls-and-cautionary-measures-in-data-science/)\n\n\nSign In  [ Get Started ](https://www.dailydoseofds.com/membership)\n/\n  * [ Newsletter ](https://dailydoseofds.github.io/ai-engg-book/)\n  * [ Archive ](https://www.dailydoseofds.com/archive/)\n  * Guidebooks \n    * [ MCP Guidebook ](https://www.dailydoseofds.com/what-is-mcp/)\n    * [ Agents Guidebook ](https://drive.google.com/file/d/1Th8mN_IF7Ttc8bI_OLtUuQ7Mjx3aJ6Hi/view)\n    * [ AI Engineering Guidebook ](https://drive.google.com/file/d/1_s2UaD7tEPECjgC5YMOa1LIOB9HUWFO-/view)\n    * [ DS Guidebook ](https://drive.google.com/file/d/1ZunUHwkD2Ut0_LrgDTDmlQRQkfT2lkVf/view)\n    * [ Courses ](https://www.dailydoseofds.com/)\n    * [ MLOps/LLMOps Course ](https://www.dailydoseofds.com/mlops-crash-course-part-1/)\n    * [ Reinforcement Learning Course ](https://www.dailydoseofds.com/rl-course-part-1/)\n    * [ AI Agents Course ](https://www.dailydoseofds.com/ai-agents-crash-course-part-1-with-implementation/)\n    * [ MCP Course ](https://www.dailydoseofds.com/model-context-protocol-crash-course-part-1/)\n    * [ RAG Systems Course ](https://www.dailydoseofds.com/a-crash-course-on-building-rag-systems-part-1-with-implementations/)\n  * Courses \n    * [ MLOps/LLMOps Course ](https://www.dailydoseofds.com/mlops-crash-course-part-1/)\n    * [ Reinforcement Learning Course ](https://www.dailydoseofds.com/rl-course-part-1/)\n    * [ AI Agents Course ](https://www.dailydoseofds.com/ai-agents-crash-course-part-1-with-implementation/)\n    * [ MCP Course ](https://www.dailydoseofds.com/model-context-protocol-crash-course-part-1/)\n    * [ RAG Systems Course ](https://www.dailydoseofds.com/a-crash-course-on-building-rag-systems-part-1-with-implementations/)\n    * [ LLM and Fine-tuning ](https://www.dailydoseofds.com/bi-encoders-and-cross-encoders-for-sentence-pair-similarity-scoring-part-1/)\n    * [ Classical ML and Deep Learning ](https://www.dailydoseofds.com/where-did-the-assumptions-of-linear-regression-originate-from/)\n    * [ Engineering Best Practices ](https://www.dailydoseofds.com/8-fatal-yet-non-obvious-pitfalls-and-cautionary-measures-in-data-science/)\n  * Sign In \n\n\nMay 23, 2026  Memory \n#  [Hands-on] Agent memory is only as good as its schema \nA deep dive on building production-grade memory for Agents. \n![Avi Chawla](https://storage.ghost.io/c/3f/df/3fdf6ed2-17ac-4b12-a693-8078bd13e748/content/images/size/w400/2026/03/avi-google.jpg)\nAvi Chawla \n👉\n* * *\nWhen you give an agent a knowledge graph for memory, the default behavior is that the LLM handling extraction decides the structure on its own.\nIt picks the entity types, the relationship labels, and the attributes.\nThe results are generic.\nEverything becomes a `Topic` or `Object` and every connection is labeled `RELATES_TO`, resulting in a graph that can’t be queried meaningfully.\n[​**Zep’s Graphiti (open-source with 26k+ GitHub stars)** ​](https://github.com/getzep/graphiti?ref=dailydoseofds.com) fixes this with a prescribed ontology.\n![](https://substackcdn.com/image/fetch/$s_!W4Jh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff24d8488-abf4-452f-a130-d72f9c8a4e17_1240x782.png)\nYou can define entity types and edge types as Pydantic models, and the extraction model classifies against these definitions instead of guessing.\nLet’s look at why this matters, how the extraction pipeline works, with code!\n* * *\n#### Why flat retrieval breaks on multi-hop reasoning\nVector-based memory stores facts as text chunks and retrieves them by semantic similarity. That works until a query requires connecting facts that don’t appear in the same chunk.\nConsider three facts stored about a project.\n  * Alice manages Project Atlas\n  * Project Atlas runs on PostgreSQL\n  * The PostgreSQL cluster went down Tuesday\n\n\nA query like “`was Alice’s project affected by Tuesday’s outage`” needs all three.\n![](https://substackcdn.com/image/fetch/$s_!m9Pb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc929820-281f-4b0b-a551-f770a9d4624a_1456x829.png)\nVector search will retrieve just facts 1 and 3 because both mention relevant terms. Fact 2 is the bridge connecting Alice to PostgreSQL through Project Atlas, but it mentions neither Alice nor Tuesday. Similarity search misses it.\nA knowledge graph stores entities as nodes and relationships as edges. Instead of matching text, it traverses connections.\nThat chain (Alice → manages → Project Atlas → runs on → PostgreSQL) is what makes multi-hop reasoning work, and it is invisible to flat vector retrieval.\n* * *\n#### Where extraction fits in the pipeline\nEvery graph-based memory system follows the same pipeline. LLM accepts the raw data and extracts entities and relationships.\nThese get stored as nodes and edges, and at query time, the system searches the graph and injects relevant facts into the agent’s prompt.\nThe extraction step determines everything downstream. It decides what the graph contains, how it’s structured, and what can be queried.\nWhen extraction is unstructured, the LLM picks entity types and relationship labels on its own.\n![](https://substackcdn.com/image/fetch/$s_!jdHD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F986e63b0-0ae5-46a0-8674-5c55f6da69c2_1456x788.png)\nA developer conversation about building a web app called Nexus with Python, TypeScript, React, and Docker produces nodes labeled `Topic` and `Object` with `RELATES_TO` edges across the board.\nTwo things break without proper structure:\n  * Retrieval collapses to semantic similarity because it can’t filter by type when everything shares the same label.\n  * Domain constraints disappear because there are no structured attributes like `status` or `category` to distinguish “active vs. completed” or “frontend framework vs. database.”\n\n\n* * *\n#### Defining the schema with Pydantic\nThe fix is the same pattern used everywhere in the AI stack.\n  * FastAPI endpoints get Pydantic response models.\n  * Function calling tools get Pydantic schemas.\n  * Agent memory works the same way in Zep.\n\n\nDefine custom entity types using `EntityModel` (a subclass of Pydantic’s `BaseModel`) with `EntityText` fields and descriptions that guide the extraction model.\n![](https://embed.filekitcdn.com/e/k7YHPN24SoxyM8nGKZnDxa/tnksXtZqbdehntsj2qqkdq/email)\nThe docstrings and field descriptions are important here because good descriptions with concrete examples give the extractor enough signal to classify accurately.\nThe Pydantic descriptions above aren’t just classification instructions. They teach the extractor vocabulary it doesn’t know.\nA Technology entity follows the same pattern.\n![](https://embed.filekitcdn.com/e/k7YHPN24SoxyM8nGKZnDxa/5a4icZSqcNb1kN1rqz9ihT/email)\nEdge types use `EdgeModel` and carry their own attributes.\n![](https://embed.filekitcdn.com/e/k7YHPN24SoxyM8nGKZnDxa/hmuYRQu8oea4hE35RyrATM/email)\nFinally, wire these into the graph with source/target constraints using `EntityEdgeSourceTarget`, which defines which entity types can connect through which edge types:\n![](https://embed.filekitcdn.com/e/k7YHPN24SoxyM8nGKZnDxa/sFaWtzJcqJiMYkuMjamWSs/email)\nThe code enforces that:\n  * `WORKS_ON` can only connect a `User` to a `Project`\n  * `USES_TECHNOLOGY` can only connect a `User` to a `Technology`.\n  * Any relationship that doesn't match these constraints won't produce a typed edge.\n\n\n#### Under the hood\nWhen a conversation is ingested with a schema, Zep’s extraction pipeline runs through five steps:\n![](https://substackcdn.com/image/fetch/$s_!VPK6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F089cd292-dcce-4ecb-823b-a5b41a2c1637_1456x697.png)\n  1. Entity extraction identifies named entities in the text and classifies them against the defined types\n  2. Entity resolution merges duplicates (”Nexus” and “the Nexus project” become one node)\n  3. Fact extraction identifies relationships and outputs them as typed edges using the source/target constraints\n  4. Fact resolution detects contradictions and invalidates outdated facts, preserving history through Graphiti’s bi-temporal model, which tracks both event time and ingestion time\n  5. Temporal extraction parses time references and maps them to validity windows on each edge\n\n\nThe Pydantic schema defined above guides steps 1 and 3.\nEntity types tell the extractor what to look for. Edge types with their constraints tell it what relationships to classify. Resolution and temporal processing happen automatically.\nEvery edge also carries explicit validity intervals (`t_valid`, `t_invalid`). When information changes (”Alex moved from Project Atlas to Project Nexus”), the old fact is invalidated, not deleted.\nThis way, you can query what’s true now as well as reconstruct what the state would have been at any point in time.\n#### The output in practice\nWe ingest a conversation where a developer named Alex discusses their work (an active web app called Nexus, their tech stack, proficiency levels):\n![](https://substackcdn.com/image/fetch/$s_!z9Te!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4087687-6628-4776-b403-50ef3be315b2_1456x589.png)\nQuerying for `Project` nodes returns Nexus with populated `project_status` and `project_type` attributes.\n![](https://substackcdn.com/image/fetch/$s_!F1gH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6a1f879-cc56-4d2e-8010-e04fedcf9871_1456x134.png)\nThe node isn’t a generic “Topic” or “Object.” It’s a `Project` with structured fields as defined in the schema.\nThe edges are typed too.\n  * `WORKS_ON` carries `role: lead developer`\n\n![](https://substackcdn.com/image/fetch/$s_!bfM3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0892db25-cac1-4540-8dc3-ce0194ec2efb_1456x163.png)\n  * `USES_TECHNOLOGY` carries `proficiency: advanced` for Python and Docker, `proficiency: intermediate` for TypeScript.\n\n![](https://substackcdn.com/image/fetch/$s_!QHDB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb5039f38-73fb-44f9-bd99-83e8dc47ae6c_1456x410.png)\nThis can now filter projects by status, technologies by category, and query “which active projects use PostgreSQL” with a precise answer.\n#### Context templates\nThe final piece is context templates, which assemble typed facts into a prompt-ready block.\nYou can define which edge types and entity types to include, and Zep formats them with temporal annotations into a single string injected into the agent’s prompt.\n![](https://embed.filekitcdn.com/e/k7YHPN24SoxyM8nGKZnDxa/ruQ3fXbQn2isXezR1Qeo26/email)\nIt looks like this:\n![](https://substackcdn.com/image/fetch/$s_!Rvoj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca065bfa-4a46-46a0-8d1e-a087e415fd8a_1456x481.png)\nEvery entry in the resulting context block is typed, temporally annotated, and carries the attributes defined. Save the template once, reference it by ID in agent calls.\n* * *\n#### The 10/10/10 constraint and schema as a reasoning boundary\nZep enforces a hard limit of 10 custom entity types, 10 custom edge types, and 10 fields per type.\n![](https://substackcdn.com/image/fetch/$s_!Cpke!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e178618-4c13-4a6b-929e-cb17de03bf72_1758x982.png)\nThat’s intentional to force a dev to think about what matters in a domain rather than modeling everything.\nThe source/target constraints also act as guardrails on what an agent is allowed to remember. If a schema doesn’t include an edge type connecting `Project` to `Competitor`, the extraction model won’t create that relationship, even if a conversation mentions both.\nThe schema defines the space of valid memories.\nThis is the same principle behind typed function calling, where we constrain the LLM’s output space so that it can’t produce invalid arguments. Memory schemas apply that same constraint to what the agent stores.\nStart with 3-4 entity types and 3-4 edge types that capture 80% of your domain logic, and add complexity incrementally.\n* * *\nAgent memory without schema discipline is a graph that behaves like a vector store.\nIn a way, you pay the cost of graph construction without getting the benefit of structured retrieval.\nThe schema is how you get that benefit back, and the fact that it’s Pydantic means there’s nothing new to learn.\n[​**You can find Zep’s GitHub repo here →** ​](https://github.com/getzep/graphiti?ref=dailydoseofds.com) (don’t forget to star 🌟)\nThanks for reading!\nPublished on May 23, 2026 \nComments \nShare \nCopy link [ Share to X ](https://x.com/intent/tweet?url=https%3A%2F%2Fwww.dailydoseofds.com%2Fp%2Fhands-on-agent-memory-is-only-as-good-as-its-schema%2F&text=%5BHands-on%5D%20Agent%20memory%20is%20only%20as%20good%20as%20its%20schema) [ Share to Facebook ](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fwww.dailydoseofds.com%2Fp%2Fhands-on-agent-memory-is-only-as-good-as-its-schema%2F) [ Share to Linkedin ](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fwww.dailydoseofds.com%2Fp%2Fhands-on-agent-memory-is-only-as-good-as-its-schema%2F)\nCopied \n[ Previous  Model-Free Learning  ](https://www.dailydoseofds.com/rl-course-part-4/) [ Next  Function Approximation  ](https://www.dailydoseofds.com/rl-course-part-5/)\n[ ![Daily Dose of Data Science](https://storage.ghost.io/c/3f/df/3fdf6ed2-17ac-4b12-a693-8078bd13e748/content/images/2025/12/dailyds-logo-transparent-1.png) ](https://www.dailydoseofds.com)\nA daily column with insights, observations, tutorials and best practices on python and data science. Read by industry professionals at big tech, startups, and engineering students. \n  * Menu \n  * [ Contact ](https://www.dailydoseofds.com/contact/)\n  * [ FAQ ](https://www.dailydoseofds.com/faq/)\n\n\n[Daily Dose of Data Science](https://www.dailydoseofds.com) © 2026 \n[ ](https://x.com/_avichawla \"X \\(Formerly Twitter\\)\")\n",
  "body_base_path": "attachments/7c0726acba87/pages/",
  "body_markdown_path": "attachments/7c0726acba87/pages/archived-body.md",
  "local_html": "attachments/7c0726acba87/pages/archived-body.html",
  "body_source": "prior_capture"
}