Long-Horizon Agentic Coding: 3 Surprises and 1 Unexpected Finding After Testing Over 10 Million Tokens
This article reports on a hands-on evaluation of long-horizon agentic coding with general-purpose large language models, based on more than 10 million tokens consumed across database design, mobile environment setup, logic puzzles, difficult math problems, and lightweight everyday questions. It covers three positive findings—stable autonomous planning during a roughly 60-minute build session, a closed loop between tool calls and self-correction, and reduced long-task costs from context caching—plus one unexpected issue where a stronger model overthought simple tasks and underperformed a lighter one. Readers will also find practical engineering guidance on task routing, structured errors, persisted progress, cache-friendly prompt ordering, and reasoning stability limits.
Introduction: Why 10 Million Tokens Were Worth Spending
When a model family starts claiming “long-horizon autonomous execution,” single-turn question-and-answer benchmarks are no longer enough to support the conclusion. The real dividing line appears once task duration moves from seconds to minutes: the model has to decompose the goal itself, choose tools itself, fall back and retry after errors itself, and keep the objective from drifting along the way.
To test these capabilities, we ran general-purpose large language models through long-horizon agentic coding tasks and consumed more than 10 million tokens in total, covering database design, mobile simulation environment setup, logical reasoning, hard math problems, and lightweight everyday questions.
The results boil down to three surprises and one unexpected finding: long-horizon autonomous planning and execution improved markedly; tool calling and self-correction now form a closed loop; cache reuse changed the cost structure of long tasks; and on simple tasks, some versions failed because they “overthought” the problem.
Surprise 1: 60 Minutes of Continuous Autonomous Development Without Plan Collapse
For the database design task, we deliberately withheld the table schema, field constraints, and implementation path, describing only the business goal in order to test autonomous planning.
The model first produced a complete plan: 8 core feature modules and 6 data tables covering bookkeeping and transaction statistics. It then laid out its own development workflow and closed with a 10-item verification checklist. Once we let it run, it worked for close to 60 minutes straight—no interruptions, no infinite loops, and no skipped critical steps.
From an engineering perspective, three capabilities stack up here:
- Task decomposition: turning a vague goal into deliverable submodules and defining the dependency order between them.
- State retention: maintaining a stable sense of “done vs. pending” across a long context to avoid duplicated work.
- Self-verification: defining “done” as “passes verification” rather than “code was generated.”
One caveat: the front-end output still lacked visual polish, but the core functionality worked, and operations such as adding records and editing or deleting categories ran without errors. At this stage, then, long-horizon capability shows up mainly as functional correctness rather than engineering aesthetics.
Surprise 2: Tool Calling and Self-Correction Form a Closed Loop
The hard part of long-horizon tasks is not writing code but handling failure. In testing, when the model hit missing dependencies or abnormal API responses, it read the error, located the specific file, applied a fix, and reran—instead of repeatedly emitting the same broken code.
A reusable orchestration pattern (illustrative):
for step in plan.steps:result = tool.run(step) # Execute: read/write files, run commands, invoke testsif not result.ok:ctx = tool.read(result.error_target) # Observe: pull logs and contextpatch = model.fix(step, ctx) # Decide: make a minimal changeresult = tool.run(patch)state.commit(step, result) # Record: persist progress to support resume
Three design points matter: errors must be structured (with file, line number, and exit code); each fix must be scoped to the smallest possible change; and progress must be written to disk so state survives context compaction.
Surprise 3: Caching Reshapes the Cost Curve of Long Tasks
In long-horizon tasks, the prefix is highly repetitive: system prompts, project conventions, directory structure, already-generated code. If every turn were billed in full, cost would grow linearly or even superlinearly with the number of turns. In testing, with context cache reuse enabled, the total bill for long tasks grew noticeably less than the increase in per-token price.
Practical recommendations:
- Put the stable prefix first: keep unchanging project conventions at the top and variable content after them.
- Avoid pointless rewrites: append-style edits beat regenerating the whole file.
- Meter and monitor by segment: track token consumption per task phase to locate abnormal growth.
The Unexpected Finding: The “Overthinking” Trap on Lightweight Tasks
On a simple reasoning question of the “car wash” type, the Pro version sometimes returned the wrong answer while the lighter Flash version was direct and efficient. The cause was not insufficient capability but an over-allocated reasoning budget: the model introduced unnecessary assumption branches on a simple question and drifted away from the most straightforward solution.
The engineering takeaway is direct: routing matters more than parameters. A lightweight classifier can judge task complexity up front, sending simple tasks to a lighter model and complex long-horizon tasks to a stronger reasoning model, balancing cost and accuracy.
if complexity(task) == "low":return flash_model.answer(task) # Low latency, low costreturn pro_model.plan_and_execute(task) # Long-horizon planning and tool calls
Reasoning Stability: Both Strengths and Limits
Performance on logic puzzles was strong, indicating clear progress in constraint satisfaction and counter-intuitive reasoning. On very hard math problems, however, the model still fell into infinite loops or reached wrong conclusions. Practical mitigations include setting a maximum number of reasoning steps and a timeout, requiring the model to list known conditions and the derivation chain explicitly, and verifying results a second time (substitution checks or dimensional analysis).
Implementation Checklist
- Route by task tier; do not overuse strong models on simple scenarios.
- Force long tasks to persist progress to disk so they can resume.
- Structure errors and keep fixes minimal.
- Put the stable prefix first to reuse caches.
- Instrument everything and account for tokens and latency per phase.
In short, long-horizon agentic coding has moved from “works in a demo” to “usable in engineering,” but it still needs finer design around reasoning stability and task routing to deliver reliable returns in real business settings.
