Long-Horizon Agent
A long-horizon agent grinds through complex, multi step work for hours on end without losing its mind or forgetting the original brief. It tracks every decision, every edited file, and every insight from the first thirty minutes all the way to delivery no matter how tangled the project gets. Claude 4.7 finally delivered the stability to make these agents production reality after years of promises. On 4.6 they would drift hard past the ninety minute mark, repeating finished tasks, ignoring their own earlier edits, and quietly derailing from the goal they started with. The 4.7 models keep the thread alive through better internal planning, attention fixes that actually use the full context window, and tool calling that no longer spits out broken JSON at the three hour mark. Internal tests at the Devin team showed Opus 4.7 agents completing clean ten hour coding runs end to end with the reliability curve staying flat instead of falling off a cliff. The family wide 1M context window means even the fast Haiku variant can hold an entire TypeScript repo or four full length books in memory while the prompt caching improvements cut the cost enough to run these agents at scale without bankrupting the company.
This is not some chat window you leave open all day hoping the model remembers what you said. It is not a basic loop that hammers the same API call until something sticks or a wrapper script that adds retries every time the model flakes. Long-horizon agents are not created by simply cranking up the context tokens and calling it a day. A 4.6 model with 1M context still fell apart after an hour and a half because the attention and planning layers were not ready for sustained work. These agents also are not the right pick for quick hits or real time back and forth that needs sub second responses. If the job wraps in fifteen minutes or forms the front end of a customer facing feature then this pattern adds cost and latency for zero benefit. They further are not fully autonomous sci fi entities. Even strong long-horizon agents perform better when you give them clear rubrics up front and build eval pipelines that score their outputs against fifteen criteria at the two hour and four hour marks.
Cursor showed what this looks like in real shipping software in 2026. Their Agent mode on Sonnet 4.7 takes vague feature requests from designers and runs for two or three hours implementing them across entire codebases. The agent holds the full repo in its 1M context window, makes architectural calls early on, implements across seventeen files, runs the test suite, refactors based on what it learned at the one hour mark, and delivers a pull request that actually matches the original intent. Devin went bigger with ten hour autonomous agents on Opus 4.7. Their system explores solution spaces, hits dead ends, recalls the constraints it set down in hour one, pivots cleanly, integrates test feedback from the middle of the run, and ships production code that passes regression before the team even wakes up. Linear routes its thorniest prioritization work to Opus 4.7 long horizon flows. The agent eats strategy decks, interview transcripts from the past year, usage metrics, and competitor moves then spends four uninterrupted hours synthesizing them into ranked tickets, spec documents, and risk assessments that stay true to every point raised in the opening prompt. Granola does the smart handoff dance where Haiku 4.7 handles the initial real time transcription and fast classification then passes the rich structuring job to a Sonnet 4.7 long horizon agent that runs for ninety minutes while maintaining perfect fidelity to the original meeting context and action items. Figma's 2026 AI audit tools followed the same playbook, running three hour design system reviews against new accessibility rules without dropping any constraints loaded at the start.
Pull out the long-horizon pattern when the work involves real depth, long chains of dependent decisions, and the risk that a human would lose consistency over a long afternoon. Think full codebase refactors that touch sixty files and require revisiting architectural choices made at the start, competitive teardown reports that synthesize trends from the last eighteen months of product launches, or design critiques that cross reference user research with current Figma files and brand guidelines over a three hour run. Route the hard thinking and ranking to Opus 4.7 and the sustained execution and editing to Sonnet 4.7. The tiered routing that Linear and Devin use keeps quality high and cost under control while the one hour prompt cache drops the repeated read price by thirty percent. This is the setup that turned agentic IDEs from flaky demos into tools designers actually trust for all day work. Leave it alone for anything real time, high volume, or short. Live chat support, instant image classification, voice interfaces, and quick data extraction all run better and cheaper on Haiku 4.7. Do not reach for this pattern when latency is the product or when the task is narrow enough that a human can review every output in real time. The multi second first token time kills the experience on those surfaces and the stability benefits never kick in on jobs that finish in under thirty minutes. The economics flip from competitive to expensive fast.
Long-horizon agents finally make AI feel like the teammate who sticks around until the work ships instead of wandering off after the first coffee.
Read the full guide
Related terms
Keep exploring
Context Window
The total amount of text, code, and conversation history an AI model can hold in active memory during a single session. Measured in tokens, not words.
Context Drift
Context drift is the slow degradation of an AI coding agent's adherence to your design system and constraints as the session grows longer and the context window fills with new information.
Tiered Routing
Tiered routing sends each task to the right Claude 4.7 model. Opus tackles hard reasoning, Sonnet runs the main loop, and Haiku handles high volume simple work. The pattern that makes production agents both smart and affordable.
Prompt Engineering
The practice of writing instructions that produce consistent, usable output from a language model. Functionally identical to writing a good creative brief.