Memory API
Access and manage agent memory programmatically.
Get Memory Overview
bash
GET /api/agents/:name/memoryResponse
json
{
"short_term": {
"session_id": "sess_abc123",
"entries_count": 25,
"last_updated": "2024-01-15T12:00:00Z"
},
"long_term": {
"entries_count": 150,
"size_kb": 45.2
},
"swarm": {
"shared_facts": 12
}
}Get Short-Term Memory
bash
GET /api/agents/:name/memory/stmQuery Parameters
| Parameter | Default | Description |
|---|---|---|
limit | 50 | Max entries |
session | current | Session ID |
Response
json
{
"session_id": "sess_abc123",
"entries": [
{
"id": 1,
"role": "user",
"content": "Hello!",
"timestamp": "2024-01-15T12:00:00Z"
},
{
"id": 2,
"role": "assistant",
"content": "Hi! How can I help?",
"timestamp": "2024-01-15T12:00:02Z"
}
]
}Get Current Context
bash
GET /api/agents/:name/memory/currentReturns the human-readable context file (current.md).
Response
json
{
"content": "# Agent Short-Term Memory Context\n\n## Session: sess_abc123\n\n### Recent Messages\n\n**User:** Hello!\n\n**Agent:** Hi! How can I help?\n"
}Search Long-Term Memory
bash
POST /api/agents/:name/memory/ltm/searchRequest
json
{
"query": "API rate limit",
"limit": 5,
"threshold": 0.7
}Parameters
| Field | Type | Required | Description |
|---|---|---|---|
query | string | Yes | Search query |
limit | number | No | Max results (default: 10) |
threshold | number | No | Similarity threshold (0-1) |
Response
json
{
"results": [
{
"id": 42,
"content": "The API rate limit is 1000 requests per minute",
"similarity": 0.92,
"created_at": "2024-01-10T10:00:00Z",
"source": "conversation"
},
{
"id": 38,
"content": "Rate limiting may occur during high traffic",
"similarity": 0.78,
"created_at": "2024-01-08T15:30:00Z",
"source": "announcement"
}
]
}Add to Long-Term Memory
bash
POST /api/agents/:name/memory/ltmRequest
json
{
"content": "Project deadline is February 15th, 2024",
"metadata": {
"source": "user_input",
"category": "important"
}
}Response
json
{
"success": true,
"id": 151,
"message": "Memory added"
}Get Long-Term Memory Entry
bash
GET /api/agents/:name/memory/ltm/:idResponse
json
{
"id": 42,
"content": "The API rate limit is 1000 requests per minute",
"embedding_dimensions": 1536,
"metadata": {
"source": "conversation"
},
"created_at": "2024-01-10T10:00:00Z"
}Delete Long-Term Memory Entry
bash
DELETE /api/agents/:name/memory/ltm/:idResponse
json
{
"success": true,
"message": "Memory entry deleted"
}Clear Short-Term Memory
bash
DELETE /api/agents/:name/memory/stmResponse
json
{
"success": true,
"message": "Short-term memory cleared"
}Clear All Memory
bash
DELETE /api/agents/:name/memoryWARNING
This permanently deletes all memory (STM and LTM).
Response
json
{
"success": true,
"message": "All memory cleared"
}Swarm Memory
Get Swarm Facts
bash
GET /api/swarm/factsResponse
json
{
"facts": [
{
"id": 1,
"source_agent": "monitor",
"content": "Production API is experiencing issues",
"created_at": "2024-01-15T10:00:00Z"
}
]
}Search Swarm
bash
POST /api/swarm/searchRequest
json
{
"query": "production issues",
"limit": 10
}Add Swarm Fact
bash
POST /api/swarm/factsRequest
json
{
"content": "Deployment scheduled for 3pm",
"source_agent": "admin",
"ttl_seconds": 3600
}Clear Swarm
bash
DELETE /api/swarm/factsScheduled Jobs
List Scheduled Jobs
bash
GET /api/agents/:name/schedulesResponse
json
{
"schedules": [
{
"name": "daily_report",
"cron": "0 9 * * *",
"prompt": "Generate and send daily report",
"next_run": "2024-01-16T09:00:00Z",
"created_at": "2024-01-15T10:00:00Z"
}
]
}Create Scheduled Job
bash
POST /api/agents/:name/schedulesRequest
json
{
"name": "hourly_check",
"cron": "0 * * * *",
"prompt": "Check server health and alert if issues"
}Delete Scheduled Job
bash
DELETE /api/agents/:name/schedules/:name