Skip to content

robmorgan/agentd

Repository files navigation

agentd logo

Run coding agents like processes. Supervise them like jobs.

Developers are starting to run multiple coding agents in parallel including Claude Code and Codex. But once you run more than one, things get messy:

  • terminals everywhere
  • scrolling logs
  • lost artifacts
  • agents needing attention

agentd turns coding agents into durable tasks with state, artifacts, and history. Instead of babysitting terminal tabs, you supervise work.

How It Works

tmux multiplexes terminals. agentd supervises agents. agentd is a daemon runtime for supervising coding agents as durable tasks.

Each task runs inside a managed session with:

  • its own git worktree and branch
  • a dedicated PTY
  • retained terminal history
  • persistent artifacts

This allows developers to supervise agent work without constantly switching between terminal sessions.

Example

Start a task:

agent run --name fix-tests "fix failing tests in auth service"

This creates a task, assigns a session, and starts the agent in a detached PTY.

List running tasks:

agent ls

NAME                 AGENT    STATUS      ELAPSED   TOKENS      COST
● fix-tests          codex    running     12m       2.3k/900    $0.18
⚠ dependency-bump    claude   running     4m        800/120     $0.07
✔ docs-readme        codex    completed   6m        1.1k/420    $0.05

You can attach to a running agent to open the underlying PTY session:

agent attach fix-tests

Multiple clients can attach to the same running session at once, including the TUI and one or more agent attach processes.

Detach the local agent attach client using ctrl + \. Switch to the previous attached session with ctrl + [ and the next one with ctrl + ]. To inspect or manage other attached clients:

agent attachments fix-tests
agent detach fix-tests --attach attach-1
agent detach fix-tests --all

Inspect retained session scrollback from daemon memory:

agent history fix-tests
agent history fix-tests --vt

Stop a task:

agent kill fix-tests

And explicitly cleanup any artifacts and worktrees:

agent kill --rm fix-tests

Run the agent command without any arguments to open the TUI.

Core Concepts

agentd introduces three core primitives.

  • Tasks. A long-running unit of work. A task may spawn one or more agents and has a lifecycle (running, completed, failed).
  • Threads. A sequence of reasoning associated with a task. Threads capture prompts, tool calls, intermediate outputs, and final results.
  • Artifacts. Outputs produced by agents, such as commits, files, patches, test results, or screenshots.

Attention model

Multiple agents create an attention problem.

Instead of streaming logs constantly, tasks emit attention signals:

info      background update
notice    something meaningful happened
action    user intervention required

Clients surface tasks based on attention instead of raw output.

Architecture

agentd is not a terminal multiplexer. Terminal layout (splits, panes, tabs) should remain the responsibility of the host terminal or multiplexer. Instead, it focuses purely on agent runtime semantics.

  • durable PTY-backed agent sessions that outlive the client connection that started them
  • built-in Git worktree isolation under the resolved runtime root
  • session metadata stored in state.db under the resolved runtime root
  • in-memory PTY scrollback retained by the daemon until restart
  • interactive reattach with agent attach
  • background PTY input with agent send
  • diff inspection against the base branch with agent diff

Build

Initialize the pinned Ghostty submodule first:

git submodule update --init --recursive

This checks out ghostty-org/ghostty into vendor/ghostty at the commit recorded by the repository's submodule pointer.

If you create an ad hoc Git worktree outside agentd, run the same command in that worktree before building.

Then build:

cargo build

For local development, run the debug binaries directly without reinstalling:

make dev-run ARGS="sessions"

Install

make install

Configure Agents

Create <runtime-root>/config.toml:

default_agent = "codex"

[agents.codex]
command = "codex"
args = []

[agents.claude]
command = "claude"
args = []

Agent picker order follows the order of the [agents.*] tables in this file. default_agent must name one of those configured agents.

The daemon injects:

  • AGENTD_SESSION_ID
  • AGENTD_SOCKET
  • AGENTD_WORKSPACE
  • AGENTD_WORKTREE
  • AGENTD_BRANCH
  • AGENTD_TASK

Instrumented agents can use the injected session environment to locate the daemon socket, but there is no separate structured event channel. Session status, attention, history, diff, and worktree state are the supported runtime surfaces.

Runtime paths are resolved in this order:

  • AGENTD_DIR as the exact runtime root
  • XDG_RUNTIME_DIR/agentd
  • on macOS, ~/.agentd
  • TMPDIR/agentd-<uid>
  • /tmp/agentd-<uid>

The selected root contains config.toml, agentd.sock, agentd.pid, state.db, and worktrees/.

macOS typically does not set XDG_RUNTIME_DIR, so the default root on macOS becomes ~/.agentd unless AGENTD_DIR is set explicitly.

Interactive PTY attach is available with agent attach <name>. Detach with Ctrl-\, switch to the previous running session with Ctrl-[, or switch to the next running session with Ctrl-], or agent detach <name> --attach <attach_id> for a specific client, or agent detach <name> --all to disconnect every attached client on the session. Use agent attachments <name> to inspect the current attachment ids. Attach clears the visible screen and repaints from the daemon's retained terminal state; if the restored session was using the alternate screen, replay restores that state naturally. Multiple interactive attachers are allowed per session, and the TUI uses the same shared attach path when a worker is focused. Background PTY writes are still available with agent send-input <name> -- <text>.

Troubleshooting

Try restarting the daemon:

agent daemon info
agent daemon restart
agent daemon upgrade

agent daemon upgrade now refuses to run while live sessions are active; stop them first.

Status And Limitations

Current capabilities include:

  • local agentd daemon over a Unix socket
  • PTY-backed agent processes that outlive client connections
  • SQLite-backed session metadata and event storage
  • in-memory per-session PTY history until daemon restart
  • Git worktree isolation per session

attach and send only work for sessions created under the current daemon lifetime. If agentd restarts, previously running sessions still keep their metadata, but their live PTY can no longer be reattached or written to and their in-memory history is lost.

About

✨ A daemon-backed workspace for coding agents - like tmux, but built for AI-native software development.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages