Persistent agent daemon — systemd for AI agents
Project description
AgentRuntime — systemd for AI Agents
A persistent agent daemon that manages AI agent processes, serializes state, and resumes sessions. Think of it as systemd for AI agents — start, pause, resume, and checkpoint agent sessions with full state persistence.
Architecture
┌─────────────┐ ┌──────────────────┐ ┌────────────────┐
│ CLI │────▶│ FastAPI Server │────▶│ SessionManager│
│ (agentd) │ │ (port 8721) │ │ │
└─────────────┘ └──────────────────┘ └───────┬────────┘
│
┌─────────────────────────┼─────────────────────┐
│ │ │
┌────────▼────────┐ ┌────────▼────────┐ ┌───────▼──────┐
│ StateSerializer │ │ MemoryStore │ │ Daemon │
│ (SQLite) │ │ (Short+Long) │ │ (Heartbeat) │
└─────────────────┘ └─────────────────┘ └──────────────┘
Features
- Session Lifecycle: Create, start, pause, resume, stop agent sessions
- State Persistence: Full session state serialized to SQLite
- Checkpoints: Save and restore complete state at any point
- Memory Management: Short-term (conversation context) and long-term (key-value with semantic search)
- Memory Consolidation: Auto-summarize old short-term memories
- Auto-Checkpoint: Configurable interval for automatic state snapshots
- Graceful Shutdown: State preservation on daemon stop
- Session Timeout: Automatic cleanup of stopped sessions
- REST API: Full HTTP API via FastAPI
- CLI: Command-line interface for all operations
- Docker: Production-ready container image
Quick Start
Install
pip install -e .
Start the Daemon
agentd start --port 8721
Create a Session
agentd create --name "my-agent" --model fableforge-14b --system-prompt "You are a helpful assistant"
List Sessions
agentd list
Resume a Session
agentd resume <session-id> --checkpoint-id <checkpoint-id>
Stop the Daemon
agentd stop
API Reference
POST /sessions
Create a new session.
{
"name": "my-agent",
"model": "fableforge-14b",
"system_prompt": "You are a helpful assistant.",
"tools": ["search", "calculator"]
}
GET /sessions
List all sessions.
GET /sessions/{id}
Get session state.
POST /sessions/{id}/start
Start a session (begins heartbeat and auto-checkpoint).
POST /sessions/{id}/pause
Pause a running session (creates checkpoint, cancels heartbeat).
POST /sessions/{id}/resume
Resume a paused or stopped session.
{
"session_id": "abc123",
"checkpoint_id": "cp_456"
}
POST /sessions/{id}/stop
Stop a session (creates final checkpoint).
GET /sessions/{id}/memory
List memory keys or retrieve specific key: ?key=my_key
POST /sessions/{id}/memory
Store a memory entry.
{
"key": "user_preference",
"value": {"theme": "dark", "language": "en"}
}
GET /sessions/{id}/checkpoints
List all checkpoints for a session.
POST /sessions/{id}/checkpoints
Create a checkpoint. Query param: ?label=my-checkpoint
GET /health
Daemon health status.
Session States
CREATED ──▶ RUNNING ──◆──▶ PAUSED ──▶ RUNNING
│ │ │
│ └──▶ STOPPED
└──▶ ERROR
Memory Architecture
Short-Term Memory
- Last N messages per session (default 50)
- Automatic pruning when window exceeded
- Used for conversation context
Long-Term Memory
- Key-value store with optional embeddings
- Cosine similarity semantic search
- Persistent across sessions
- Consolidation: summarizes old short-term into long-term
Consolidation
When short-term memory exceeds a threshold, the daemon:
- Summarizes the recent conversation
- Stores the summary in long-term memory
- Prunes old short-term entries
Configuration
| Env Variable | Default | Description |
|---|---|---|
AGENT_RUNTIME_DB |
~/.agent_runtime/state.db |
SQLite database path |
AGENT_RUNTIME_MEMORY_DB |
~/.agent_runtime/memory.db |
Memory database path |
AGENT_RUNTIME_PORT |
8721 |
HTTP server port |
AGENT_RUNTIME_HOST |
0.0.0.0 |
HTTP server bind address |
AGENT_RUNTIME_CHECKPOINT_INTERVAL |
60 |
Auto-checkpoint interval (seconds) |
AGENT_RUNTIME_SESSION_TIMEOUT |
3600 |
Session timeout (seconds) |
Docker
docker build -f docker/Dockerfile -t agent-runtime .
docker run -p 8721:8721 -v agent_data:/root/.agent_runtime agent-runtime
Testing
pip install -e ".[dev]"
pytest tests/ -v
Project Structure
agent-runtime/
├── pyproject.toml
├── docker/
│ └── Dockerfile
├── src/
│ └── agent_runtime/
│ ├── __init__.py
│ ├── models.py # Pydantic models
│ ├── state_serializer.py # SQLite state persistence
│ ├── memory_store.py # Short/long-term memory
│ ├── session_manager.py # Session lifecycle
│ ├── daemon.py # Background daemon process
│ ├── server.py # FastAPI HTTP server
│ └── cli.py # CLI interface
├── tests/
│ └── test_state_serializer.py
└── README.md
License
MIT
Ecosystem
Part of the FableForge ecosystem — 21 open-source projects built from 210K real agent traces:
| Project | Description |
|---|---|
| Anvil | Self-verified coding agent |
| VerifyLoop | Plan→Execute→Verify→Recover framework |
| ErrorRecovery | Self-healing middleware (3,725 error patterns) |
| FableForge-14B | The fine-tuned 14B model (4-stage training) |
| ShellWhisperer | 1.5B edge agent (phone/RPi, 50ms) |
| ReasonCritic | Verification model (130 benchmark tasks) |
| TraceCompiler | Compile traces → LoRA skills |
| AgentRuntime | Persistent agent daemon (systemd for AI) |
| AgentSwarm | Multi-agent from real trace transitions |
| AgentTelemetry | Datadog for agents (token tracking, costs) |
| BenchAgent | HumanEval for tool-use (107 tasks) |
| AgentDev | VSCode extension with verification |
| TraceViz | Trace replay visualizer (Next.js) |
| AgentSkills | npm for agent behaviors |
| AgentCurriculum | 5-stage progressive training |
| AgentFuzzer | Adversarial testing for agents |
| AgentConstitution | Safety guardrails from traces |
| CostOptimizer | Token cost reduction (50-80%) |
| AgentProfiler | Behavioral fingerprinting |
| TrajectoryDistiller | Trace→training data pipeline |
| Fable5-Dataset | HuggingFace dataset release |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fableforge_agent_runtime-0.1.0.tar.gz.
File metadata
- Download URL: fableforge_agent_runtime-0.1.0.tar.gz
- Upload date:
- Size: 14.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c77738e3e160aa139346b88c1566897ef7ca5ca46c2fc8d33b72155649b7776
|
|
| MD5 |
b9f60c960422bfc9c42fed1fbe520978
|
|
| BLAKE2b-256 |
3c9e55a07aebe5e893bf80d2ea86c176b1527e408964f3a7cff0ca7227f649ea
|
Provenance
The following attestation bundles were made for fableforge_agent_runtime-0.1.0.tar.gz:
Publisher:
release.yml on KingLabsA/agent-runtime
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fableforge_agent_runtime-0.1.0.tar.gz -
Subject digest:
9c77738e3e160aa139346b88c1566897ef7ca5ca46c2fc8d33b72155649b7776 - Sigstore transparency entry: 1819969400
- Sigstore integration time:
-
Permalink:
KingLabsA/agent-runtime@2a3870d70378fcce4158e366c96f8c495fc05af9 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/KingLabsA
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@2a3870d70378fcce4158e366c96f8c495fc05af9 -
Trigger Event:
push
-
Statement type:
File details
Details for the file fableforge_agent_runtime-0.1.0-py3-none-any.whl.
File metadata
- Download URL: fableforge_agent_runtime-0.1.0-py3-none-any.whl
- Upload date:
- Size: 16.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
50e6ce6bfffda1e34080beae72633ee704ea9896dd62093855e6da450e332bd1
|
|
| MD5 |
55864e8ae57e03eb4aea08cc7483ec96
|
|
| BLAKE2b-256 |
cc65407bdcfd98e25fd1f7d766236fdb5adcc423ac99719a8aa9032d40987bdc
|
Provenance
The following attestation bundles were made for fableforge_agent_runtime-0.1.0-py3-none-any.whl:
Publisher:
release.yml on KingLabsA/agent-runtime
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fableforge_agent_runtime-0.1.0-py3-none-any.whl -
Subject digest:
50e6ce6bfffda1e34080beae72633ee704ea9896dd62093855e6da450e332bd1 - Sigstore transparency entry: 1819969415
- Sigstore integration time:
-
Permalink:
KingLabsA/agent-runtime@2a3870d70378fcce4158e366c96f8c495fc05af9 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/KingLabsA
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@2a3870d70378fcce4158e366c96f8c495fc05af9 -
Trigger Event:
push
-
Statement type: