Long-Horizon Agents

How agents keep working toward a goal across sessions, interruptions, and context resets.

A session counts only when it commits a handoff for the next one, never on the agent's word. Of 81 recorded sessions, 76 did.

By Justin Bartak. Updated .

An agent's context is finite and its session ends. A goal that takes weeks has to survive both, and survive the agent's own report of how far it got, which can be wrong or missing.

A long-horizon agent works one goal across many sessions. No single session holds the whole job, so what carries the work forward is what each session leaves in the repository for the next.

Our handoff loop is how we run one. Each session, which the loop calls an iteration, is a fresh process that ends by committing a handoff: a file telling the next session what is done, what is open, and in what order to take it.

The loop decides whether a session counted by looking for that commit in the repository, never by reading the agent's last line. That check is the gate, and a session that passes it has landed. The loop's committed record holds 81 iterations across 16 runs of the loop over 63 hours, from to . Of them, 76 landed, 12 through a closer, a separate short run that commits what an iteration left unfinished.

What is a long-horizon agent?

An agent working toward one goal across sessions, interruptions and context resets. The hard part is not any one step. It is keeping the steps pointed at the same goal when no session remembers the last one.

Two different things get called long horizon. Long-horizon reasoning is a model holding one plan together inside a single context. Long-horizon execution is carrying a job across many contexts. This page is mostly about the second, because that is what we run.

These are working definitions, not a standard. Other writers draw the line between the two in other places.

What can this page not see?

The limits come first:

  • The loop's committed record covers 63 hours, to . Nothing later is in it, and why the record stops has its own section below.
  • One loop, one repository, one model. Nothing here compares this loop with another design.
  • The record says whether a handoff commit landed. It does not grade whether the work in that commit was good.
  • The arc runner for one goal across many sessions is built and has not run an arc, so it has no record to show.
  • No causal claim. Nothing here has a controlled comparison.

How did the handoff loop come to be?

It started as a request from the founder on the evening of . Until then a person ended every session: the founder cleared a session's context himself and started the next one from the handoff it left. A runner built for one goal across many sessions had been installed a month earlier and never started. That evening he asked whether the agent could write its handoff, clear its context and pick the work back up without him:

I want you to be able to do this without me.

Justin Bartak, the founder, asking for the loop,

A session cannot clear its own context, so the answer that night was a script that ends each session and starts a fresh one from what the last one committed. It was written and committed the same night and was not scheduled. Starting it was left to the founder, because an unattended loop spends the weekly allowance the whole company runs on.

Its first real iteration ran that night, and its first order was one it could not carry out. The orders said to fetch, rebase and push the night's work, but the iteration's permission list, written hours earlier, named no push to main and no rebase. The push went through only because a broader permission sat in a local settings file on the founder's machine. The iteration added exactly those two commands to its list, nothing wider, and a test now reads the orders and the list together. It was meant to run with nobody in the room; the founder ended up pushing twice from another session while it worked.

On a fresh copy of the repository every one of those iterations would have ended with the work unpushed and a handoff saying so, and the gate would have counted each one as landed, because a handoff about not pushing is still a handoff. That is the gate's limit, met on the first night: a landed handoff proves a commit, not progress.

The next day he asked for more: a 24-hour sprint, run without him, which he called a long-horizon run. He had just asked whether the loop would keep going on its own, and the answer was no: every run that day had ended with a stop, three of them on a dirty tree, and four of the six iterations had spent every turn they were given. So the loop gained a deadline, a queue behind a loop already running, and a way to tell the agent failing from the service saying no. It also stopped calling itself done when its queue was empty. From that day, an empty queue with any part of done still open meant refill the queue, the rule the section on how reasoning survives a session boundary describes. The rows the figure below is drawn from begin on , so the loop's first nights are not in them.

At half past three on the morning of he asked whether the sprint would keep going without him. The answer written down was no, not all of it. The loop would keep writing handoffs, but work handed to a second coding agent sat finished and unchecked, because the only thing that checked it was a session that woke when something told it to. Four finished jobs had waited half an hour that way. Within the hour the loop's orders gained that lane: every iteration now opens by checking the second agent's finished jobs and landing what passes, and a separate launcher starts new ones, never more than four at once, because he said four or less. It was committed that afternoon.

This story is told from the Book LOG and the commits that carry it. The quote is the founder's message as the Book LOG records it; the rest paraphrases.

What is long-horizon reasoning, and where does it stop?

Long-horizon reasoning is a model holding one plan coherent across many interdependent steps: what it decided, why, and what it ruled out. Benchmarks built to measure it, LongCoT and R-Horizon, find even the strongest models they tested falling well short of it. Inside one session it also ends outright when the context fills or the session closes.

Compaction, where the tool summarizes a long session to free space, does not save it: the summary is the agent's own account of itself, and Anthropic's harness post says compaction alone is not sufficient for long-running work. Its context engineering guide names three techniques for long-horizon tasks: compaction, structured note-taking, and sub-agents. A handoff is the second, written at the session boundary. What we keep on purpose, and what it costs to re-read, is context engineering.

We do not measure reasoning quality across a long context. Our own yardstick is in the next section.

How is long-horizon reasoning measured?

By how far a model gets before its plan breaks. The research on reasoning counts steps inside one chain of thought, and a neighboring yardstick counts task length:

  • Steps inside one chain of thought. LongCoT, published in April 2026, poses 2,500 expert-designed problems, and at release the best models it tested scored under 10 percent. R-Horizon chains short problems that depend on each other and reports that even advanced reasoning models do significantly worse on the chained tasks.
  • Task length in human time, which rates agents rather than reasoning. METR's time horizon rates tasks by how long they take a skilled human and reports the task length at which a model succeeds half the time, read from a curve fit across its tasks. It says nothing about sessions. METR revised it in January 2026 as Time Horizon 1.1, growing the suite from 170 to 228 tasks.

Our yardstick is a third one: whether the work crossed a session boundary, decided by a handoff commit landing. In the loop's record, 76 of 81 iterations crossed. The gate section below says how that is measured.

We have run neither benchmark and quote no model's horizon figure. The LongCoT figures above are from its abstract, and the R-Horizon finding from its own.

How do long-running AI agents keep executing across sessions?

By ending every session on purpose. A session cannot clear its own context, so the clear is a process boundary: the handoff loop starts each iteration as a fresh process, hands it the newest committed handoff, and lets it work the ranked list there.

Each iteration has a turn cap, 48 by default, and the loop writes that number into its orders, because the tool enforces the cap without showing it to the model. Before the cap the iteration writes a handoff, committed with the work it describes. The tool did stop iterations at the cap: all 16 that ended in an error recorded 49 turns, one over the cap, the count a cap stop leaves. But 41 that ended normally also recorded more than 48. So either the turn count the rows carry is not the count the cap limits, or the cap did not apply to those runs, and the record cannot say which. This page states the cap the loop sets, not a session length the record proves.

When an iteration ends with finished work still uncommitted, usually because it ran out of turns, a second short run, the closer, commits what is finished, records what is not, and writes the handoff.

The handoffs are the thread, and they are not only the loop's: sessions that end on a context clear write one too. That is why the repository's 200 committed handoffs start on , before the loop existed, and run to , after its record stops. Some later handoffs live in a local folder that is not committed, so that count is a floor.

A handoff is written by the session that is about to lose its context. What it leaves out, the next session cannot know is missing.

How does the reasoning survive a session boundary?

By being written down before the context goes. The plan a session was holding, what it settled and what it left open, has to be in the repository when the next session starts, because nothing the session held only in its context crosses.

In our loop, that record is the handoff. The command that writes one tells the session to sort what is open into the founder's decisions and the agent's work, ranked, so the next session knows what it may act on and in what order. It copies the founder's standing directive in full rather than linking it, and it carries forward every known pitfall from the last handoff that still applies, dropping one only with a reason.

The goal stays put while sessions come and go. Every iteration starts by re-reading the loop's orders. In this record they rank one goal above every task: the founder's Collective console, working and free of known issues. They define done as a checklist where every item needs a receipt in the handoff, among them no known defect open against it, every row of its spec the agents own marked done, the happy path walked end to end with evidence, measured test coverage at 98 percent or above, a refactor review landed, and a design review at A- or better. An empty task list is not done: the agent refills it from whatever the checklist still lacks. In 81 recorded iterations, none printed LOOP: DONE, the line an iteration uses to claim the goal is met.

The loop may not change those orders. A decision the founder logged on lets it propose a change for him to decide and never adopt one. That decision, made before the loop was configured to land its work through a check of its own, said such a change was caught after the fact, not prevented. From the landing check sent a commit that touches them to a pull request, never main; since it refuses one and holds it locally. No loop run under the landing check is proven.

Anthropic, which makes the model this loop runs on, describes the same pattern in its harness for long-running agents, published in November 2025. Each session starts with no memory of the last, and state travels in a progress file beside the git history. The post names the failure our gate exists for:

Claude declares victory on the entire project too early.

Anthropic, Effective harnesses for long-running agents,

The difference is where the check sits. In the post, a coding agent marks a feature as passing only after testing it, so the record of progress is still the agent's own. Here the loop measures progress itself, from the repository, but what it measures is narrower: that a handoff was committed, not that the work in it works. The post also has a first session, an initializer, set up the environment for the sessions that follow. This loop has no setup session; every iteration starts from the newest handoff.

The arc runner, below, is built to ask for more of the reasoning in writing: the goal kept verbatim in its ledger, a drift line in each iteration block comparing the next step with that goal, and, for a choice of approach, three paths weighed and an argument against the one picked. No hook enforces the drift check.

Nothing grades a handoff, and nothing here measures whether the next session followed its ranking.

Why is progress not completion?

Because the agent reporting progress is the thing being judged. Each iteration ends by printing a line, LOOP: CONTINUE or LOOP: DONE. The loop records that line as the agent's claim and never decides the gate from it. A claim of DONE does one thing: after a landed handoff, it ends the loop.

The gate is a measurement: a new commit touching a handoff file, made during the iteration. No such commit, and the iteration did not land, whatever its last line said.

We learned that the expensive way. Until the run of a seat, one of the agent roles that run the company, was judged complete by a token the agent had to print in the right place, and a complete weekly report from the changelog seat was discarded because the token sat on the last line of the report file instead of the final message. The ruling that day made the token a recorded claim and the system's own measurements the gate.

In the loop's record the two disagree five times in 81, and not the way the warning above suggests: no iteration claimed DONE, so the record holds no false finish. One iteration, finished by a closer, claimed CONTINUE and was stopped for a person. Four iterations ended in an error before printing any claim, each with its handoff already committed, so each landed. A gate that read the last line would have counted those four as failures.

An interruption is not a loss here either. Sixteen iterations ended with the command-line tool's error flag set, and 14 of them still landed, because the gate reads the repository, not the exit. The rows do not record which error, but the snapshot of the loop's logs does: of the 155 run files it could read, iterations and closers together, 24 ended at the turn cap and none in any other error. Every errored row recorded 49 turns, one over its cap, the shape a run the tool stops at its cap leaves, and 10 needed a closer to commit what they had left.

Every handoff loop iteration: what the agent claimed, and what the gate measured

81 iterations in 16 loop runs, 76 landed. No iteration claimed DONE. The claim and the gate disagreed on 5 iterations. The 4 that landed with no claim ended in an error before printing one, after committing a handoff.

Landed: a new handoff commitRetry: no new handoff commitRefused: the run did no workStopped for a personDot: the agent claimed CONTINUE or DONE. No dot: no claimBlue: the claim and the gate disagree
Each row is one run of the handoff loop, in time order, and each cell is one iteration. The cell's shape is the loop's measured gate: whether a new commit touching a handoff file was made during the iteration. The dot inside is the agent's own closing claim. Blue marks the cells where the two disagree.
  • When an iteration left work uncommitted, a closer run finished it, and the claim recorded is the closer's. That happened on 13 iterations.
  • The rows also record a turn count. On 57 of the 81 rows it is above the cap the run was given, 41 of them runs that ended without an error. Why is not settled, so this figure does not draw it.
  • Refused means the run did no work: it errored or was killed within one turn, committed nothing and left the tree clean. A usage limit or an outage has that shape, so the loop waits instead of counting a failed gate.

Not shown. Each iteration's token usage and turn count, which the rows carry, and any iteration that wrote no row: loop runs before the rows file existed, and anything after the last committed row.

Built from loop-gate-figures.generated.json, written by scripts/research/method-figures/long-horizon-agents.ts from docs/handoff-loop/iterations.jsonl. The rows file is committed by the loop itself, one row per iteration.

Last row written

The numbers as a table
Every handoff loop iteration: what the agent claimed, and what the gate measured
Loop runStarted, Central timeWhat the gate measuredWhere the claim and the gate disagree
Run 11 iteration. Stopped for a person: 1Iteration 1: claimed CONTINUE, stopped for a person
Run 22 iterations. Landed: 2None
Run 328 iterations. Landed: 28None
Run 41 iteration. Landed: 1None
Run 51 iteration. Landed: 1None
Run 61 iteration. Landed: 1None
Run 71 iteration. Landed: 1None
Run 88 iterations. Landed: 8None
Run 93 iterations. Landed: 3None
Run 105 iterations. Landed: 5None
Run 111 iteration. Refused: 1None
Run 123 iterations. Landed: 2, Retry: 1None
Run 135 iterations. Landed: 5Iteration 2: made no claim, landed
Run 142 iterations. Landed: 2None
Run 152 iterations. Landed: 2None
Run 1617 iterations. Landed: 15, Retry: 2Iteration 7: made no claim, landed; Iteration 9: made no claim, landed; Iteration 11: made no claim, landed

Download the data: long-horizon-agents-claim-gate.csv, long-horizon-agents-claim-gate.json

The gate proves a handoff was committed. It does not prove the handoff is true. For each of the 5 iterations that did not land, the record names the gate's reason. It says nothing about the quality of the 76 that did.

Where do long-horizon agents fail?

At the boundary between sessions, and the record shows each way it happened. Five iterations of 81 did not land, and 12 more landed only because a closer finished them:

  • One was stopped for a person, and the stop was the loop's own mistake. It was the first iteration of the first run. A closer committed two files the iteration had never named: the book previews the commit hook rebuilds whenever the book's log changes. The loop read them as another writer's work and stopped rather than land it. That night a fix registered them as files the hook rewrites, and a test replays that night; the fix was committed the next afternoon.
  • Three were retries: the iteration ended with no handoff commit, the gate did not count it, and the next iteration re-read the same handoff. A second failed gate in a row would have stopped the loop; each retry here was followed by an iteration that landed.
  • One was refused. It matched the shape a usage limit or an outage leaves: no work done, nothing committed, a clean tree. So the loop waited instead of counting a failed gate against the agent.
  • Twelve landed only through a closer. Each iteration ended with finished work still uncommitted, and the closer committed it and wrote the handoff. Ten of those iterations had ended in an error at their turn cap.

Two more came before the rows begin, in the loop's first days, and each is now a mechanism.

A cap the model never saw. The early iterations had 200 turns and handed off near turn 75, each turn re-reading about 370,000 tokens of context. Their orders said to hand off at 85 percent of the cap, but the tool enforces the cap without telling the model the number. On the default came down to 48, and the loop began writing the number into each run's orders.

A notice that never came. An iteration wrote its handoff, started the commit, said it would wait for the commit's notice, and stopped. Under the headless tool a stop is an exit, so nothing was left to receive the notice. The closer read the staged files as another writer's and left them, the loop stopped, and the two loops queued behind it each refused the same dirty tree. The orders now say what a stop means, and the loop waits for a commit still inside its hook before it reads the tree.

The record is 63 hours of one loop. A longer one may hold kinds of failure this one does not.

What stops a long-running agent?

Running unattended means every stop has to work with nobody watching. Beside a deadline set at launch, six are built in: four read before an iteration starts and two after one. One of them, the stop file, is a person's hand on the loop.

The logs show it is the one used most. Of the 26 runs the snapshot of the loop's logs holds, 12 ended at a stop file and 6 more were cut off by a fresh start of the loop. The loop's own checks ended the rest: 6 on a tree left dirty or holding another writer's files, 1 on a budget it could not read, and 1 at the iteration count it was started with. The stops built in:

The loop's own stops, as configured in its script. The last column is what the record shows of each.
StopWhen it is readWhat it doesIn the record
The kill switchBefore each iteration, in the working tree and on a fresh fetch of the remote.A global halt file or the loop's own stops it. A read that fails is never treated as no stop.The snapshot of the loop's logs has no class for a kill-switch stop, so it cannot show one.
The stop fileBefore each iteration, from one local file a person leaves.The loop ends at the next boundary between iterations and leaves the file in place, so it stays stopped until the file is gone.12 of the 26 runs the snapshot logs ended here: 8 to make way for the founder's own working session, 1 to pause for the weekly budget, and 3 with no reason given.
The weekly budgetBefore each iteration, from one local file the founder sets.A spent budget stops the loop, and a file that does not validate stops it too, rather than let it run unmetered.A snapshot of the loop's logs, cut on , records 1 stop on a budget the loop could not read, on .
The idle lineBefore each iteration, from the newest handoff.When nothing can be done before a known time, the handoff names it and the loop sleeps to it instead of starting a session to learn the same thing. A line it cannot read is ignored, and the iteration runs.The snapshot records about 7 hours asleep on an idle line, across 3 runs, about 6 of them in the last run.
Failed gates in a rowAfter each iteration, from the gate.A failed gate on a clean tree is retried from the same handoff. By default two failed gates in a row stop the loop, a number HANDOFF_LOOP_MAX_FAILURES can change, so a lasting fault cannot spend the week.Three retries, each followed by an iteration that landed, so the rule never stopped a run.
The landing ceilingAfter each iteration, when the loop lands what it committed.By default at most 8 pushes to main a UTC day, the owner account's own pushes included, through a landing check that runs the tests on the exact commit first. A full day leaves the commits waiting for the next.No row ran under it: the landing check was configured on , after the last row.

The loop's tests run each of these against a fake model in a sandbox. The iteration rows do not say which stop ended a run; the snapshot of the loop's logs does, for the runs it holds, and the counts here are read from it.

What about one goal that spans many sessions?

That is the arc runner, and it came first. A session built it in August 2026 in a clean room outside the repository, tested every hook until each had gone red and stayed quiet, and packed it into a folder with a note on top for the session working in the repository. On the founder dragged that folder into the terminal, and it was installed. An arc drives one goal to a proved condition, and its runner runs it in a git worktree of its own.

Its state lives in a ledger file, one append-only block per iteration, never in context. Two hooks hold it there: a turn counter that orders a handoff, and a stop hook that blocks the first attempt to end an arc session without a closed block and lets the second through.

One part of the kit runs in every session, arc or not: the valve, a hook that leaves force pushes, remote branch deletes, destructive database commands, credential rotation and money movement to a person, and, at the time, any push to main. It went live the moment the install wrote its settings, and the next command, the install's own self-test, carried the words it watches for. The valve denied it. The proof came from the real path, against the session installing it.

It has not run an arc. On the day of the install the week's usage stood at 109 percent of the heaviest week the project had run, so starting a runner that spawns fresh sessions was left to the founder, and the smoke arc was staged and left waiting. This page found no record of why it has not been started since. No arc ledger is in the tree; the one ever committed is a scaffold on a smoke test branch, written that same day, with its first step still marked ready and no iteration block. Its tests run it against a mocked model, and none of that is a record. What ran instead was the handoff loop, a script written in one evening four weeks later, and every row on this page is its.

Until an arc runs, its design is a claim about a path nobody has walked.

Why does the record stop in September?

The last committed row is from .

It stops because a person stopped it. A snapshot of the loop's own logs, cut on , ends on . Its last run ran 18 iterations and ended on at a stop file whose reason cited the weekly budget. Twelve of its 26 runs ended at a stop file, that one included.

A week later, on , the loop was configured to run in a clone of its own and to land its work through the landing check instead of pushing it. The commit that made the change says a real run under it was not proven. No iteration row has reached main since.

Whether the loop ran after is not in the repository: NOT OBSERVED.

The loop was asked for so the work could go on without him, and in the record it did: 76 of 81 sessions handed their work to the next with no person in the gate. The same logs show the other half. Twelve of the 26 runs ended at a stop file, the tool a person uses to end the loop, and 6 more were cut off by a fresh start of the loop, with no line in the log saying why the earlier run ended. In this record, without him meant a loop he could stop at any boundary, not one he had left.

This section reads the repository only: the rows and the committed snapshot. The loop's own logs are kept on the founder's machine, and only that snapshot of them was read for this page.

Long-horizon work questions? Answers.

Long-horizon names the task: one goal that takes many steps. Long-running names the execution: an agent that keeps working across sessions. This loop is the second, in service of the first.

No. Long-horizon reasoning is a model holding one plan coherent across many interdependent steps, and benchmarks such as LongCoT and R-Horizon measure it inside one chain of thought. A long-horizon agent carries a goal across many sessions. This page measures only the second: whether the work crossed a session boundary, never the quality of the reasoning.

A file a session writes before it ends, committed with its work, telling the next session what is done, what is open, and in what order to take it. The loop counts a session only when it commits one.

Because a report and a measurement are different things, and the loop keeps both. In 81 recorded sessions no agent claimed the goal was done, so the record holds no false finish. The report and the measurement disagreed five times: once an agent said to keep going and the loop stopped it for a person, and four times a session ended in an error before it reported anything, with its handoff already committed.

A new commit touching a handoff file, made during the iteration. The agent's closing line is recorded and never decides the gate; a DONE after a landed handoff only ends the loop.

By the clock, from a row's start to its end, closer included, the median iteration ran 19 minutes, and half ran between 14 and 31; the longest ran 74. Each is also given a cap of 48 turns by default, which the founder can change, and told to hand off before it. The turn counts the rows record do not settle how many turns a session really took: 57 of 81 are above that cap, 41 of them runs that ended without an error.

No. It is installed and its tests run it against a mocked model. The only arc ledger ever committed is a scaffold on a smoke test branch with no iteration in it.

Cite this page

Cite this page for the practice and follow its sources for the underlying records.

Bartak, J. (2026). Long-Horizon Agents. Orbyt Labs Research. https://www.orbytlabs.ai/research/long-horizon-agents