Going the distance
Quota used up, context full, end of session: keep a long task alive through what threatens it before the end
- Module
- Module 08
- Deliverable
- passation.md recounted line by line, and tenir-la-distance.md: the cost of a stop provoked in the middle of a step, the false statements in the handover, and what the resume in a fresh session redid
- Access
- preview
Before you read
- What you will be able to do
You write instructions so that a cut-off leaves only each agent's current step unfinished, and every fresh session starts by checking the file it restarts from.
- What you will do
- Action 1: Write into the instructions when to commit
- Action 2: Recount a handover
- Action 3: Take the inventory of an agent's folder
- Action 4: Write the resume instructions
Then the exercise: Une coupure simulée, une passation recomptée, une reprise en session neuve (in French)
- Time
29 min reading, 150 min exercise
- Updated on
- Before you start
- Words used in this module
- toolThe software that runs your coding agents, and has them read, at launch, the project's instructions files, where you write the rules of the project.
- sessionA conversation with the tool, from the moment you open it to the moment you close it, by quitting the tool or by clearing the conversation.
- agentA session you open, or a subagent: a secondary conversation that a session starts and hands part of the work to.
- fleetAll the agents working for you at the same moment, sessions and subagents together.
- instructionsThe text an agent receives at launch, from you, from the session that launches it or from the instructions files the tool has it read: what it must achieve, what it must not touch, facts about the code.
- stepOne part of a long task, finished when a terminal command (a test or a script, for example) says its work is done and the agent has committed it.
- quotaWhat you can consume on your subscription over a given period, for all your agents together.
- cut-offThe stop of all your agents at the same time, when the quota is used up.
- contextEverything an agent has in front of it when it answers: the conversation, the files read, the command outputs. Its size is counted in tokens, the units of text the language model behind the agent reads, and has a maximum.
- automatic summaryThe summary of the conversation that the tool writes itself when the context nears its maximum, and that replaces the history.
- handoverThe document a session leaves to the next one so that it can resume the work; here, a file the agent writes at your request before stopping.
- fresh sessionA session opened without the history of the previous one.
What interrupts a long task
Two agents have been redoing application screens for sixteen minutes. They stop together, on the same message: the subscription's quota is used up. When the quota comes back, one has left 69 modified files, the other 74, and no commit. The code compiles on both sides, but nothing says what was finished, or where each agent had got to.
Write the instructions of a long task so that the task can stop at any second without leaving more than one unfinished step per agent. The task must also be able to resume in a session that saw nothing of the previous one.
A session, here, is a conversation with the tool, from the moment you open it to the moment you close it, by quitting the tool or by clearing the conversation. The tool is the software that runs your agents. An agent is a session you open, or a subagent: a secondary conversation that a session starts and hands part of the work to. At launch it receives its instructions: the text that tells it what to do. They come from you, from the session that launches it, or from the instructions files the tool has it read: files in the repository where you write the rules of the project for your agents. A long task is split into steps: a step is finished when a terminal command (a test or a script, for example) says its work is done and the agent has committed it.
Three events threaten a long task, and no agent decides any of them.
The quota is what you can consume on your subscription over a given period, for all your agents together. When it is used up, all your agents stop at the same time: that is the cut-off.
An agent's context is everything it has in front of it when it answers: the conversation, the files read, the command outputs. Its size is counted in tokens, the units of text read by the language model that makes the agent answer, and has a maximum. When the context nears it, the tool summarises the conversation itself and replaces the history with that summary: that is the automatic summary. Claude Code calls it compaction.
The third is you closing the session. What then passes to the next one is the handover: the document a session leaves to the next one so that it can resume the work. Here, it is a file the agent writes at your request before stopping. A fresh session, opened without the history of the previous one, reads this file to resume, and corrects it where it is false. This is called a cold resume.
| The event | Who triggers it | When | What survives |
|---|---|---|---|
| The cut-off | The quota, used up | At the moment it runs out, for all your agents at once | The files on disk. Once the quota is back, the session that launched the subagents can resume its conversation. Its subagents do not restart on their own, and did not tell it where they had got to |
| The automatic summary | The tool | When the context nears its maximum, wherever the agent has got to | A summary the tool writes and that you do not read before it is used |
| The end of session | You | At the moment you choose | What the handover says, and what has been checked in it |
The first two events take no account of your steps: they can fall in the middle of one. The third is the only one whose moment you choose: stop the session at the end of a step, before the context nears its maximum. The cut-off falls without warning: the agent works until the moment its requests are refused. What then protects the work is the commits made at each step (section further down): they say which part is finished.
The session that launches the subagents cannot save anything at the moment of the cut-off: it stops at the same time as they do. So what survives is decided in each agent's instructions, before launch.
When this module is useless
If you launch one agent at a time, on short sessions whose context never fills up, this module is of little use to you. The conversation itself serves as memory, and you have nothing to pass to a next session. Stop reading here, and come back the day your sessions last longer, or the day an agent stops in the middle of a task on a used-up quota or a full context.
If you pay by usage, with no quota, the cut-off does not exist in this form: your limit is a bill, and module 5 deals with it. The sections on the automatic summary, the handover and resuming the work concern you as soon as a session nears the maximum of its context.
A cut-off stops all your agents at once
On a subscription, your whole fleet consumes the same quota. The fleet is all the agents working for you at the same moment, sessions and subagents together. When the quota is used up, everything that is running stops within the same minute, including the session that launched the subagents. A stopped subagent returns no report: what it did exists only on disk, and only if it wrote it there.
Two consequences for your instructions:
- launching more agents does not give more quota. It increases the number of tasks stopped in the middle when it runs out;
- the session that launches the subagents cannot save anything for them, since it stops at the same instant. All that remains is what each agent wrote on disk itself.
Have each step committed as soon as its command passes
Split the task into numbered steps before launch, and write down in your notes the commit each agent starts from: its starting commit. Then, in the instructions of each agent that modifies files, say when to commit: as soon as a step's command says its work is done, never in one single final commit. After a cut-off, a step without its commit is not finished, even if its command passes: its work is among the pending files, meaning modified, created or deleted, but not yet committed. If the agent commits at each step, only the step in progress stays unfinished: everything before it is committed, and each commit message says which step it closes. Without these commits, you no longer know which part of the task is finished, even when all the files are on disk. Ask an agent in charge of research, which does not touch the code, to write its results in a file as the work goes. Otherwise, after a cut-off, they remain only in its session log, where no agent goes looking for them.
Three details make this line useful:
- the commit message starts with the number of the step. After a cut-off, you read where the agent had got to without rereading the diff;
- an architecture decision is written in a file of the repository before it is coded. If it is stopped afterwards, the agent leaves at least the reason for what it did;
- the instructions say why. Write "Commit each step as soon as its command passes, because a quota cut-off stops all the agents at once". Whoever shortens the instructions later will see why the line is there, and will keep it. "Commit in steps", without its reason, risks being removed by someone who believes they are simplifying.
Module 6 already asks the agent to note its decisions and their reasons, to check them after the fact. Written in a file of the repository, they also serve to resume after a cut-off: they say why the code is the way it is.
Action 1: Write into the instructions when to commit
Take the instructions you plan to give your next agent on a long task: the text you will write for it, or the instructions file your tool will have it read. If its steps are not numbered, number them first. Then look for the line that says when to commit. If it is missing, does not say when, or does not say why, rewrite it. The line asks for the number of the step at the start of the message, and gives the cause of the rule. For example: "Commit each step as soon as its command passes, with the number of the step at the start of the message, because a quota cut-off stops all the agents at once."
Expected result: The instructions contain a line that asks to commit each step as soon as its command passes, with the number of the step at the start of the message and the reason for the rule written next to it.
Still in this module:
- Stop the session before the tool summarises
- Recount the handover before you believe it
- Write a handover that can be checked
- Resuming after a cut-off
- In practice
That is about 3,305 words, and the exercise with its deliverable template.