Answer
How should long-running agent tasks be structured?
As stages, each ending in a written output, so the state of the work lives on disk rather than in the session.
As stages that each end in a written output, so the state of the work exists on disk rather than in the session. Anything held only in the conversation is lost at the first interruption and degrades before that.
Long runs fail in a particular way. Early decisions become less influential as the session extends, intermediate findings get summarised and then summarised again, and the version of the plan the system is working from gradually diverges from the one it started with. None of this announces itself. The output stays fluent and the work stays confident, and the divergence is visible only when someone compares the result against the original intent.
The structural answer is to stop treating the session as the place the work lives. Each stage should end by writing something durable: a findings file, an updated plan, a record of decisions taken and why, a list of what remains. That artefact is then re-read at the start of the next stage rather than recalled. The difference between reading and recalling is the whole of the reliability improvement, because a file does not degrade and a summary of a summary does.
Three artefacts do most of the work. A plan that names the stages and their finished conditions. A decisions record, appended to rather than rewritten, saying what was chosen and on what grounds. And a state file that says where the work is now and what the next step is. The decisions record earns its keep on long jobs specifically, because the most expensive long-run failure is the quiet reversal of an earlier choice, and a system that can read what was decided and why will contradict it far less often than one relying on what it recalls.
Stages should also be sized to their checks rather than to their content. A stage whose output cannot be evaluated until three stages later is a stage that can be wrong for three stages, and the cost of the error compounds with everything built on it. Where possible, arrange the order so the checkable work comes first and the work that depends on judgement comes after something has confirmed the foundation.
Interruption should be assumed rather than handled as an exception. Sessions end, limits are reached, machines restart, and someone will need to stop the work halfway. If the state file is current, resumption costs a read. If it is not, resumption means reconstructing the situation from an output nobody can now verify, and in practice teams restart instead, which is the real cost of an unstructured long run.
Finally, keep the running context small deliberately rather than letting it accumulate. The natural trajectory of a long run is that everything encountered stays present, and the material that bears on the current stage becomes a shrinking fraction of it. Writing findings out and then working from the written summary — rather than from the whole history — is what keeps the later stages as sharp as the early ones.
In a long agent run the file on disk is the work and the conversation is a rehearsal of it, which is why the file has to be written as you go.
Siddharth Sharma, Context Theory
Related questions
How often should state be written?
At every point where losing the work since the last write would be annoying. That is a practical rather than a theoretical answer and it lands most people at the end of each stage plus any moment where something was discovered that would be expensive to rediscover. Writing too often costs almost nothing; writing too rarely costs the stage.
Does this apply to a task that takes twenty minutes?
Partly. A short run does not need staging, but it benefits from the same discipline of writing the result somewhere durable rather than leaving it in the conversation. The threshold is not duration but whether losing the session would mean losing the work, and that becomes true earlier than most people expect.
METHOD
Every figure below carries its source and the date it was verified. Nothing on this page is asserted.
The numbers on this page.
| What | Value | Specific to |
|---|---|---|
| Sub-15-minute compliance — automated routing vs manual only | 62.5% vs 39.1% | Category-wide |
| Close rate — response under 5 minutes vs over 24 hours | 32% vs 12% | Category-wide |
2026 speed-to-lead benchmark · verified
Optifai speed-to-lead benchmark · n=939 companies · Q2 2025–Q1 2026 · verified
What is specific to this page.
| Kind | Claim | Check it against |
|---|---|---|
| Workflow | In a long run the working plan diverges from the original silently, because early instructions carry decreasing relative weight while intermediate findings are progressively re-summarised, and neither change is visible in the fluency of the output. | Comparing the plan an agent describes late in a long session against the brief it was given at the start. |
| Software | Re-reading a written artefact and recalling a summarised one behave differently over a long run, because a file does not degrade while a summary of a summary loses specificity at each pass, which is why stage outputs must be durable rather than conversational. | Comparing detail retained in a written stage output against the same content recalled after several intervening stages. |
| Response | An append-only decisions record with reasons is the specific defence against the most expensive long-run failure, which is the quiet reversal of an earlier choice, because a reader can check whether the recorded reason still holds. | Auditing a completed long run for choices that were made, reversed and not acknowledged. |
| Buying behaviour | A stage whose output cannot be evaluated for several further stages allows an error to compound through everything built on it, so ordering checkable work ahead of judgement-dependent work lowers the cost of being wrong. | Identifying, for each stage in a plan, how many subsequent stages would need redoing if it were wrong. |
Each row would be wrong on another industry's page. Where a sourced figure exists it is in the table above instead; these are the constraints that shape the work and do not happen to be numbers.
Start with the measurement.
Reading about a benchmark is not the same as knowing your own number. The audit produces yours, measured rather than estimated.
$497 · delivered in 5 business days · credited against month one