Agent Persistence
Save and load agents from database for reusability. Learn the setup patterns, APIs, and practical examples needed to build reliable Astreus agent systems.
Save and load agents from database for reusability.
Quick Start
Clone the Complete Example
The easiest way to get started is to clone the complete example repository:
git clone https://github.com/astreus-ai/examples
cd examples/agent-persistence
npm installOr Install Package Only
If you prefer to build from scratch:
npm install @astreus-ai/astreusEnvironment Setup
# .env
OPENAI_API_KEY=sk-your-openai-api-key-here
DB_URL=sqlite://./astreus.dbAgent Persistence
import { Agent } from '@astreus-ai/astreus';
// Create and save an agent
const agent = await Agent.create({
name: 'ProjectAssistant',
model: 'gpt-4o',
memory: true,
systemPrompt: 'You are a project management assistant.'
});
// Use the agent
await agent.ask("Remember that our project deadline is March 15th");
// Later, load the same agent by name
const loadedAgent = await Agent.findByName('ProjectAssistant');
const response = await loadedAgent?.ask("What is our project deadline?");
console.log(response); // Should remember March 15thRunning the Example
If you cloned the repository:
npm run devRepository
The complete example is available on GitHub: examples/agent-persistence
Last updated: June 7, 2026
In this section
Your First Agent
Create your first AI agent with Astreus framework. Learn the setup patterns, APIs, and practical examples needed to build reliable Astreus agent systems.
Agent with Memory
Build agents with persistent memory capabilities. Learn the setup patterns, APIs, and practical examples needed to build reliable Astreus agent systems.
Agent with Knowledge
Create agents with knowledge base capabilities for enhanced information retrieval. Learn the setup patterns, APIs, and practical examples needed to build...
Agent with Vision
Create agents capable of processing and analyzing images. Learn the setup patterns, APIs, and practical examples needed to build reliable Astreus agent systems.