Memory Overview
AgentForge's memory layer — working, session, and long-term memory for agents.
| Tier | Scope | Persistence | Implementation |
|---|
| Working | Current step | Ephemeral | Conversation context |
| Session | Single run | Task-scoped | State store |
| Long-term | Cross-session | Durable | PgVector / In-memory |
import { defineAgent, InMemoryMemoryStore } from '@ahzan-agentforge/core';
const agent = defineAgent({
name: 'remembering-agent',
description: 'Agent with memory',
tools: [myTool],
llm,
systemPrompt: '...',
memory: {
store: new InMemoryMemoryStore(),
config: {
autoCapture: true,
retrieveBeforeStep: true,
maxRetrieved: 5,
},
},
});
// Store a memory
await agent.remember('Customer prefers email communication', {
type: 'preference',
customerId: 'cust_123',
});
// Recall memories
const results = await agent.recall('communication preferences', {
customerId: 'cust_123',
});
| Store | Backend | Best For |
|---|
InMemoryMemoryStore | In-process | Development, testing |
PgVectorMemoryStore | PostgreSQL + pgvector | Production |