Chapter 45
Keep an agent running
An agent you rely on — one you reach from your phone through Remote Control, a workspace's manager, a helper that watches a queue — should come back when its program dies.
On this page
An agent you rely on — one you reach from your phone through Remote Control, a workspace's manager, a helper that watches a queue — should come back when its program dies. Kept running means exactly that: Dozable restarts the agent's program on this Mac when it exits or dies, in the same folder, with the same command, resuming the same conversation. It never restarts an agent because it is quiet: an agent thinking for an hour, or waiting for you, is left alone.
Keeping one#
doz run @mac --keep --session admin -- claude --session-id "$(uuidgen)" --remote-control admin
doz sessions keep @mac admin # an agent already running
doz sessions unkeep @mac admin # no longer kept: it runs on, and is not restarted when it endsA workspace's agent on this Mac is kept with the workspace:
doz worker add W ana --task "Watch the queue" --keep
doz workspace edit W --keep-agent ana
doz workspace edit W --no-keep-agent anaIn a space file, restart: on-failure on an agent keeps it running (the held key x-dozable.keep: {} says the same; restart: no beside it is refused). The file decides again at each doz space up.
In the dashboard, an agent's row (a workspace's Agents tab) and its pane on This Mac have a Keep running switch. It works only in this Mac's own browser; another computer sees it, and is told to use this Mac.
What restarts it, and what does not#
- Any exit restarts it: a crash,
kill -9, and quitting the program yourself — typing/exitin Claude Code restarts it too. To stop it, end it (below) or unkeep it. A space file'srestart: on-failureis the exception: it restarts the agent when it fails, never after it exits by itself (exit 0,/exit) — it then shows "it exited" and runs again when you start it;restart: always(space/3.2) restarts any exit. - You ending it never does.
doz sessions end @mac admin,doz worker end, a workspace's stop or sleep: the agent stays kept, but is not restarted until you start it again (doz sessions restart @mac admin, or the workspace's wake).doz sessions endsays so. - Silence never does. There is no watchdog on what the agent prints. A long resume of a long conversation is not a death either: only the program ending counts.
- Shutting down your Mac is not a crash. An agent that ends while Dozable itself is stopping (a shutdown, a restart, a logout,
doz daemon stop) is not counted toward its restarts: it starts again when Dozable next starts from your login. - Claude Code resumes its own conversation. The restart resumes the conversation the agent held, with the same flags —
--remote-control admincomes back as--resume ID --remote-control admin, the same Remote Control session on your phone (see Sessions on this Mac, "Sleep, logout, restart"). - The variables you gave with
-eare never stored, so a kept agent could not have them after a restart:--keepwith-eis refused. Put them in the program's own configuration.
Keeping is consenting#
Keeping an agent is your consent for Dozable to restart it when it dies and to start it when you log in. There is no second step, also for an agent with No fence whose command bypasses its permissions (--permission-mode bypassPermissions, --dangerously-skip-permissions), which acts as you with nobody watching.
A Fenced Claude Code agent kept with a bypass is not asked Claude's "bypass permissions" question at each start: keeping it answered that question, so its private Claude folder records it as accepted. One that is not kept still asks.
- Who may keep one. Anyone who could start it the way it runs. That is you, an agent that runs as you (No fence, on your login), or a trusted agent (one you gave the
superadminrole). A Fenced helper may keep a Fenced helper, but never a No-fence or bypassed one; its refusal says who may.doz config set trust.agents_act_as_you falsemakes an agent that runs as you count as any other agent for this. Only you change that setting. - More power clears it. A change that makes the agent more powerful clears "kept" until someone allowed keeps it again: a looser fence, a bypass it didn't have, another program or another folder. Dozable says so on This Mac's page. A new model, a name, a resumed conversation or a flag that narrows it never clears it.
- Every keep says who made it: "kept by you", "kept by gm for you", or "kept by a Claude Code agent (session …) for you" when a Claude Code terminal session ran the command. It shows in
doz sessions @mac, the agent's status,--jsonand the log. - Done for you.
doz daemon done-for-youlists what agents did as you, newest first: agents kept, roles granted, unfenced starts confirmed. Each one that can be undone has an undo (--undo ID, which unkeeps or takes the role back). Once a day the acts that matter most are summed up in This Mac's Needs you. - Trust is yours alone. Only you make an agent trusted (
doz permissions grant NAME superadmin --everywhere) or take it away. An agent can't, and nor can a command run from an agent's shell. Taking it away suspends what that agent kept: each one waits in Needs you until it is kept again (doz sessions keep @mac NAME).
doz sessions consent @mac NAME --start-at-login and doz agent consent W/NAME --start-at-login, the old way, still work for one more release. They keep the agent, and say so.
The safety net is the restart cap. With no consent step, a broken bypassed agent is stopped by the cap below: 5 restarts with no ten-minute run, then it stops restarting, and its manager is told in the workspace's room (you, on This Mac's page, for an agent in no workspace). Look at why it keeps dying before you start it again.
When it can't start#
A command that can never start (a typing mistake, a program that is not installed) exits at once. When it exits twice in a row with the same error, each time within 5 seconds of starting, Dozable stops at once and says so, with the last line it printed:
kept · stopped: it can't start (exit 127 twice, each within 5 s of its start) — its last line: zsh: command not found: claudWhen it keeps dying#
Each restart waits a little longer while the deaths come quickly: 2 s, then 10 s, 60 s, and 300 s after that. A run of ten minutes starts the count again. After 5 restarts with no such run, Dozable stops restarting it, so a broken agent does not spend your account's usage over and over:
admin — ended (exit 1) · kept · stopped restarting after 5 restarts in 7 minAn agent on this Mac that is in no workspace has no room: Dozable tells you on This Mac's page, and in doz daemon status (needsYou in --json, which the menu bar reads). Each restart is there too, with what it lost. What needs you clears by itself when its cause does: you restart, unkeep or end the agent. A notice that only informs (a restart, a Remote Control nudge) goes after a day, or when you dismiss it: Dismiss on This Mac, or doz daemon dismiss ID.
For a workspace's agent, Dozable says it in the workspace's room — a notice from the health feed, and an Ask to you: Restart again or Leave it stopped. Restart again starts it at once, with the count cleared. For any kept agent, doz sessions restart @mac NAME does the same.
Seeing it#
$ doz sessions @mac
SESSION PID STATE …
admin 48211 running · no isolation · kept · restarted 2× (last 09:02, after exit 137)doz sessions @mac --json gives each kept agent a keep object: its state (kept, restarting, stopped-restarting, waiting, ended-by-you), total restarts, lastExit, lastExitAt, lastRestartAt and lastRestartBy, nextAt while a restart is due, and stoppedWhy. doz workspace state W shows the same line beside each agent's condition, and its --json carries the same keep. A workspace's log says each restart ("ana restarted") and when one stopped restarting. The dashboard shows a chip — Kept running, Restarting in N s, Stopped restarting — and the Kept running line.
The daemon and the login#
With chat on, the chat server keeps the daemon running even when always on is off: doz daemon status says so. doz chat off lets it exit when idle.
A kept agent keeps the daemon running: it does not stop at its idle timeout while an agent is kept (a stopped or ended one does not count). With the login item on (doz daemon login-item on, Sessions on this Mac), a kept agent is reason enough to start the daemon at login, even with daemon.always_on off; when nothing is kept any more, the login item goes again (unless always on keeps it).
Each Dozable keeps only its own agents: a second Dozable on the same Mac (another store) never restarts, counts or touches this one's.
Watching Claude Code#
Dozable reads the bottom of each Claude Code agent's screen on this Mac, and only reads it. It never answers a question for the agent.
- Remote Control. An agent started with
--remote-controlsometimes loses Remote Control: it does not come back after a restart, or it disconnects (signing in with/loginin another Claude does that). Dozable then types/remote-controlinto it, but only when its screen is idle: an empty prompt and nothing running. It never types while the agent works, however long the turn, or while you have text in its prompt. It waits a few minutes after a restart first, because a long conversation takes time to resume. It types at most once after each restart, and for a disconnection at most once in 10 minutes and 3 times an hour. Each time is said: "Remote Control turned back on" in the room or on This Mac, and as a mark beside the agent.doz config set mac.remote_control offstops the typing; the marks still show. - Account trouble. Only an error on its screen counts: a login that expired, an account that is spent, a key that is refused. Switching accounts is not trouble. A kept agent then waits for you and is not restarted for it: you see it on This Mac's page, in the menu bar ("1 agent needs you"), in the room and in
doz daemon status. It clears by itself when the error leaves its screen or this Mac's Claude login is good again, or when you restart it. - Claude's bypass question. When Claude starts in Bypass Permissions mode it can ask you to accept that ("No, exit / Yes, I accept"). A Fenced agent you keep has it answered in its own private Claude folder (keeping it is your consent), so it is not asked at each start. Otherwise Dozable never answers by itself: the agent waits for you ("Claude asks you to accept bypass permissions"), shown on This Mac, in the menu bar and in
doz daemon status, until you answer it in the agent (doz attach @mac NAME) or withdoz sessions answer @mac NAME bypass.doz doctornames a kept Fenced agent that will ask. - Claude's folder question, and pre-trust. The first time Claude runs in a folder it asks whether to trust it. A Fenced agent and a sandbox are never asked. For an agent with No fence, Dozable pre-trusts the folder before it starts: it marks that one folder trusted in your
~/.claude.json(nothing else of the file changes), when whoever starts it may start it that way — you, an agent that runs as you, or a trusted agent. Each pre-trust is in Done for you ("pre-trusted ~/work/x for Claude, for gm").doz config set agent.pre_trust falseturns it off: then such an agent waits at Claude's question (it reaches you, or its manager in the Agents feed), anddoz worker answer W NAME trust(ordoz sessions answer @mac NAME trust) answers it. - Answering Claude yourself, or by an agent.
doz sessions answer @mac NAME trust|bypass|continueanddoz worker answer W NAME trust|bypass|continueanswer only the question the agent's screen shows: its folder, bypass permissions, or its first-run security notes ("Press Enter to continue"). Any other answer is refused and nothing is typed. You may always answer; an agent may only when it is trusted, or when it manages that agent with the agent.health grant. It is never automatic, and each answer is in Done for you. - Marks. Claude's own question whether to trust a folder, a login that expires in a few days, and Remote Control's state are shown beside the agent in
doz sessions @macand on its card. - Bypass. When its footer says "bypass permissions on", or Claude's settings set it, the agent counts as bypassing its permissions even though its command does not say so:
doz sessions @macshows "bypass: from its settings" or "bypass: from its screen", and the consent rule above applies.
doz doctor with a kept agent also checks what would stop it coming back by itself: sleep, automatic login, FileVault, whether Claude trusts its folder, and this Mac's Claude login for Remote Control.
Not in this version#
- An agent in a Sandbox is not kept (its
restart:in a space file is noted, not applied). - Starting a kept agent at login and replacing one left in a login that has ended: After a restart or a lost login.
Who looks after it#
A workspace's agent is looked after by its manager. Each problem with it (it died and was restarted, what the restart lost, it stopped restarting, it can't start, its conversation is gone or open in another Claude, Claude waits at a question or its first-run security notes, the network is in trouble) is a notice of the Agents feed in the workspace's room, where the manager reads it; only what needs a person (an account, Claude's own question) is also in This Mac's Needs you. An agent in no workspace has no room: its notices are in This Mac's Needs you.
To see an agent's health at once (read-only):
doz worker status W NAME: its state, whether it is kept, its restarts and last exit, the last line it left, what its last restart lost, its conversation id and display name, what it waits for, and the fix with the exact command;doz worker ls W --health: every agent of the workspace, problems first;doz sessions status @mac SESSION: the same for a session on this Mac.
Each says who acts: the manager (restart it) or you (a login, an account, Claude's question). --json gives the same facts.
A manager acts on its helpers with the agent.health grant on its workspace (doz permissions grant W/gm agent.health=allow --in W). Without it, it can read their health but not act, and it tells you instead. Run from the manager's own shell, these use its own token (its CHAT_TOKEN_FILE and CHAT_URL), so it is held to its grant:
doz sessions restart @mac SESSION(with--conversation IDto resume a chosen conversation),doz sessions end,doz sessions keepandunkeep;doz sessions find-conversation @mac SESSION [--folder DIR]: when an agent's conversation is lost (its folder moved, or a reboot lost its record), this lists the Claude conversations of its folder, newest first. Each comes with its name and its first and last lines.doz sessions restart @mac SESSION --conversation ID --folder NEWthen resumes the chosen one from the folder's new place. Claude's own files are only read.
What stays yours: logins and account trouble, Claude's own questions (trust, bypass, its first-run security notes) and who is trusted. A manager escalates those with one line and the exact command.
When Claude's conversation is in two places#
Dozable never starts or restarts an agent into a conversation that another Claude has open, because two Claudes would write one conversation. doz run and doz sessions restart refuse and name the other one. A kept agent waits as held-elsewhere, and restarts once the other one lets go.
A /rename inside Claude survives a restart: Dozable reads the name Claude shows and restarts with it.
Network trouble#
Every 5 minutes, and after any restart Dozable makes, the daemon checks DNS and the model's API. If either fails while your login is live, doz daemon status says network trouble since HH:MM and doz doctor warns in its network row. This Mac's Needs you has it too, and each workspace that keeps agents gets a card in its room. So a manager can tell "my helper is idle" from "my helper can't reach its model". All of it clears when the checks pass again. Nothing is restarted because of it.
A Claude Code conversation you started yourself, in a terminal, can be moved into Dozable, and it is kept from the start: doz agent new gm --from claude:ID --no-fence (--no-keep leaves it unkept; Continue an agent you already run).
Edit this page on GitHub · Chapter 45 of 50