fableforge-agent-runtime 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fableforge_agent_runtime-0.1.0/.github/workflows/release.yml +38 -0
- fableforge_agent_runtime-0.1.0/.gitignore +15 -0
- fableforge_agent_runtime-0.1.0/LICENSE +21 -0
- fableforge_agent_runtime-0.1.0/PKG-INFO +274 -0
- fableforge_agent_runtime-0.1.0/README.md +257 -0
- fableforge_agent_runtime-0.1.0/__init__.py +0 -0
- fableforge_agent_runtime-0.1.0/docker/Dockerfile +24 -0
- fableforge_agent_runtime-0.1.0/pyproject.toml +34 -0
- fableforge_agent_runtime-0.1.0/src/agent_runtime/__init__.py +3 -0
- fableforge_agent_runtime-0.1.0/src/agent_runtime/cli.py +128 -0
- fableforge_agent_runtime-0.1.0/src/agent_runtime/daemon.py +172 -0
- fableforge_agent_runtime-0.1.0/src/agent_runtime/memory_store.py +244 -0
- fableforge_agent_runtime-0.1.0/src/agent_runtime/models.py +93 -0
- fableforge_agent_runtime-0.1.0/src/agent_runtime/server.py +119 -0
- fableforge_agent_runtime-0.1.0/src/agent_runtime/session_manager.py +156 -0
- fableforge_agent_runtime-0.1.0/src/agent_runtime/state_serializer.py +222 -0
- fableforge_agent_runtime-0.1.0/tests/test_state_serializer.py +200 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
name: Release to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v*'
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
id-token: write
|
|
10
|
+
packages: write
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
build-and-publish:
|
|
14
|
+
name: Build and publish to PyPI
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
environment:
|
|
17
|
+
name: pypi
|
|
18
|
+
url: https://pypi.org/p/fableforge-agent-runtime
|
|
19
|
+
permissions:
|
|
20
|
+
id-token: write
|
|
21
|
+
|
|
22
|
+
steps:
|
|
23
|
+
- name: Checkout code
|
|
24
|
+
uses: actions/checkout@v4
|
|
25
|
+
|
|
26
|
+
- name: Set up Python
|
|
27
|
+
uses: actions/setup-python@v5
|
|
28
|
+
with:
|
|
29
|
+
python-version: '3.12'
|
|
30
|
+
|
|
31
|
+
- name: Install build dependencies
|
|
32
|
+
run: python -m pip install --upgrade build
|
|
33
|
+
|
|
34
|
+
- name: Build package
|
|
35
|
+
run: python -m build
|
|
36
|
+
|
|
37
|
+
- name: Publish package to PyPI
|
|
38
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 FableForge Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fableforge-agent-runtime
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Persistent agent daemon — systemd for AI agents
|
|
5
|
+
License-File: LICENSE
|
|
6
|
+
Requires-Python: >=3.11
|
|
7
|
+
Requires-Dist: fastapi>=0.111.0
|
|
8
|
+
Requires-Dist: pydantic>=2.7.0
|
|
9
|
+
Requires-Dist: redis>=5.0.0
|
|
10
|
+
Requires-Dist: sqlalchemy>=2.0.30
|
|
11
|
+
Requires-Dist: uvicorn[standard]>=0.30.0
|
|
12
|
+
Provides-Extra: dev
|
|
13
|
+
Requires-Dist: httpx>=0.27; extra == 'dev'
|
|
14
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
|
|
15
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
|
|
18
|
+
# AgentRuntime — systemd for AI Agents
|
|
19
|
+
|
|
20
|
+
[](LICENSE) [](https://www.python.org/downloads/) [](tests/)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
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.
|
|
24
|
+
|
|
25
|
+
## Architecture
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
┌─────────────┐ ┌──────────────────┐ ┌────────────────┐
|
|
29
|
+
│ CLI │────▶│ FastAPI Server │────▶│ SessionManager│
|
|
30
|
+
│ (agentd) │ │ (port 8721) │ │ │
|
|
31
|
+
└─────────────┘ └──────────────────┘ └───────┬────────┘
|
|
32
|
+
│
|
|
33
|
+
┌─────────────────────────┼─────────────────────┐
|
|
34
|
+
│ │ │
|
|
35
|
+
┌────────▼────────┐ ┌────────▼────────┐ ┌───────▼──────┐
|
|
36
|
+
│ StateSerializer │ │ MemoryStore │ │ Daemon │
|
|
37
|
+
│ (SQLite) │ │ (Short+Long) │ │ (Heartbeat) │
|
|
38
|
+
└─────────────────┘ └─────────────────┘ └──────────────┘
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Features
|
|
42
|
+
|
|
43
|
+
- **Session Lifecycle**: Create, start, pause, resume, stop agent sessions
|
|
44
|
+
- **State Persistence**: Full session state serialized to SQLite
|
|
45
|
+
- **Checkpoints**: Save and restore complete state at any point
|
|
46
|
+
- **Memory Management**: Short-term (conversation context) and long-term (key-value with semantic search)
|
|
47
|
+
- **Memory Consolidation**: Auto-summarize old short-term memories
|
|
48
|
+
- **Auto-Checkpoint**: Configurable interval for automatic state snapshots
|
|
49
|
+
- **Graceful Shutdown**: State preservation on daemon stop
|
|
50
|
+
- **Session Timeout**: Automatic cleanup of stopped sessions
|
|
51
|
+
- **REST API**: Full HTTP API via FastAPI
|
|
52
|
+
- **CLI**: Command-line interface for all operations
|
|
53
|
+
- **Docker**: Production-ready container image
|
|
54
|
+
|
|
55
|
+
## Quick Start
|
|
56
|
+
|
|
57
|
+
### Install
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
pip install -e .
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Start the Daemon
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
agentd start --port 8721
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Create a Session
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
agentd create --name "my-agent" --model fableforge-14b --system-prompt "You are a helpful assistant"
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### List Sessions
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
agentd list
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Resume a Session
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
agentd resume <session-id> --checkpoint-id <checkpoint-id>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Stop the Daemon
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
agentd stop
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## API Reference
|
|
94
|
+
|
|
95
|
+
### POST /sessions
|
|
96
|
+
|
|
97
|
+
Create a new session.
|
|
98
|
+
|
|
99
|
+
```json
|
|
100
|
+
{
|
|
101
|
+
"name": "my-agent",
|
|
102
|
+
"model": "fableforge-14b",
|
|
103
|
+
"system_prompt": "You are a helpful assistant.",
|
|
104
|
+
"tools": ["search", "calculator"]
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### GET /sessions
|
|
109
|
+
|
|
110
|
+
List all sessions.
|
|
111
|
+
|
|
112
|
+
### GET /sessions/{id}
|
|
113
|
+
|
|
114
|
+
Get session state.
|
|
115
|
+
|
|
116
|
+
### POST /sessions/{id}/start
|
|
117
|
+
|
|
118
|
+
Start a session (begins heartbeat and auto-checkpoint).
|
|
119
|
+
|
|
120
|
+
### POST /sessions/{id}/pause
|
|
121
|
+
|
|
122
|
+
Pause a running session (creates checkpoint, cancels heartbeat).
|
|
123
|
+
|
|
124
|
+
### POST /sessions/{id}/resume
|
|
125
|
+
|
|
126
|
+
Resume a paused or stopped session.
|
|
127
|
+
|
|
128
|
+
```json
|
|
129
|
+
{
|
|
130
|
+
"session_id": "abc123",
|
|
131
|
+
"checkpoint_id": "cp_456"
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### POST /sessions/{id}/stop
|
|
136
|
+
|
|
137
|
+
Stop a session (creates final checkpoint).
|
|
138
|
+
|
|
139
|
+
### GET /sessions/{id}/memory
|
|
140
|
+
|
|
141
|
+
List memory keys or retrieve specific key: `?key=my_key`
|
|
142
|
+
|
|
143
|
+
### POST /sessions/{id}/memory
|
|
144
|
+
|
|
145
|
+
Store a memory entry.
|
|
146
|
+
|
|
147
|
+
```json
|
|
148
|
+
{
|
|
149
|
+
"key": "user_preference",
|
|
150
|
+
"value": {"theme": "dark", "language": "en"}
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### GET /sessions/{id}/checkpoints
|
|
155
|
+
|
|
156
|
+
List all checkpoints for a session.
|
|
157
|
+
|
|
158
|
+
### POST /sessions/{id}/checkpoints
|
|
159
|
+
|
|
160
|
+
Create a checkpoint. Query param: `?label=my-checkpoint`
|
|
161
|
+
|
|
162
|
+
### GET /health
|
|
163
|
+
|
|
164
|
+
Daemon health status.
|
|
165
|
+
|
|
166
|
+
## Session States
|
|
167
|
+
|
|
168
|
+
```
|
|
169
|
+
CREATED ──▶ RUNNING ──◆──▶ PAUSED ──▶ RUNNING
|
|
170
|
+
│ │ │
|
|
171
|
+
│ └──▶ STOPPED
|
|
172
|
+
└──▶ ERROR
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## Memory Architecture
|
|
176
|
+
|
|
177
|
+
### Short-Term Memory
|
|
178
|
+
|
|
179
|
+
- Last N messages per session (default 50)
|
|
180
|
+
- Automatic pruning when window exceeded
|
|
181
|
+
- Used for conversation context
|
|
182
|
+
|
|
183
|
+
### Long-Term Memory
|
|
184
|
+
|
|
185
|
+
- Key-value store with optional embeddings
|
|
186
|
+
- Cosine similarity semantic search
|
|
187
|
+
- Persistent across sessions
|
|
188
|
+
- Consolidation: summarizes old short-term into long-term
|
|
189
|
+
|
|
190
|
+
### Consolidation
|
|
191
|
+
|
|
192
|
+
When short-term memory exceeds a threshold, the daemon:
|
|
193
|
+
1. Summarizes the recent conversation
|
|
194
|
+
2. Stores the summary in long-term memory
|
|
195
|
+
3. Prunes old short-term entries
|
|
196
|
+
|
|
197
|
+
## Configuration
|
|
198
|
+
|
|
199
|
+
| Env Variable | Default | Description |
|
|
200
|
+
|---|---|---|
|
|
201
|
+
| `AGENT_RUNTIME_DB` | `~/.agent_runtime/state.db` | SQLite database path |
|
|
202
|
+
| `AGENT_RUNTIME_MEMORY_DB` | `~/.agent_runtime/memory.db` | Memory database path |
|
|
203
|
+
| `AGENT_RUNTIME_PORT` | `8721` | HTTP server port |
|
|
204
|
+
| `AGENT_RUNTIME_HOST` | `0.0.0.0` | HTTP server bind address |
|
|
205
|
+
| `AGENT_RUNTIME_CHECKPOINT_INTERVAL` | `60` | Auto-checkpoint interval (seconds) |
|
|
206
|
+
| `AGENT_RUNTIME_SESSION_TIMEOUT` | `3600` | Session timeout (seconds) |
|
|
207
|
+
|
|
208
|
+
## Docker
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
docker build -f docker/Dockerfile -t agent-runtime .
|
|
212
|
+
docker run -p 8721:8721 -v agent_data:/root/.agent_runtime agent-runtime
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## Testing
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
pip install -e ".[dev]"
|
|
219
|
+
pytest tests/ -v
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## Project Structure
|
|
223
|
+
|
|
224
|
+
```
|
|
225
|
+
agent-runtime/
|
|
226
|
+
├── pyproject.toml
|
|
227
|
+
├── docker/
|
|
228
|
+
│ └── Dockerfile
|
|
229
|
+
├── src/
|
|
230
|
+
│ └── agent_runtime/
|
|
231
|
+
│ ├── __init__.py
|
|
232
|
+
│ ├── models.py # Pydantic models
|
|
233
|
+
│ ├── state_serializer.py # SQLite state persistence
|
|
234
|
+
│ ├── memory_store.py # Short/long-term memory
|
|
235
|
+
│ ├── session_manager.py # Session lifecycle
|
|
236
|
+
│ ├── daemon.py # Background daemon process
|
|
237
|
+
│ ├── server.py # FastAPI HTTP server
|
|
238
|
+
│ └── cli.py # CLI interface
|
|
239
|
+
├── tests/
|
|
240
|
+
│ └── test_state_serializer.py
|
|
241
|
+
└── README.md
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## License
|
|
245
|
+
|
|
246
|
+
MIT
|
|
247
|
+
|
|
248
|
+
## Ecosystem
|
|
249
|
+
|
|
250
|
+
Part of the [FableForge](../) ecosystem — 21 open-source projects built from 210K real agent traces:
|
|
251
|
+
|
|
252
|
+
| Project | Description |
|
|
253
|
+
| --- | --- |
|
|
254
|
+
| **[Anvil](../anvil)** | Self-verified coding agent |
|
|
255
|
+
| **[VerifyLoop](../verifyloop)** | Plan→Execute→Verify→Recover framework |
|
|
256
|
+
| **[ErrorRecovery](../error-recovery)** | Self-healing middleware (3,725 error patterns) |
|
|
257
|
+
| **[FableForge-14B](../fableforge-14b)** | The fine-tuned 14B model (4-stage training) |
|
|
258
|
+
| **[ShellWhisperer](../shell-whisperer)** | 1.5B edge agent (phone/RPi, 50ms) |
|
|
259
|
+
| **[ReasonCritic](../reason-critic)** | Verification model (130 benchmark tasks) |
|
|
260
|
+
| **[TraceCompiler](../trace-compiler)** | Compile traces → LoRA skills |
|
|
261
|
+
| **[AgentRuntime](../agent-runtime)** | Persistent agent daemon (systemd for AI) |
|
|
262
|
+
| **[AgentSwarm](../agent-swarm)** | Multi-agent from real trace transitions |
|
|
263
|
+
| **[AgentTelemetry](../agent-telemetry)** | Datadog for agents (token tracking, costs) |
|
|
264
|
+
| **[BenchAgent](../bench-agent)** | HumanEval for tool-use (107 tasks) |
|
|
265
|
+
| **[AgentDev](../agent-dev)** | VSCode extension with verification |
|
|
266
|
+
| **[TraceViz](../trace-viz)** | Trace replay visualizer (Next.js) |
|
|
267
|
+
| **[AgentSkills](../agent-skills)** | npm for agent behaviors |
|
|
268
|
+
| **[AgentCurriculum](../agent-curriculum)** | 5-stage progressive training |
|
|
269
|
+
| **[AgentFuzzer](../agent-fuzzer)** | Adversarial testing for agents |
|
|
270
|
+
| **[AgentConstitution](../agent-constitution)** | Safety guardrails from traces |
|
|
271
|
+
| **[CostOptimizer](../cost-optimizer)** | Token cost reduction (50-80%) |
|
|
272
|
+
| **[AgentProfiler](../agent-profiler)** | Behavioral fingerprinting |
|
|
273
|
+
| **[TrajectoryDistiller](../trajectory-distiller)** | Trace→training data pipeline |
|
|
274
|
+
| **[Fable5-Dataset](../fable5-dataset)** | HuggingFace dataset release |
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
# AgentRuntime — systemd for AI Agents
|
|
2
|
+
|
|
3
|
+
[](LICENSE) [](https://www.python.org/downloads/) [](tests/)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
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.
|
|
7
|
+
|
|
8
|
+
## Architecture
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
┌─────────────┐ ┌──────────────────┐ ┌────────────────┐
|
|
12
|
+
│ CLI │────▶│ FastAPI Server │────▶│ SessionManager│
|
|
13
|
+
│ (agentd) │ │ (port 8721) │ │ │
|
|
14
|
+
└─────────────┘ └──────────────────┘ └───────┬────────┘
|
|
15
|
+
│
|
|
16
|
+
┌─────────────────────────┼─────────────────────┐
|
|
17
|
+
│ │ │
|
|
18
|
+
┌────────▼────────┐ ┌────────▼────────┐ ┌───────▼──────┐
|
|
19
|
+
│ StateSerializer │ │ MemoryStore │ │ Daemon │
|
|
20
|
+
│ (SQLite) │ │ (Short+Long) │ │ (Heartbeat) │
|
|
21
|
+
└─────────────────┘ └─────────────────┘ └──────────────┘
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Features
|
|
25
|
+
|
|
26
|
+
- **Session Lifecycle**: Create, start, pause, resume, stop agent sessions
|
|
27
|
+
- **State Persistence**: Full session state serialized to SQLite
|
|
28
|
+
- **Checkpoints**: Save and restore complete state at any point
|
|
29
|
+
- **Memory Management**: Short-term (conversation context) and long-term (key-value with semantic search)
|
|
30
|
+
- **Memory Consolidation**: Auto-summarize old short-term memories
|
|
31
|
+
- **Auto-Checkpoint**: Configurable interval for automatic state snapshots
|
|
32
|
+
- **Graceful Shutdown**: State preservation on daemon stop
|
|
33
|
+
- **Session Timeout**: Automatic cleanup of stopped sessions
|
|
34
|
+
- **REST API**: Full HTTP API via FastAPI
|
|
35
|
+
- **CLI**: Command-line interface for all operations
|
|
36
|
+
- **Docker**: Production-ready container image
|
|
37
|
+
|
|
38
|
+
## Quick Start
|
|
39
|
+
|
|
40
|
+
### Install
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip install -e .
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Start the Daemon
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
agentd start --port 8721
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Create a Session
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
agentd create --name "my-agent" --model fableforge-14b --system-prompt "You are a helpful assistant"
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### List Sessions
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
agentd list
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Resume a Session
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
agentd resume <session-id> --checkpoint-id <checkpoint-id>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Stop the Daemon
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
agentd stop
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## API Reference
|
|
77
|
+
|
|
78
|
+
### POST /sessions
|
|
79
|
+
|
|
80
|
+
Create a new session.
|
|
81
|
+
|
|
82
|
+
```json
|
|
83
|
+
{
|
|
84
|
+
"name": "my-agent",
|
|
85
|
+
"model": "fableforge-14b",
|
|
86
|
+
"system_prompt": "You are a helpful assistant.",
|
|
87
|
+
"tools": ["search", "calculator"]
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### GET /sessions
|
|
92
|
+
|
|
93
|
+
List all sessions.
|
|
94
|
+
|
|
95
|
+
### GET /sessions/{id}
|
|
96
|
+
|
|
97
|
+
Get session state.
|
|
98
|
+
|
|
99
|
+
### POST /sessions/{id}/start
|
|
100
|
+
|
|
101
|
+
Start a session (begins heartbeat and auto-checkpoint).
|
|
102
|
+
|
|
103
|
+
### POST /sessions/{id}/pause
|
|
104
|
+
|
|
105
|
+
Pause a running session (creates checkpoint, cancels heartbeat).
|
|
106
|
+
|
|
107
|
+
### POST /sessions/{id}/resume
|
|
108
|
+
|
|
109
|
+
Resume a paused or stopped session.
|
|
110
|
+
|
|
111
|
+
```json
|
|
112
|
+
{
|
|
113
|
+
"session_id": "abc123",
|
|
114
|
+
"checkpoint_id": "cp_456"
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### POST /sessions/{id}/stop
|
|
119
|
+
|
|
120
|
+
Stop a session (creates final checkpoint).
|
|
121
|
+
|
|
122
|
+
### GET /sessions/{id}/memory
|
|
123
|
+
|
|
124
|
+
List memory keys or retrieve specific key: `?key=my_key`
|
|
125
|
+
|
|
126
|
+
### POST /sessions/{id}/memory
|
|
127
|
+
|
|
128
|
+
Store a memory entry.
|
|
129
|
+
|
|
130
|
+
```json
|
|
131
|
+
{
|
|
132
|
+
"key": "user_preference",
|
|
133
|
+
"value": {"theme": "dark", "language": "en"}
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### GET /sessions/{id}/checkpoints
|
|
138
|
+
|
|
139
|
+
List all checkpoints for a session.
|
|
140
|
+
|
|
141
|
+
### POST /sessions/{id}/checkpoints
|
|
142
|
+
|
|
143
|
+
Create a checkpoint. Query param: `?label=my-checkpoint`
|
|
144
|
+
|
|
145
|
+
### GET /health
|
|
146
|
+
|
|
147
|
+
Daemon health status.
|
|
148
|
+
|
|
149
|
+
## Session States
|
|
150
|
+
|
|
151
|
+
```
|
|
152
|
+
CREATED ──▶ RUNNING ──◆──▶ PAUSED ──▶ RUNNING
|
|
153
|
+
│ │ │
|
|
154
|
+
│ └──▶ STOPPED
|
|
155
|
+
└──▶ ERROR
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Memory Architecture
|
|
159
|
+
|
|
160
|
+
### Short-Term Memory
|
|
161
|
+
|
|
162
|
+
- Last N messages per session (default 50)
|
|
163
|
+
- Automatic pruning when window exceeded
|
|
164
|
+
- Used for conversation context
|
|
165
|
+
|
|
166
|
+
### Long-Term Memory
|
|
167
|
+
|
|
168
|
+
- Key-value store with optional embeddings
|
|
169
|
+
- Cosine similarity semantic search
|
|
170
|
+
- Persistent across sessions
|
|
171
|
+
- Consolidation: summarizes old short-term into long-term
|
|
172
|
+
|
|
173
|
+
### Consolidation
|
|
174
|
+
|
|
175
|
+
When short-term memory exceeds a threshold, the daemon:
|
|
176
|
+
1. Summarizes the recent conversation
|
|
177
|
+
2. Stores the summary in long-term memory
|
|
178
|
+
3. Prunes old short-term entries
|
|
179
|
+
|
|
180
|
+
## Configuration
|
|
181
|
+
|
|
182
|
+
| Env Variable | Default | Description |
|
|
183
|
+
|---|---|---|
|
|
184
|
+
| `AGENT_RUNTIME_DB` | `~/.agent_runtime/state.db` | SQLite database path |
|
|
185
|
+
| `AGENT_RUNTIME_MEMORY_DB` | `~/.agent_runtime/memory.db` | Memory database path |
|
|
186
|
+
| `AGENT_RUNTIME_PORT` | `8721` | HTTP server port |
|
|
187
|
+
| `AGENT_RUNTIME_HOST` | `0.0.0.0` | HTTP server bind address |
|
|
188
|
+
| `AGENT_RUNTIME_CHECKPOINT_INTERVAL` | `60` | Auto-checkpoint interval (seconds) |
|
|
189
|
+
| `AGENT_RUNTIME_SESSION_TIMEOUT` | `3600` | Session timeout (seconds) |
|
|
190
|
+
|
|
191
|
+
## Docker
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
docker build -f docker/Dockerfile -t agent-runtime .
|
|
195
|
+
docker run -p 8721:8721 -v agent_data:/root/.agent_runtime agent-runtime
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## Testing
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
pip install -e ".[dev]"
|
|
202
|
+
pytest tests/ -v
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## Project Structure
|
|
206
|
+
|
|
207
|
+
```
|
|
208
|
+
agent-runtime/
|
|
209
|
+
├── pyproject.toml
|
|
210
|
+
├── docker/
|
|
211
|
+
│ └── Dockerfile
|
|
212
|
+
├── src/
|
|
213
|
+
│ └── agent_runtime/
|
|
214
|
+
│ ├── __init__.py
|
|
215
|
+
│ ├── models.py # Pydantic models
|
|
216
|
+
│ ├── state_serializer.py # SQLite state persistence
|
|
217
|
+
│ ├── memory_store.py # Short/long-term memory
|
|
218
|
+
│ ├── session_manager.py # Session lifecycle
|
|
219
|
+
│ ├── daemon.py # Background daemon process
|
|
220
|
+
│ ├── server.py # FastAPI HTTP server
|
|
221
|
+
│ └── cli.py # CLI interface
|
|
222
|
+
├── tests/
|
|
223
|
+
│ └── test_state_serializer.py
|
|
224
|
+
└── README.md
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## License
|
|
228
|
+
|
|
229
|
+
MIT
|
|
230
|
+
|
|
231
|
+
## Ecosystem
|
|
232
|
+
|
|
233
|
+
Part of the [FableForge](../) ecosystem — 21 open-source projects built from 210K real agent traces:
|
|
234
|
+
|
|
235
|
+
| Project | Description |
|
|
236
|
+
| --- | --- |
|
|
237
|
+
| **[Anvil](../anvil)** | Self-verified coding agent |
|
|
238
|
+
| **[VerifyLoop](../verifyloop)** | Plan→Execute→Verify→Recover framework |
|
|
239
|
+
| **[ErrorRecovery](../error-recovery)** | Self-healing middleware (3,725 error patterns) |
|
|
240
|
+
| **[FableForge-14B](../fableforge-14b)** | The fine-tuned 14B model (4-stage training) |
|
|
241
|
+
| **[ShellWhisperer](../shell-whisperer)** | 1.5B edge agent (phone/RPi, 50ms) |
|
|
242
|
+
| **[ReasonCritic](../reason-critic)** | Verification model (130 benchmark tasks) |
|
|
243
|
+
| **[TraceCompiler](../trace-compiler)** | Compile traces → LoRA skills |
|
|
244
|
+
| **[AgentRuntime](../agent-runtime)** | Persistent agent daemon (systemd for AI) |
|
|
245
|
+
| **[AgentSwarm](../agent-swarm)** | Multi-agent from real trace transitions |
|
|
246
|
+
| **[AgentTelemetry](../agent-telemetry)** | Datadog for agents (token tracking, costs) |
|
|
247
|
+
| **[BenchAgent](../bench-agent)** | HumanEval for tool-use (107 tasks) |
|
|
248
|
+
| **[AgentDev](../agent-dev)** | VSCode extension with verification |
|
|
249
|
+
| **[TraceViz](../trace-viz)** | Trace replay visualizer (Next.js) |
|
|
250
|
+
| **[AgentSkills](../agent-skills)** | npm for agent behaviors |
|
|
251
|
+
| **[AgentCurriculum](../agent-curriculum)** | 5-stage progressive training |
|
|
252
|
+
| **[AgentFuzzer](../agent-fuzzer)** | Adversarial testing for agents |
|
|
253
|
+
| **[AgentConstitution](../agent-constitution)** | Safety guardrails from traces |
|
|
254
|
+
| **[CostOptimizer](../cost-optimizer)** | Token cost reduction (50-80%) |
|
|
255
|
+
| **[AgentProfiler](../agent-profiler)** | Behavioral fingerprinting |
|
|
256
|
+
| **[TrajectoryDistiller](../trajectory-distiller)** | Trace→training data pipeline |
|
|
257
|
+
| **[Fable5-Dataset](../fable5-dataset)** | HuggingFace dataset release |
|
|
File without changes
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
FROM python:3.12-slim
|
|
2
|
+
|
|
3
|
+
WORKDIR /app
|
|
4
|
+
|
|
5
|
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
6
|
+
gcc \
|
|
7
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
8
|
+
|
|
9
|
+
COPY pyproject.toml .
|
|
10
|
+
RUN pip install --no-cache-dir .
|
|
11
|
+
|
|
12
|
+
COPY src/ src/
|
|
13
|
+
|
|
14
|
+
RUN pip install --no-cache-dir -e .
|
|
15
|
+
|
|
16
|
+
RUN mkdir -p /root/.agent_runtime
|
|
17
|
+
|
|
18
|
+
EXPOSE 8721
|
|
19
|
+
|
|
20
|
+
HEALTHCHECK --interval=30s --timeout=5s --retries=3 \
|
|
21
|
+
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8721/health')" || exit 1
|
|
22
|
+
|
|
23
|
+
ENTRYPOINT ["agentd"]
|
|
24
|
+
CMD ["start"]
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "fableforge-agent-runtime"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Persistent agent daemon — systemd for AI agents"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
dependencies = [
|
|
12
|
+
"fastapi>=0.111.0",
|
|
13
|
+
"uvicorn[standard]>=0.30.0",
|
|
14
|
+
"sqlalchemy>=2.0.30",
|
|
15
|
+
"redis>=5.0.0",
|
|
16
|
+
"pydantic>=2.7.0",
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
[project.optional-dependencies]
|
|
20
|
+
dev = [
|
|
21
|
+
"pytest>=8.0",
|
|
22
|
+
"pytest-asyncio>=0.23",
|
|
23
|
+
"httpx>=0.27",
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
[project.scripts]
|
|
27
|
+
agentd = "agent_runtime.cli:app"
|
|
28
|
+
|
|
29
|
+
[tool.hatch.build.targets.wheel]
|
|
30
|
+
packages = ["src/agent_runtime"]
|
|
31
|
+
|
|
32
|
+
[tool.pytest.ini_options]
|
|
33
|
+
asyncio_mode = "auto"
|
|
34
|
+
testpaths = ["tests"]
|