<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/your-ai-agent-forgets-everything-so-we-taught-it-to-remember-with-a-graph--wocxymt6u" -->

---
title: Your AI Agent Forgets Everything. So We Taught It to...
description: Neo4j Labs introduces @neo4j-labs/nams-ai-provider, a community provider for the Vercel AI SDK that adds persistent, cross-session memory to any model backed...
canonical: https://daily.dev/posts/your-ai-agent-forgets-everything-so-we-taught-it-to-remember-with-a-graph--wocxymt6u
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Your AI Agent Forgets Everything. So We Taught It to Remember — With a Graph. | daily.dev
og:description: Neo4j Labs introduces @neo4j-labs/nams-ai-provider, a community provider for the Vercel AI SDK that adds persistent, cross-session memory to any model backed...
og:url: https://daily.dev/posts/your-ai-agent-forgets-everything-so-we-taught-it-to-remember-with-a-graph--wocxymt6u
og:image: https://api.daily.dev/og/posts/wOcxyMt6u.png
og:image:alt: Your AI Agent Forgets Everything. So We Taught It to Remember — With a Graph.
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Your AI Agent Forgets Everything. So We Taught It to Remember — With a Graph.

**[neo4j](https://daily.dev/sources/neo4j)** · 19 min read · 3 upvotes · 0 comments

## Summary

Neo4j Labs introduces @neo4j-labs/nams-ai-provider, a community provider for the Vercel AI SDK that adds persistent, cross-session memory to any model backed by a hosted Neo4j knowledge graph service (NAMS). Instead of storing memories as flat text chunks searched via vector similarity, it decomposes conversations into typed entities and relationships (e.g., Alex [Person] WORKS_AT TechCorp [Organization]), enabling queries like 'list everything you believe about this user' or targeted corrections to a single fact. The package offers three integration modes — provider (invisible, guaranteed memory via middleware), tools (visible, model-driven memory calls), and a hybrid — plus new prepareStep/onFinish hooks (enforceQueryMemory and ensureMemoryStored) that solve the long-standing trade-off between guaranteed and visible memory in tool-based systems. It also guards against 'memory about remembering' polluting future retrievals, degrades gracefully on failures, and is tested with 63 Vitest tests. Integration requires only a free API key and swapping one line of code; no self-hosted Neo4j cluster, vector store, or embedding pipeline is needed.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://medium.com/neo4j/your-ai-agent-forgets-everything-so-we-taught-it-to-remember-with-a-graph-7d4c4275fa21>

## Questions this post answers

### How do I add persistent cross-session memory to a Vercel AI SDK agent without running my own database?

Install @neo4j-labs/nams-ai-provider, get a free API key from memory.neo4jlabs.com, and wrap your model with createNamsProvider() using baseProvider and a userId scope. Swapping openai('gpt-5.4-mini') for nams.languageModel('gpt-5.4-mini') is the only code change needed; memory retrieval and persistence then happen automatically inside every model call via a hosted Neo4j Agent Memory Service, with no cluster, vector store, or embedding pipeline to manage.

_daily.dev surfaces packages like this for developers wiring memory into their AI SDK agents._

### Why does tool-based AI agent memory sometimes silently fail to retrieve or store anything?

Tool-exposed memory relies on the model choosing to call query_memory or store_memory, and system instructions telling it to do so are only advisory, not enforced. Models routinely skip these calls and answer straight from the prompt, producing a confidently wrong response with no memory consulted. The enforceQueryMemory() and ensureMemoryStored() hooks fix this by forcing tool calls via prepareStep and onFinish, guaranteeing retrieval within a grace period and persistence after the loop ends.

_developers debugging flaky agent memory can track fixes like this pattern on daily.dev._

### Why would you use a graph database instead of vector search for AI agent memory?

A graph stores memory as typed, connected entities (like Alex [Person] WORKS_AT TechCorp [Organization]) rather than embedded sentences, so queries like 'list everything you know about this user' or 'correct this one detail' become simple graph operations instead of scanning chat logs. Vector search over text can answer what a user said but can't isolate and correct a single fact or show when it learned something, which entity-shaped storage with getEntityHistory() and mergeEntities() supports directly.

_teams comparing memory architectures for AI agents can weigh options like this on daily.dev._

## Similar posts on daily.dev

- [Agent Memory: Why Your AI Has Amnesia and How to Fix It](https://daily.dev/posts/agent-memory-why-your-ai-has-amnesia-and-how-to-fix-it-nkpwfuhgz) · Tech Lead Digest · 1 upvotes · 0 comments
- [Giving Salesforce Agentforce Durable Memory With Neo4j](https://daily.dev/posts/giving-salesforce-agentforce-durable-memory-with-neo4j-trxzimka0) · neo4j · 1 upvotes · 0 comments
- [Top AI Labs Share an Agent Memory Trick Most Miss](https://daily.dev/posts/top-ai-labs-share-an-agent-memory-trick-most-miss-f9zsfcwik) · Daily Dose of Data Science \| Avi Chawla \| Substack · 0 upvotes · 0 comments

---

Tags: [#ai-agents](https://daily.dev/tags/ai-agents), [#typescript](https://daily.dev/tags/typescript), [#neo4j](https://daily.dev/tags/neo4j)

[View this post on daily.dev](https://daily.dev/posts/your-ai-agent-forgets-everything-so-we-taught-it-to-remember-with-a-graph--wocxymt6u)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Your AI Agent Forgets Everything. So We Taught It to Remember — With a Graph.","url":"https://daily.dev/posts/your-ai-agent-forgets-everything-so-we-taught-it-to-remember-with-a-graph--wocxymt6u","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/your-ai-agent-forgets-everything-so-we-taught-it-to-remember-with-a-graph--wocxymt6u"},"datePublished":"2026-09-07T19:30:08.797Z","dateModified":"2026-09-13T19:35:15.075Z","description":"Neo4j Labs introduces @neo4j-labs/nams-ai-provider, a community provider for the Vercel AI SDK that adds persistent, cross-session memory to any model backed...","image":"https://media.daily.dev/image/upload/s--qPvKM23u--/f_auto/v1722860399/public/Placeholder%2009","thumbnailUrl":"https://media.daily.dev/image/upload/s--qPvKM23u--/f_auto/v1722860399/public/Placeholder%2009","isAccessibleForFree":true,"articleSection":"neo4j","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"neo4j","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/a8f15865d92d4c789a415f316dcb81d2","url":"https://daily.dev/sources/neo4j"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/your-ai-agent-forgets-everything-so-we-taught-it-to-remember-with-a-graph--wocxymt6u","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":3},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"ai-agents,typescript,neo4j","timeRequired":"PT19M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"neo4j","item":"https://daily.dev/sources/neo4j"},{"@type":"ListItem","position":3,"name":"Your AI Agent Forgets Everything. So We Taught It to Remember — With a Graph."}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/your-ai-agent-forgets-everything-so-we-taught-it-to-remember-with-a-graph--wocxymt6u#faq","mainEntity":[{"@type":"Question","name":"How do I add persistent cross-session memory to a Vercel AI SDK agent without running my own database?","acceptedAnswer":{"@type":"Answer","text":"Install @neo4j-labs/nams-ai-provider, get a free API key from memory.neo4jlabs.com, and wrap your model with createNamsProvider() using baseProvider and a userId scope. Swapping openai('gpt-5.4-mini') for nams.languageModel('gpt-5.4-mini') is the only code change needed; memory retrieval and persistence then happen automatically inside every model call via a hosted Neo4j Agent Memory Service, with no cluster, vector store, or embedding pipeline to manage. daily.dev surfaces packages like this for developers wiring memory into their AI SDK agents."}},{"@type":"Question","name":"Why does tool-based AI agent memory sometimes silently fail to retrieve or store anything?","acceptedAnswer":{"@type":"Answer","text":"Tool-exposed memory relies on the model choosing to call query_memory or store_memory, and system instructions telling it to do so are only advisory, not enforced. Models routinely skip these calls and answer straight from the prompt, producing a confidently wrong response with no memory consulted. The enforceQueryMemory() and ensureMemoryStored() hooks fix this by forcing tool calls via prepareStep and onFinish, guaranteeing retrieval within a grace period and persistence after the loop ends. developers debugging flaky agent memory can track fixes like this pattern on daily.dev."}},{"@type":"Question","name":"Why would you use a graph database instead of vector search for AI agent memory?","acceptedAnswer":{"@type":"Answer","text":"A graph stores memory as typed, connected entities (like Alex [Person] WORKS_AT TechCorp [Organization]) rather than embedded sentences, so queries like 'list everything you know about this user' or 'correct this one detail' become simple graph operations instead of scanning chat logs. Vector search over text can answer what a user said but can't isolate and correct a single fact or show when it learned something, which entity-shaped storage with getEntityHistory() and mergeEntities() supports directly. teams comparing memory architectures for AI agents can weigh options like this on daily.dev."}}]}
```

