Long-term agent memory with three Jev gates. Keep durable facts, recall what fits a token budget, and evict what went stale. Nothing is rewritten.
Requirements, wiring steps, and what this pattern adds to your project.
Pick how you want to pull this pattern in. Then wire env vars and routes the same way.
Download → Next.js app
Use Download → Next.js app in the preview toolbar. You get a zip scaffold (Pro downloads rewrite preview `/view/.../api/*` paths to `/api/*` automatically).
Extract the zip and install dependencies
Unzip the archive, then run `pnpm install` (or npm / yarn) in the project folder.
Fill .env.local
The download includes .env.local placeholders when needed. Add real values for: AI_GATEWAY_API_KEY.
Customize the agent and tool files
Adapt prompts, tools, and stop conditions in the generated project for your product.
Run the app and open the pattern route
Run `pnpm dev`, open the setup/checklist page if present, then navigate to the generated pattern route and verify responses.
AI_GATEWAY_API_KEYGet keyAI SDK APIs
experimental_evaluateProviders
External services
app/page.tsxapp/layout.tsxapp/api/memory/route.tscomponents/memory-demo.tsxcomponents/memory-list.tsxcomponents/memory-steps.tsxcomponents/info-tip.tsxcomponents/typesafe-ai.tsxhooks/use-memory.tslib/seed-memories.tslib/memory-config.tslib/memory-policy.tslib/rate-limit.tslib/request-utils.tsREADME.mdnpm packages
7
Registry components
lib/memory-policy.tsevaluateTurn runs jev-memory remember() into an empty inMemoryStore and select() over the sent memories in parallel. evaluateCompact runs compact() against recent messages. Memory text is never rewritten. Do not call Jev from unit tests. Pass Experimental_EvaluationMockModelV4 as model and stub AI_GATEWAY_API_KEY.
lib/memory-config.tsWRITE_THRESHOLD and EVICT_THRESHOLD are 0.60. TOKEN_BUDGET is 48 estimated tokens. Request limits live here too.
hooks/use-memory.tsThe browser owns the memory list and sends it on each request. Pin, unpin, forget, and reset stay local and never call Jev.
memory/route.tsRate-limited Gateway boundary for typesafe-ai/jev. Validates memories and messages, then returns a TurnDecision or CompactDecision. Swap inMemoryStore for a persistent MemoryStore in production.
Long-term agent memory with three Jev gates. Keep durable facts, recall what fits a token budget, and evict what went stale. Nothing is rewritten.
Requirements, wiring steps, and what this pattern adds to your project.
Pick how you want to pull this pattern in. Then wire env vars and routes the same way.
Download → Next.js app
Use Download → Next.js app in the preview toolbar. You get a zip scaffold (Pro downloads rewrite preview `/view/.../api/*` paths to `/api/*` automatically).
Extract the zip and install dependencies
Unzip the archive, then run `pnpm install` (or npm / yarn) in the project folder.
Fill .env.local
The download includes .env.local placeholders when needed. Add real values for: AI_GATEWAY_API_KEY.
Customize the agent and tool files
Adapt prompts, tools, and stop conditions in the generated project for your product.
Run the app and open the pattern route
Run `pnpm dev`, open the setup/checklist page if present, then navigate to the generated pattern route and verify responses.
AI_GATEWAY_API_KEYGet keyAI SDK APIs
experimental_evaluateProviders
External services
app/page.tsxapp/layout.tsxapp/api/memory/route.tscomponents/memory-demo.tsxcomponents/memory-list.tsxcomponents/memory-steps.tsxcomponents/info-tip.tsxcomponents/typesafe-ai.tsxhooks/use-memory.tslib/seed-memories.tslib/memory-config.tslib/memory-policy.tslib/rate-limit.tslib/request-utils.tsREADME.mdnpm packages
7
Registry components
lib/memory-policy.tsevaluateTurn runs jev-memory remember() into an empty inMemoryStore and select() over the sent memories in parallel. evaluateCompact runs compact() against recent messages. Memory text is never rewritten. Do not call Jev from unit tests. Pass Experimental_EvaluationMockModelV4 as model and stub AI_GATEWAY_API_KEY.
lib/memory-config.tsWRITE_THRESHOLD and EVICT_THRESHOLD are 0.60. TOKEN_BUDGET is 48 estimated tokens. Request limits live here too.
hooks/use-memory.tsThe browser owns the memory list and sends it on each request. Pin, unpin, forget, and reset stay local and never call Jev.
memory/route.tsRate-limited Gateway boundary for typesafe-ai/jev. Validates memories and messages, then returns a TurnDecision or CompactDecision. Swap inMemoryStore for a persistent MemoryStore in production.
Loading preview…
Early-bird pricing — limited time


Open on desktop for the interactive preview.
Long-term agent memory with three Jev gates. Keep durable facts, recall what fits a token budget, and evict what went stale. Nothing is rewritten.
Loading preview…
Early-bird pricing — limited time


Open on desktop for the interactive preview.
Long-term agent memory with three Jev gates. Keep durable facts, recall what fits a token budget, and evict what went stale. Nothing is rewritten.