Husk
GitHub

Computers

Lifetimes and the reaper

idleTimeoutSec, maxLifetimeSec, which providers are actually swept, and how a machine gets bound to a session.

A computer is disposable. Two ceilings decide when one goes away on its own.

FieldDefaultWhat it means
idleTimeoutSec900 (15 minutes) in a husk.yamlDestroy after this long with no exec
maxLifetimeSec0 (off)Destroy this long after creation, whatever the activity

Both are per-machine and both are disabled by 0. A computer made by husk up or POST /v1/computers has no idle limit unless you give one, and a chat's computer has neither: only you delete it.

computer:
  idleTimeoutSec: 600
  maxLifetimeSec: 7200
husk up scratch --idle-timeout 3600

"Idle" means no exec. Every exec records when it ran: on local, ssh and fly in the computer's record, and on Docker and Podman, whose engine knows only when the container started, in ~/.husk/computers/<id>.used.

The reaper

ComputerManager.startReaper(intervalMs = 60_000) starts a sweep every 60 seconds. The interval timer is unref'd, so it never holds a CLI process open, and startReaper is idempotent.

husk serve starts it, and so does the shared Husk that chats' tools go through. The CLI's one-shot commands do not — a husk exec that also garbage-collected somebody else's machine would be a surprise.

All five providers implement reap(), and the sweep asks each one. A reaper failure in one provider is logged at debug and does not stop the others.

Stopping versus destroying

CommandFilesystemRecoverable
husk stop <name>keptyes, with husk start
husk rm <name>gone, except what a chat's or a bot's computer keeps on Docker and Podmanno
husk rm --erase <name>gone, that includedno

On Docker and Podman, a computer that persists under a key — every chat's, and a bot's with persist: true — keeps its /work volume through husk rm, browser logins included, and its next computer finds them. --erase, like the console's Delete, takes them too. Everywhere else husk rm deletes the workspace.

A stopped machine still counts against nothing — only running and creating machines count toward the eight-machine quota — but it still occupies disk.

Session bindings

ComputerManager.ensure(key, spec) maps a stable key onto a machine, so a conversation keeps one filesystem without the caller tracking ids.

The map lives in ~/.husk/computers/bindings.json, written with write-then-rename. When a binding points at a machine that no longer exists, it is cleared and a new machine is created.

MCP uses this. --session <key> or $HUSK_SESSION names the key, and the machine is mcp-<key>; without one, each chat gets a computer of its own. A chat's computer is made with persist: true and no idle or lifetime limit. After ten idle minutes it is stopped, unless you hold it, and its next call starts it again.

claude mcp add husk-api -- npx -y @husk-ai/mcp --session api --flavor python
claude mcp add husk-web -- npx -y @husk-ai/mcp --session web --flavor node

Two keys, two machines, two filesystems, one client.

Shutdown paths

TriggerWhat happens
husk rmThe machine is destroyed and the binding cleared, except what a chat's or a bot's computer keeps on Docker and Podman (above)
MCP client disconnects (stdin closes)The machine is stopped, not destroyed. With --keep it is left running
SIGINT / SIGTERM to husk mcpSame
Ctrl-C during husk runThe run aborts at once, mid-step if need be. The machine is left alone
Ten idle minutes, on a chat's computerStopped. Its files stay
ReaperDestroys a computer past its idle or lifetime limit, on every provider

Ctrl-C during a run is deliberately non-destructive. You interrupted the agent, not the machine, and destroying the filesystem you were about to inspect would be the wrong reading of that keystroke.