Persistent Agent Memory, Profiles, Namespaces, and Recall
How managed agent memory stores facts across conversations: profiles, ingest, remember, recall, APIs, limits, and safe usage patterns.
This page summarizes Cloudflare Agent Memory documentation: a managed service for persistent, scoped memory so agents can remember users, organizations, and domain context across conversations without building your own extraction, storage, search, and summarization pipeline.
Persistent, scoped memory for agents that need to remember users, organizations, and domain-specific context across conversations.
— Cloudflare, Agent Memory
Agent Memory: what it is and when to use it
Section titled “Agent Memory: what it is and when to use it”Agent Memory gives agents durable memory across conversations. You can ingest conversations so the service extracts memories automatically, or remember information explicitly when your application already knows what to store. Typical uses include user preferences, company operating rules, support history, project state, or the state of a specific object (Agent Memory).
The service provides:
- Isolated profiles for users, agents, tenants, teams, or application entities
- Namespaces to separate applications, environments, or memory layers
- Automatic extraction of facts, events, instructions, and tasks from conversations
- APIs to add, list, recall, and delete memories
- Profile summaries to inspect what is stored (Features)
Workers access Agent Memory through an agent_memory binding; external services use the HTTP API. For agent apps on Cloudflare, see also Agents and Get started.
How this differs from conversation state alone
Section titled “How this differs from conversation state alone”For Cloudflare agents, a memory system maintains context and tracks task progress alongside the decision engine and tools (What are agents?). Agent Memory is the managed layer for long-term knowledge extracted from past sessions—not a substitute for the current prompt or in-session state (Harnesses: Sessions stores conversation context across turns; Agent Memory persists structured knowledge beyond that).
Memory types: facts, events, instructions, and tasks
Section titled “Memory types: facts, events, instructions, and tasks”Agent Memory classifies every extracted memory into one of four types (How Agent Memory works):
| Type | Role | Behavior over time |
|---|---|---|
| Facts | Stable knowledge (preferences, identities, goals) | Evolve via supersession: newer facts on the same topic replace older ones in recall; history is kept |
| Events | Completed actions at a point in time (deployments, decisions) | Accumulate; they do not conflict |
| Instructions | Reusable procedures and conventions | Like facts, support supersession when updated |
| Tasks | Short-lived, session-scoped follow-ups | Deprioritized after the session ends |
Agent Memory classifies every extracted memory into one of four types: Facts — Stable knowledge… Events — Completed actions… Instructions — Reusable procedures… Tasks — Short-lived, session-scoped items…
— Cloudflare, How Agent Memory works
Namespaces and profiles: how to isolate memory per user or tenant
Section titled “Namespaces and profiles: how to isolate memory per user or tenant”Agent Memory uses a two-level isolation model: namespaces define memory domains; profiles are isolated stores per entity (Namespaces and profiles).
Agent Memory uses a two-level isolation model: namespaces define memory domains, and profiles provide isolated memory stores for individual users, agents, teams, tenants, or application objects.
— Cloudflare, Namespaces and profiles
Namespace — top-level container for an application or environment (e.g. prod vs staging, or separate apps). Profile — one isolated memory store (e.g. per user). Scoping is strictly namespace → profile → memory; a recall() on one profile never returns another profile’s data.
Namespace: my-assistant-prod Profile: alice → Memories, Messages Profile: bob → Memories, MessagesCreate a namespace with Wrangler (name up to 32 characters; used in bindings and API calls):
npx wrangler agent-memory namespace create my-agentSee Get started: Create a namespace and HTTP API: Create a namespace.
Profiles are created automatically on first write (HTTP API: Profiles). In Workers, getProfile(profileName) also creates a profile if missing (profile name max 100 characters) (Workers API: getProfile).
ingest(), remember(), and recall(): when to call each API
Section titled “ingest(), remember(), and recall(): when to call each API”Three operations cover most applications (Get started, Workers API):
| Method | Use when |
|---|---|
ingest() |
You have conversation messages and want automatic extraction of durable memories |
remember() |
Your agent or app already knows the exact text to store |
recall() |
The LLM needs relevant memory not present in the current prompt or session |
Use
recall()when the model needs relevant memory to answer or act. Useingest()when you have conversation messages and want Agent Memory to extract durable memories automatically. Useremember()when your agent already knows the exact memory to store.— Cloudflare, Get started
Automatic ingestion is enough for most apps. Explicit remember() via an LLM-callable write tool is optional; if you add one, define in the system prompt what is worth remembering and when to confirm—automatic ingestion is often simpler and safer (Get started: Store explicit memories).
How ingestion extracts and stores memories
Section titled “How ingestion extracts and stores memories”When you call ingest(), processing runs through extraction, classification, deduplication, and storage (How Agent Memory works):
- Extraction — identifies discrete memorable items with summaries and supporting content
- Classification — assigns type, topic key, keywords, and search queries
- Deduplication — facts and instructions with the same topic key supersede older versions
- Storage — durable storage with full-text indexes; non-task memories also get vector embeddings
Raw conversation messages are stored verbatim alongside extracted memories.
ingest() is idempotent: messages are content-addressed; duplicate sends do not duplicate memories; sessions are deterministic from content if you omit sessionId (Idempotency, Workers API: ingest).
How recall() searches and answers
Section titled “How recall() searches and answers”recall(query, options?) runs query analysis, parallel retrieval (keywords, topic keys, vectors, raw messages), scoring, ranking, and synthesis into a natural-language answer grounded in stored content (How recall works).
If no memories match the query, recall() returns an empty answer rather than hallucinating a response.
— Cloudflare, How recall works
Workers options include thinkingLevel (low | medium | high) for retrieval breadth and responseLength (short | medium | long) for answer verbosity (Workers API: recall). Query size is limited to 1 KB UTF-8 (Limits).
Workers binding vs HTTP API: how to connect your app
Section titled “Workers binding vs HTTP API: how to connect your app”| Access path | Best for |
|---|---|
Workers API via agent_memory binding |
Agents and Workers on Cloudflare |
| HTTP API | Services that call the Cloudflare API directly |
Overview: API. Profile operations include ingest, remember, recall, list, get, and getSummary on both surfaces.
Inspect stored knowledge with getSummary(), which returns structured Markdown for the profile (Workers API: getSummary, HTTP API: Get a summary). list() returns paginated entries without full content; use get(memoryId) for content (Workers API: list).
recall() as an LLM tool: wiring Agent Memory to the LLM
Section titled “recall() as an LLM tool: wiring Agent Memory to the LLM”The LLM does not use memory automatically because a binding exists. Expose recall through a tool and instruct the LLM when to call it (Get started: Add memory recall as a tool).
With the Agents SDK Session API, a searchable context provider’s search() becomes a search_context tool. The system prompt should state when to search (prior sessions, preferences, project state), to phrase searches as concise topics—not questions—and to treat recalled content as helpful context, not guaranteed truth for irreversible actions (Get started).
Conceptual flow:
- Create namespace and bind
MEMORYin the Worker (Workers API) getProfile()for the end-user or entity profile name- Batch
ingest()at checkpoints; optionalremember()for explicit facts - Tool handler calls
profile.recall(query, { responseLength: "short" }) - Periodically or for debugging, call
getSummary()
See the full pattern in Get started and Concepts.
Platform limits and validation constraints
Section titled “Platform limits and validation constraints”| Feature | Limit |
|---|---|
Messages per ingest() call |
500 |
| Message content size | 32 KB (32,768 bytes UTF-8) |
| Recall query size | 1 KB (1,024 bytes UTF-8) |
| Session ID length | 64 characters |
| Profile name length | 100 characters |
| Namespace name length | 32 characters |
| List API page size | 1 to 1,000 (default: 20) |
Source: Limits. Workers list() default limit is 20, max 500 per page (Workers API: list).
Common mistakes when using Agent Memory
Section titled “Common mistakes when using Agent Memory”- Ingesting every turn — increases cost and noise; batch at idle or compaction instead (Get started).
- No recall tool or policy — binding alone does not give the model long-term context (Get started).
- Wrong profile — cross-user leakage is prevented only if each user maps to the correct profile in a consistent namespace (Namespaces and profiles).
- Treating empty
recall()as fabrication license — empty answers mean no match; do not invent memories (How recall works). - Re-ingesting without understanding idempotency — safe for duplicates, but supersession can update facts when topic keys collide (Idempotency).
- Giving the LLM unrestricted
remember()— prefer ingestion or guarded write tools with confirmation (Get started).
How to check this on your site
Section titled “How to check this on your site”-
Create or confirm an Agent Memory namespace with Wrangler or the HTTP API Create a namespace flow, and verify the name matches your Worker
agent_memorybinding (Get started). -
Send a test conversation through
ingest()(Workers or HTTP ingest), staying within Limits (≤500 messages, ≤32 KB per message). -
Call
getSummary()on the same profile and confirm extracted facts, events, instructions, or tasks appear as expected (HTTP API: Get a summary). -
Run
recall()with a query that should hit stored preferences or events; confirm a non-emptyanswerwhen matches exist and an empty answer when none do (HTTP API: Recall memories, How recall works). -
You can check automatically in Answerwell (our tool): https://answerwell.org/workspace
Report an error or ask a question
Section titled “Report an error or ask a question”If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact statement you are asking about, and we will correct or clarify it.