Resting agents

Brief

An agent you haven't touched for ten minutes rests. Terminal Delight freezes its processes and pushes their memory out. Look at the pane or press a key and it carries on where it was, in about a fifth of a second.

After an hour of rest, the agent goes to sleep. It is ended and its conversation is kept, and the pane shows a card that says Press any key to wake. A key or a click starts it again with the command line it was started with plus the conversation to resume, in a fresh pane in the same place. It comes back without its background jobs or the permissions you granted that session. A Codex agent sleeps only when it runs its own server.

An agent that is working, printing, running a command, or that Terminal Delight can't read is left alone. The times and switches are on the Agents page in CONFIG. Hover the agent counter at the top right to see how much memory awake, resting and sleeping agents hold.

Technical has the rules, the files, the settings and how a resting agent looks from outside.

Technical

Rest and sleep

The two states#

RestingAsleep
What happensThe pane's processes are frozen and their memory pushed out. They are still running, paused.The agent is ended with SIGTERM. The pane's shell stays; the conversation stays on disk.
After10 minutes untouched and quiet1 hour of rest, or Sleep now
WhoClaude Code and Codex panesClaude Code; Codex only when it runs its own server
Pane headerRESTING · 14m, with a moonASLEEP, with a zzz, and a card over the pane
Wakes onfocusing the pane, or anything written to ita key that would type, or a click on the card
Back inabout a fifth of a second, same paneabout two seconds, in a fresh pane

Shells and configured local agents never rest. Terminal Delight looks at every pane every 15 seconds, the first time 3 seconds after the window opens5.

When an agent rests#

All of these must hold. A fact Terminal Delight can't read counts against resting, never for it1.

  • The pane runs Claude Code or Codex.
  • It isn't focused (on screen with the keyboard), and it isn't pinned with Keep awake.
  • Nobody has touched it for the rest time: no key, paste, click or focus, and nothing written to it, such as a bench line.
  • Its screen hasn't changed for the rest time.
  • Claude Code has reported idle in its own ~/.claude/sessions/<pid>.json for at least the rest time, and the screen doesn't show it working, asking or failing. Codex has its prompt on screen.
  • Nothing else runs in the pane besides its shell, the agent and the agent's MCP helpers: no command the agent started (a background Bash shell, say), no job of the pane's shell, nothing listening on a TCP port.
  • The pane's processes used under 3% of one core since the last look.

Then the pane's memory group is frozen and its memory reclaimed in 64 MiB steps, stopping when a step frees less than 8 MiB3. A key that races the freeze wins: the freeze is refused if anything was written since the look.

When an agent sleeps#

  • It has rested for the sleep time, or you chose Sleep now.
  • Everything rest needs still holds.
  • Claude Code: the conversation id comes from its own sessions file, and the conversation is saved and not empty at ~/.claude/projects/<the pane's directory>/<id>.jsonl. Claude writes a conversation down only once something is said in it, so an agent you started and never spoke to, or one you /cleared into a new conversation, rests and never sleeps2.
  • Codex: it runs its own server, meaning it has MCP helpers of its own. A Codex window attached to a shared Codex service only rests, because ending it would free almost nothing. Its conversation is the one it holds open.
  • The command line can be rebuilt exactly. Claude Code keeps every option word for word, drops any that names a conversation, and adds --resume <id>; it is refused when the line holds an initial prompt (it would be sent again), an option this build doesn't know, or -p, --print, --bg. Codex keeps every option, drops its opening prompt (already the conversation's first message) and adds resume <id>; it is refused for an unknown option, an initial image, --worktree, or a subcommand that isn't an interactive pane1.

Then the wake file is written, the pane thawed, and SIGTERM sent to the agent alone: never to the shell, never SIGKILL. Terminal Delight waits up to 5 seconds for it to go and checks again on every later look. An agent still running a minute after the signal has chosen not to stop, and its pane stays awake1.

Waking#

A resting pane thaws before any bytes reach it, so no key, paste or mouse report lands on a frozen agent. Focusing it is enough.

An asleep pane shows its last screen dimmed under a card67:

Asleep since 14:02
Conversation kept · opus
Press any key to wake
Comes back without background jobs or session grants

The model shows when the command line named one. A key that would type, or a click on the card, opens a fresh pane in the same place that runs the wake file; the shell that held the sleeper is closed. The fresh pane is a new pane with a new $TD_PANE_ID, and it keeps the old one's look, its Threshing Floor seat, any read-only or off-limits mark, and a Keep awake pin. Shortcuts still do what they do on an asleep pane; only a key that would type wakes it.

If a live process already has that conversation open, the card says Not woken: its conversation is open in another process and nothing starts, so one conversation never has two writers5.

Keep awake and Sleep now#

Both are in the pane header's ⋯ menu on an agent pane. ☕ Keep awake pins the pane so it never rests or sleeps, and reads Keep awake ✓ while on; the pin survives a new window. 💤 Sleep now asks the next look to put an awake or resting agent to sleep. It skips the untouched and quiet clocks and keeps every other rule, including Claude Code's own: it must have reported idle for the rest time. It is answered once, slept or refused6.

The ⋯ appears once the header has tucked something away, in a narrow pane or with a control hidden in UI CONFIG. In a single-line header, right-click the header to open the same menu.

Settings#

🤖 Agents in the CONFIG menu opens AGENTS, and so does the 🤖 glyph in the bottom-right corner. The glyph has its own chip under MENU GLYPHS in UI CONFIG; Standard and All show it, and Clean leaves it to the CONFIG menu9. Under REST AND SLEEP:

ControlShippedRangeagents.toml
Rest idle agentsonrest
Rest after10 minslider 2 min to 2 h; a click lands on 5, 10, 20, 30 or 60 min, a drag on any minuterest_after_min
Sleep resting agentson; off whenever rest is offsleep
Sleep after resting2 hslider 13 min to 48 h; a click lands on 20 min, 45 min, 90 min, 4 h or 24 hsleep_after_rest_min

The file is ~/.config/terminal-delight/agents.toml, written the moment you change a control. Every key is optional and an absent one means the shipped answer; a file that doesn't parse reads as all absent, so a typo can't switch your agents off or on. Values are held to 1 minute to 24 hours for rest and 1 minute to 7 days for sleep4.

Under the switches, a live readout:

Now: 2 resting · 1 asleep · 610 MiB (3/3) given back · 1.4 GiB (6/6) held by agents
Values cover measured panes only (measured/total).
Not resting: busy 3 · touched 1 · running something 1

· 2 unmeasured joins the first line when some agent panes have no reading. The last line counts why panes didn't rest or sleep on the latest look:

WordMeans
busyworking, asking, printing, or using more CPU than an idle agent
touchedfocused or touched within the rest time
running somethinga command, a shell job or a listening process under the agent
kept awakepinned with Keep awake
could not tella fact couldn't be read, the conversation isn't saved, or the command line can't be rebuilt
switched offrest or sleep is off on this page

Memory#

Each hosted pane's processes get a memory group of their own, so its header can say what it costs3:

PaneHeader reads
awakeRAM plus swap, e.g. 1.2 GiB
restingRAM left plus what went out, e.g. 9.0 MiB + 340 MiB out
swap unreadable9.0 MiB + ?
group couldn't be made or readunmeasured

RAM is the sum of each process's proportional set size, swap the sum of their swapped share, in binary units. Hover the agent counter at the top right of the window for Agent memory5:

Agent memory
               RAM               Swap
Awake · 3      1.1 GiB (3/3)     120 MiB (3/3)
resting · 2    18 MiB (2/2)      640 MiB (2/2)
asleep · 1     4.0 MiB (1/1)     0 B (1/1)
RAM decrease since rest: 610 MiB (3/3)
Values cover measured panes only (measured/total).
Sample age: 9s · refresh about 15s
Includes pane processes and shells. Shared services excluded.

Each figure carries how many panes it covers. A row with no panes reads —; one whose panes all lack a reading reads unmeasured (0/2). An asleep row measures the shells left behind. RAM decrease since rest is, for each resting or asleep pane, its RAM just before it rested minus its RAM now; a pane woken from sleep starts again with no baseline. Before the first look the card says Waiting for the first memory sample. The card reads the last look's figures and never wakes a pane. Clicking the counter still opens the Threshing Floor, and the counter has a cell for resting and one for asleep. Clean hides the counter; turn on agent counter in UI CONFIG to get it back.

Where it is kept#

~/.local/state/terminal-delight/rest-<session>.toml
Which panes are asleep, by pane id, with when they fell asleep, the conversation, the wake file, and the harness and model they wake as; and which panes are pinned awake. <session> is the window's session name, with anything but letters and digits as _. A new window reads it and puts the sleep cards back. A record whose pane is running an agent again is dropped2.
~/.local/state/terminal-delight/wake/<conversation id>.sh
Owner-only. It waits up to three seconds for the fresh pane's memory group, so the agent starts inside it, then runs the rebuilt command line with exec. bash on it from a shell brings the agent back by hand.

Both honour $XDG_STATE_HOME. Export settings and records in CONFIG › ADMIN copies the wake files with everything else (see Uninstall).

From outside#

  • A pane's group is a systemd scope named td-pane-<session>-<pane>-<shell pid>.scope under your user manager's app.slice, made without privilege. A resting pane's scope has cgroup.freeze set to 1 and its cgroup.events reads frozen 1. Its processes are all still there3.
  • An asleep pane runs only its shell. list_panes reports it as SHELL, with is_agent false and no session, and nothing in the listing says an agent sleeps there. A resting agent is listed as usual8.
  • The Threshing Floor keeps sleeping agents in their seats, named by the harness and model they will wake as: CLAUDE, CODEX, or AGENT when the record doesn't say. A prompt sent along a Floor line wakes a resting or asleep worker without moving your focus. A worker woken from sleep finds this under the prompt's header: [You were asleep, and Terminal Delight restarted you from your saved conversation for this prompt. Anything that lived only in your old process is gone: background shells, permissions granted for that session only, and running loops.]

Turning it off#

The switches on the Agents page stop freezing and ending while keeping the memory figures. To turn the whole feature off, memory groups and readings included, start Terminal Delight with TD_AGENT_REST=0 in its environment. The header figures and the counter's card then stay empty, and panes an earlier window left asleep come back as plain shells; their wake files stay on disk5.

When a window quits or crashes#

A window that quits thaws every frozen pane of its session on the way out, so whatever opens next finds them awake. A frozen group whose pane the window doesn't show is thawed on every look. A crash skips the thaw; a window of this build that finds a pane frozen takes it over and thaws it on the first key. An older build knows nothing of rest, and its panes stay frozen until you thaw them by hand3:

for f in /sys/fs/cgroup/user.slice/user-$(id -u).slice/user@$(id -u).service/app.slice/td-pane-*/cgroup.freeze; do echo 0 > "$f"; done

What would prove this wrong#

A pane frozen while it was focused, while you were typing, or while a command ran under its agent would mean the rules above failed. So would an asleep pane that no key brings back, or a wake that started a second process on a conversation already open somewhere else.

Sources

  1. The rules, the thresholds, the refusals and the rebuilt command line: agentrest.rs.
  2. One look at one pane, the saved-conversation check, the wake file and the rest record: agentrest_io.rs.
  3. Memory groups, freezing, reclaim, the readings and the quit thaw: panegroup.rs.
  4. agents.toml: agentcfg.rs.
  5. The 15-second look, waking, the Agents page, the memory card and TD_AGENT_REST: main.rs.
  6. The header chip and memory figure, the sleep card, Keep awake and Sleep now: pane.rs.
  7. Every label as printed: lang/chrome.rs and lang/parts.rs.
  8. list_panes: mcp.rs; sleeping agents on the Floor: threshing_floor_view.rs; the note to a woken worker: prompt.rs.
  9. Which UI sets show the 🤖 glyph and the counter: clean.toml, standard.toml; the glyph chips: uiconfig.rs.