The Agent Memory System uses a hybrid architecture combining:
- PostgreSQL for structured data and metrics
- ChromaDB for semantic similarity search
- Time-based queries ("tasks from last week")
- Exact filters (status, agent, project)
- Aggregations (counts, averages, success rates)
- Relational joins (tasks → executions → agents)
- ACID guarantees
- Semantic similarity (find "related" tasks without exact keywords)
- Fast vector search
- Metadata filtering
- Scales to millions of embeddings
User Input → Embed Query → ChromaDB (similarity) + Postgres (stats)
↓
Smart Routing (best agent based on history)
↓
Execute with Context (past solutions, patterns)
↓
Store Results (both DBs updated)
See schema.md for full SQL schema.
Key tables:
tasks- Task metadataexecutions- Execution records with outcomestechniques- Solutions/approaches usedagent_stats- Materialized performance metrics
Uses OpenAI text-embedding-3-small (1536 dimensions):
- Cost: ~$0.0001 per 1k tokens
- Can batch process for efficiency
- Alternative: local sentence-transformers
- Task arrives
- Query similar historical tasks (ChromaDB)
- Get agent performance stats (Postgres)
- Route to best agent with confidence score
- Inject context from similar successful tasks
- Execute
- Store outcome in both DBs
- Update agent stats (auto-trigger)
After N executions:
- More data = better routing
- Pattern recognition improves
- Time estimates become accurate
- Can explain decisions with data
- Embedding: ~100ms per task
- ChromaDB query: <50ms for top-10
- Postgres aggregation: <10ms
- Total overhead: ~150ms per task
Scales to:
- 1M+ tasks (tested)
- 100+ agents
- Sub-second query times
All local deployment:
- No external calls (except OpenAI embeddings)
- Data stays in your containers
- Can use local embeddings for full offline mode