How do I put a limit on an AI agent that runs overnight?
Two caps stop an unattended agent from burning through your queue: a per-task budget Done enforces at start_run, and a whole-night cap the agent checks between tasks. What each does and doesn't enforce.

By Alejandro Rioja6 min read
Use two caps, because they stop different things. A per-task budget (tool calls, minutes, or both) limits how much one task can consume, and Done enforces it: start_run is refused once the task has spent its whole budget. A night cap (tasks, minutes, tool calls) limits the whole session, and the agent has to ask for it: it calls check_night_budget between tasks and stops when the answer says stop. Neither one kills a process mid-tool-call. Done doesn't run your model, so a cap is something the agent is told and the record holds it to, not a kill switch.
Why isn't one cap enough?
A budget on a single task can't see the other eleven. An agent that handles each task within its budget can still work all of them in one night. The reverse also fails: a night cap with no per-task budget lets one stubborn task eat the entire allowance. The per-task cap bounds the worst single task; the night cap bounds the sum.
How does the per-task budget work?
A human sets budget_tool_calls and/or budget_minutes on a task. An agent can't set or raise its own: create_task and update_task refuse those fields, and the agent's route to more is ask_decision, which asks you.
- start_run opens a run on the task and returns the budget and cumulative usage so far, so the agent can pace itself. If the task has already spent its whole budget across earlier runs, start_run is refused with budget_exceeded, and a person has to raise the budget or take the task over.
- check_budget reads the remaining budget without opening a run. Mid-task, over_budget: true means stop and hand back.
- end_run records what the run spent. A run that goes past the budget can still be closed; it is recorded as over_budget. So the hard stop is at the start of a run, not in the middle of one.
How does the whole-night cap work?
In Account & settings → Where agents run → Overnight routine you choose when a run should stop: after a number of tasks, minutes, or tool calls. The agent calls check_night_budget between tasks. It returns the cap, what's used and what's remaining for each dimension, plus stop and a reason. The default window is the last 12 hours, so last night's spend doesn't count against tonight's.
The totals are counted from the runs recorded on your account, not from a counter in the agent's memory. If the routine crashes and restarts mid-night, it picks up the same totals instead of starting from zero and quietly doubling the night. Only your own runs count against your caps; a teammate's runs in a shared workspace don't.
When stop is true the instruction to the agent is: end_run with a summary, release_task so the claim doesn't strand the task, and leave the rest queued. The summary matters. A night that stopped at four of eight tasks reads as everything handled unless the agent says what it left undone.
Does Done actually stop the agent at the night cap?
No. check_night_budget is advisory: it is a read that tells the agent to stop. An agent that never calls it is never stopped by it. The Copy runner prompt button in Where agents run (the instruction your scheduled run follows) tells the agent to call start_run at the top, check_night_budget before each task, and end_run at the end, so a run built from it does. If you write your own runner, put those three calls in.
What does hold regardless of the agent: the approval gate. Whatever it spends, a task that isn't marked agent_ok can only reach done through your approval, so a runaway night produces a longer review queue, not a pile of closed tasks. And pause_board, or the pause in the app, stops every agent on the board from being handed work until you resume it. The agent can call it too, for the case where it sees the whole run going wrong.
How do I see what a night actually cost?
Each run leaves a trace in the task's activity, with tool calls, minutes and, if the agent reports them, tokens, and an optional trace_url to the session transcript. get_agent_economics reports runs, tool calls and minutes per agent and the approval rate on that work, in units only. Done stores no currency figure, so it won't tell you dollars.
A sensible starting setup
- Run unattended only on tasks with acceptance criteria, so the agent knows what done means.
- Set a per-task tool-call budget on anything open-ended; leave short tasks uncapped.
- Set a night cap that stops well before you'd be upset: a few tasks and a time limit, then raise it once a few nights have gone well.
- Use the runner prompt, or make sure your own runner calls start_run, check_night_budget and end_run.
- Read the morning's Needs you: what shipped, what is waiting on approval, what is waiting on an answer.
Frequently asked questions
Can an AI agent raise its own budget?
No. create_task and update_task refuse budget_tool_calls and budget_minutes. To ask for more, the agent calls ask_decision and a person decides.
What happens when a task runs out of budget?
start_run is refused with budget_exceeded, so no new run can begin on that task until a person raises the budget or takes it over. A run already underway isn't killed; if it exceeds the budget, end_run records it as over_budget.
Is the overnight cap enforced by Done?
No, it is advisory. check_night_budget reports the caps, usage and a stop flag, and the agent is expected to stop when it says so. The runner prompt Done gives you includes that check; a custom runner has to call it.
Does the night cap reset if my routine crashes and restarts?
No. Usage is summed from the runs recorded on your account in the window (12 hours by default), so a restart sees the same totals instead of starting from zero.
How do I stop every agent at once?
Pause the board. No agent is handed work until you resume it. See the post on pausing an agent that's stuck in a loop for the difference between pausing a task and pausing the board.