Background agents

Background agents let you kick off a task and walk away. The agent runs detached, captures output to a log file, and you can check on it later.

Start

isonforge --bg "audit every fetch() call for missing await + timeout"

Output:

✓ Background agent started: a3f8c1d2
  pid: 18472
  logs: isonforge logs a3f8c1d2
  follow: isonforge attach a3f8c1d2
  stop: isonforge stop a3f8c1d2

The parent process exits immediately. The agent continues running in the background using your current working directory. It calls IsonForge in --print --yolo mode internally, so all tools are auto-approved.

Manage

isonforge agents              # list all
isonforge logs <id>           # tail recent stdout (default 50 lines)
isonforge logs <id> -n 200    # tail more
isonforge attach <id>         # follow live (Ctrl+C to detach)
isonforge stop <id>           # SIGTERM then SIGKILL after 3s
isonforge respawn <id>        # restart a stopped agent with original prompt
isonforge rm <id>             # remove a stopped agent from the list

List output

  ID        State     Started   Prompt
  ───────────────────────────────────────────────────
  a3f8c1d2  running   2h ago    audit every fetch() call for missing await...
  91b4ef0a  stopped   5h ago    refactor session.py to use redis with proper...
  c2d7a3b8  running   45s ago   summarize all README.md files in submodules

State derives from the recorded PID:

State auto-syncs when you list.

State files

Each agent has a directory at ~/.isonforge/agents/<id>/:

File Contents
meta.json id, pid, prompt, cwd, started_at, state
stdout.log cumulative stdout from the agent
stderr.log cumulative stderr

The agent process holds an exclusive write to the log files. You can cat / tail them safely as a reader.

Why background?

Pair with worktrees

The most useful pattern: one background agent per worktree.

isonforge -w feature-auth --bg "implement the new auth flow with tests"
isonforge -w feature-billing --bg "wire up the stripe webhook handler"
isonforge agents

Each agent runs in its own branch directory with its own isolated state. Combined effect: like having multiple junior engineers each working on a separate ticket.

Carve out effort / permission

The agent inherits the spawn-time effort and permission mode:

isonforge --bg --effort max --permission-mode auto "audit every endpoint"

These persist in meta.json and apply on respawn.

Respawn

If an agent crashed or hit a budget cap and stopped, restart it with the same prompt:

isonforge respawn a3f8c1d2

The respawned agent is a fresh --print run with the original prompt. Conversation state from the previous run is NOT preserved - this isn't a true resume. If you need conversation continuity, use sessions (/sessions + --continue) instead.

Remove

When done with an agent:

isonforge stop <id>     # if still running
isonforge rm <id>       # delete the directory + logs

rm refuses to delete running agents - stop first.

Caveats

When NOT to background