Memory-augmented chat using the Vercel AI SDK and the
agentMemoryMiddleware from @neo4j-labs/agent-memory/middleware/vercel-ai.
- Wiring
agentMemoryMiddlewarearound anopenai("gpt-4o-mini")model viaexperimental_wrapLanguageModel. - Three-tier context (reflections + observations + recent messages) prepended to every model call.
- Automatic persistence of both the user input and the assistant response.
cp .env.example .env
# edit .env: set MEMORY_API_KEY and OPENAI_API_KEY
npm install
npm startYou'll see a three-turn chat where the assistant remembers context from prior turns. Re-run the script to see context recalled across sessions (the conversation id is printed at the end of each run).