"Cloudflare Agent Memory," announced by Cloudflare on April 30, 2026, is a new service that provides managed persistent memory for AI agents. Cross-conversation context retention, user-specific memory, and memory retention lifespan design across contract periods—challenges that previously caused friction in every client project integrating AI agents into business systems—can now potentially be implemented without running your own storage infrastructure.
Client projects seeking to incorporate AI agents into business systems have grown noticeably since the second half of 2025. However, numerous projects stall due to issues like "the PoC generated great excitement, but in production, it asks for the exact same information in every conversation," making persistent memory architecture the primary battleground in custom AI development. This article organizes how to incorporate Cloudflare Agent Memory into real projects, focusing on memory tiering and scope design.
Why "persistent memory" is the core challenge for business system AI
Typical failures when integrating AI agents into enterprise systems fall into three categories:
| Pitfall | Symptom | Consequence in client projects |
|---|---|---|
| Forgets across conversations | Client mentions "Regarding what I asked last time..." but agent has zero context | Complaints leading to rework |
| Stuffing all memory in | Context bloat leads to degraded accuracy and higher costs | Monthly running costs triple expectations |
| No memory lifespan design | Statements by departed employees persist indefinitely | Personal data and compliance violations |
To avoid these pitfalls, you must deliberately architect separate tiers for "short-term memory," "medium-term memory," "long-term memory," and "organizational knowledge." Historically, combining Pinecone, Redis, and Postgres in-house was the standard practice. Cloudflare Agent Memory's primary differentiator is handling all four memory tiers through a single unified API.
We previously covered the complexities of memory design in production in our article on Sandbox Memory in OpenAI Agents SDK v2, and Cloudflare has effectively moved to "absorb that complexity at a lower infrastructure layer."
Key features of Cloudflare Agent Memory
From the official announcement, we summarize four critical features for custom development.
| Features | Overview | Use cases in client projects |
|---|---|---|
| Scoped Memory | Isolates memory by user, session, or organization | Memory architecture for multi-tenant SaaS |
| TTL & Retention Policy | Retention periods configurable per memory entry | Compliance with personal data deletion mandates |
| Semantic Recall | Retrieves relevant memories via vector search | RAG and FAQ augmentation |
| Workers AI integration | Low-latency access from Workers | Edge AI agents |
In particular, having Retention Policy configurable at the API level is substantial for business systems subject to the Act on the Protection of Personal Information, GDPR, or the revised Telecommunications Business Act. It eliminates the need to write custom scripts to delete data after one year.
Four-tier memory architecture for custom integrations
This is our four-tier architecture designed around Cloudflare Agent Memory when integrating AI agents into business systems.
[Layer 1] 会話バッファ(短期) 直近 10〜20 ターン、TTL: 30 分
└ Cloudflare Agent Memory: scope=session
[Layer 2] ユーザー記憶(中期) 好み・口調・履歴サマリ、TTL: 90 日
└ Cloudflare Agent Memory: scope=user
[Layer 3] 組織記憶(長期) 社内ナレッジ・FAQ、TTL: 無期限(手動更新)
└ Cloudflare Agent Memory: scope=organization
[Layer 4] 監査ログ(永続) 誰が何を聞いたか、TTL: 7 年
└ Cloudflare R2 / D1(独立管理)
The key point is that Layer 4 audit logs alone should never be stored in Agent Memory. Audit requirements cannot tolerate accidental deletions or overwrite bugs by AI agents, so they must be maintained in independent, persistent storage.
Implementation sample — Workers + Agent Memory
A minimal agent implementation example.
// src/agent.ts
import { AgentMemory } from '@cloudflare/agent-memory';
import Anthropic from '@anthropic-ai/sdk';
export default {
async fetch(req: Request, env: Env) {
const { userId, sessionId, message } = await req.json();
const memory = new AgentMemory(env.AGENT_MEMORY);
// 短期:直近の会話を取得
const recent = await memory.recall({
scope: { sessionId },
limit: 20,
});
// 中期:このユーザーの記憶を意味検索で引く
const userMemories = await memory.semanticRecall({
scope: { userId },
query: message,
limit: 5,
});
// 長期:組織のFAQから関連を引く
const orgKnowledge = await memory.semanticRecall({
scope: { orgId: 'gleamhub' },
query: message,
limit: 3,
});
const client = new Anthropic({ apiKey: env.ANTHROPIC_API_KEY });
const result = await client.messages.create({
model: 'claude-opus-4-7',
max_tokens: 1024,
system: buildSystem(orgKnowledge, userMemories),
messages: [...recent, { role: 'user', content: message }],
});
// 会話を Layer 1 に書き戻し
await memory.remember({
scope: { sessionId },
ttl: 1800,
content: { user: message, assistant: result.content[0].text },
});
return Response.json({ reply: result.content[0].text });
}
};
The crucial element of this code is to "vary the recall API scope according to each memory layer." Incorrect scoping can cause user A's inputs to leak to user B; restricting scope via TypeScript types is an effective technique to prevent such incidents.
Patterns for integration into existing business systems
When retrofitting AI agents onto existing legacy core systems, three patterns are practical.
| Variant | Overview | Applicable project type |
|---|---|---|
| Integration via MCP | Turn existing APIs into MCP servers and link with Agent Memory | AI frontends for internal core systems and ERPs |
| Edge sidecar | Deploy agents exclusively to frontend customer inquiry touchpoints | E-commerce sites and support chats |
| ETL + nightly summaries | Sync business DBs to Agent Memory via nightly batch jobs | Customer analytics and CRM AI assistance |
Integration via MCP extends the Design Patterns for Turning Existing APIs into MCP Servers, fitting cleanly when you separate Agent Memory as the "conversation and memory layer" and MCP as the "business data layer."
Running costs — Usage-based pricing of Agent Memory
Cloudflare Agent Memory's pay-as-you-go pricing scales on request and storage fees like Workers and R2, and is expected to fall within tens of thousands to hundreds of thousands of yen monthly from PoCs to mid-sized production environments.
The baseline experience of "the AI remembering past conversations" delivers immense value in both business systems and customer experiences, making it straightforward to justify ROI. However, memory is rarely a standalone drop-in; the pragmatic approach in 2026 is to pair it with the evaluation design covered in Custom Development Patterns for Setting Up AI Evals First and the governance provided by the TTL and scoping designs described here.
Five design pitfalls
| Pitfall | Symptom | Measure |
|---|---|---|
| Writing all memory to user scope | Excessive personal data; handling deletion requests becomes difficult | Keep non-essentials confined to session scope |
| Leaving TTL unset | Outdated info causes hallucinations; inflated costs | Always pass TTL in API calls |
| Exposing semantic recall directly | Irrelevant memories pollute context and degrade accuracy | Apply score thresholds and reranking |
| Storing audit logs solely in Agent Memory | Vulnerable to accidental deletion and tampering | Duplicate to R2 with tamper-detection hashing |
| Vendor lock-in | Difficult to migrate or exit | Introduce an abstraction layer (detailed below) |
In particular, mitigating vendor lock-in is critical in custom development; our company always introduces a MemoryAdapter interface to ensure Cloudflare Agent Memory, Redis, or self-hosted Postgres can be swapped out later.
Conclusion — Making "AI with memory" a standard specification in custom development
The launch of Cloudflare Agent Memory represents a major operational relief for custom development projects embedding AI agents into business systems, as you no longer need to manage memory infrastructure yourself. On the flip side, mistakes in scope and TTL design directly cause personal data incidents, making initial architectural design more critical than ever.
How many tiers to split memory into, how far to push retention policies to the API side, and where to draw the boundary for keeping audit logs outside Agent Memory—the answers to the considerations raised in this article vary with each system's architecture, regulatory retention obligations, and industry audit requirements. Because this domain does not fit a rigid template, we tailor architectures after reviewing your existing systems and requirements. If you are at a stage where you want to integrate AI but are stuck on conversation memory design or personal data compliance, or want to add a natural language interface to an existing core system, please reach out via our contact form.








