Agent Persistence
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/agent-persistence
cd agent-persistence
npm install
Or Install Package Only
If you prefer to build from scratch:
npm install @astreus-ai/astreus
Environment Setup
# .env
OPENAI_API_KEY=sk-your-openai-api-key-here
DB_URL=sqlite://./astreus.db
Agent 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 15th
Running the Example
If you cloned the repository:
npm run dev
Repository
The complete example is available on GitHub: astreus-ai/agent-persistence
How is this guide?