Agents that remember. Context that scales.
Build agents with persistent memory, multi-tier context blocks, tool management, and automatic context optimization.
Everything agents need to remember
Persistent memory that survives across conversations. Agents build knowledge over time.
Persona, human, system, and custom blocks. Each tier has its own retention and priority rules.
Register, update, and manage tools per agent. Fold optimizes tool descriptions in context.
Automatic context optimization keeps agents within token budgets without losing important memory.
Track every code block, document, and structured output your agent produces.
Interactive playground for testing agents, adjusting memory, and debugging conversations.
Create an agent in seconds
Define memory blocks, set a system prompt, and start sending messages.
// Create a stateful agent
const agent = await fold.agents.create({
name: "code-reviewer",
model: "gpt-4o",
systemPrompt: "You are an expert code reviewer...",
memory: {
persona: "Senior engineer who values clean code",
blocks: [
{ type: "system", content: "Always check for security issues" },
{ type: "human", content: "Prefers TypeScript and functional patterns" },
],
},
});
// Send a message — agent remembers previous conversations
const response = await fold.agents.message(agent.id, {
content: "Review this pull request for security issues",
attachments: [{ type: "code", content: prCode }],
});Four tiers of memory
Each memory tier has its own priority and retention rules. Fold automatically manages what stays in context.
Defines the agent's identity, expertise, and communication style. Highest priority — always included in context.
Stores information about the user: preferences, past interactions, and working context. Updated automatically.
Operational instructions and constraints. Guidelines, safety rules, and behavioral boundaries.
Application-specific blocks for domain knowledge, project context, or any structured data your agent needs.
Streaming, tools, and analytics
Stream responses, manage tools, and monitor context optimization in real time.
// Stream responses from your agent
const stream = await fold.agents.stream(agent.id, {
content: "Explain the architecture of this codebase",
});
for await (const chunk of stream) {
process.stdout.write(chunk.text);
}
// Add tools to your agent
await fold.agents.addTool(agent.id, {
name: "search_code",
description: "Search the codebase for relevant files",
parameters: { query: { type: "string" } },
});
// Check context optimization stats
const stats = await fold.agents.stats(agent.id);
console.log(stats.optimization);
// { tokensUsed: 12000, tokensSaved: 34000, savingsPercent: 74 }