gitmyhub

agentd

Rust ★ 33 updated 27d ago

State Machine Daemon designed specifically to orchestrate and persist the state of AI agents

A background Rust daemon that gives AI agents a shared coordination layer, persisting task state in SQLite as a directed graph, issuing leases with heartbeat timeouts, and managing exclusive file locks so multiple agents from any language or provider never stomp on each other.

RustSQLitesetup: moderatecomplexity 4/5

agentd is a background daemon written in Rust that acts as a coordination layer for AI agents running on your local machine. The core problem it solves is that AI agents, especially ones handling long-running tasks with many steps, need somewhere outside themselves to store what they have done and what still needs to happen. If the agent crashes or is restarted, that state would otherwise be lost. agentd handles this by running as a separate process and storing all task state in a SQLite database on disk.

The daemon organizes work as a directed acyclic graph (DAG), which is a way of describing a set of tasks where some must finish before others can start. Each node in that graph goes through strict states: pending, running, completed, or failed. When an agent wants to work on the next available step, it asks the daemon for a lease. The agent must send periodic heartbeats to keep that lease active. If the agent goes silent for too long (the default is 300 seconds), the daemon marks the node as failed and returns it to pending so another agent can try it.

A second major feature is resource locking. When multiple AI agents from different providers or tools might try to edit the same file at the same time, agentd gives each agent a way to claim an exclusive lock on that file before touching it. If another agent already holds the lock, the newcomer gets a null response and knows not to proceed. The README includes detailed examples showing two agents from different providers competing to edit the same file and how the coordination works. Locks also expire, so a stalled agent cannot block others forever.

Communication with the daemon happens through a Unix socket using a simple line-by-line JSON format, meaning any language or tool that can write to a socket can use it without a special library. The daemon also keeps an append-only event journal, which gives a historical record of what happened during a task.

The project is built with Rust and can be compiled from source using Cargo or downloaded as a prebuilt binary.

Where it fits