Long-Horizon Agentic Coding Tested at 10 Million Tokens: Key Takeaways
This article reports on a hands-on test that pushed token consumption to the 10 million mark to evaluate long-horizon agentic coding and complex reasoning stability. It explains how a model sustained nearly 60 minutes of uninterrupted coding by combining explicit planning, persistent state, and embedded checks; why complex reasoning still fell into loops without external computation and budget limits; why stronger models can overthink simple tasks; and how prefix caching and context layering keep costs from scaling with unit price. A reusable evaluation checklist is included.
1. Why Run a Test at the 10 Million Token Scale
Small-sample evaluations only show whether a model can answer a single question correctly. Real engineering cares about a different set of questions: can the model work continuously for an hour without drifting off course, can it detect its own mistakes, and will the bill spiral out of control under long context. Pushing consumption to the 10 million token level turns occasional problems into observable statistical phenomena—low-frequency infinite loops, fluctuations in cache hit rates, and consistency gaps between planning and execution all surface at this scale.
The test covered two capabilities: long-horizon agentic coding and the stability of complex reasoning. It also recorded performance and cost structure changes on lightweight tasks, producing a reusable evaluation framework.
2. Long-Horizon Agentic Coding: How 60 Unattended Minutes Were Achieved
1. Task Design: Deliberately Fewer Constraints
The first task was to build a complete accounting system. The prompt described only the goal: no table schema, no module breakdown, no verification method. The purpose was to test autonomous planning—the model had to handle requirement decomposition, architecture decisions, and acceptance criteria definition on its own.
The model first produced a design: 8 core functional modules and 6 data tables covering bookkeeping and transaction statistics. It then laid out a development workflow and ended with a 10-item verification checklist. The value of this step is often underestimated—when the executor defines the acceptance criteria itself, every subsequent step has a verifiable anchor.
2. Execution: Stability Comes from a Plan–Execute–Verify Loop
Once execution began, the model coded continuously for nearly 60 minutes with no interruptions, infinite loops, or skipped steps, advancing strictly according to the established plan. The reproducible engineering lesson is that long-horizon stability is not mysterious; it depends on three conditions holding at the same time.
- Explicit planning: write the task as ordered steps and acceptance items rather than leaving them implicit in the context.
- Persistent state: write intermediate artifacts to disk so key information survives context compaction.
- Embedded verification: run checks as soon as each component is complete, so errors are caught early.
A schematic execution skeleton follows (pseudocode, expressing control flow only):
plan = planner(task) # outputs a step list and acceptance checkliststate = load_or_init_state() # intermediate state is persistedfor step in plan.steps:patch = coder(step, state) # generate changesapply(patch)result = run_checks(step.acceptance)if not result.passed:patch = fixer(step, result.logs) # self-correctionapply(patch)state = save_state(state)
3. Results: Working Features Take Priority over Visual Polish
All core functions of the delivered system worked, new data was added without errors, and custom operations such as adding categories and editing or deleting data were usable; the frontend looked average. This suggests a pragmatic acceptance principle: for long-horizon tasks, the first priority is functional correctness and verifiability, while interface polish should be a separate iteration rather than coupled to the main workflow.
3. Complex Reasoning: Strong Performance alongside Infinite Loops
Performance on logical reasoning problems was good, but on hard math problems and some lightweight tests the model fell into loops or produced outright wrong conclusions. The causes are not hard to identify:
- No external verification: self-verification purely within language space cannot provide reliability equivalent to real computation.
- No budget cap: once an invalid path is entered, there is no forced exit mechanism.
- Context pollution: an early wrong assumption was never explicitly retracted, and later reasoning kept being pulled by it.
The general engineering fix is to separate “thinking” from “computing”: let the model handle modeling and strategy, hand the computable parts to code execution or symbolic computation tools, and set dual budgets on steps and time, rolling back when either is exceeded.
def solve_with_budget(problem, max_steps=40, timeout_s=120):for i in range(max_steps):if timeout(): return fallback(problem)step = model.propose(problem)if step.is_computable:problem = problem.apply(exec_step(step)) # external computation checkelse:problem = problem.apply(step)if problem.solved(): return problem.answerif problem.loop_detected(): problem = problem.rollback()return fallback(problem)
4. The “Overthinking” Problem on Lightweight Tasks
A counterintuitive observation: on simple problems, the more capable version sometimes answered incorrectly because its reasoning chain was too long and pulled in irrelevant branches, while the lightweight version was more direct and had a higher hit rate. This maps to a clear selection rule—route models by task complexity instead of using the strongest model everywhere.
if task.complexity == "low": use lightweight_modelelif task.need_long_horizon: use agent_mode + persistent stateelse: use reasoning_model + external verification
Supporting measures include shorter thinking budgets for simple tasks, requiring a conclusion before the reasoning, and caching results for high-frequency simple queries.
5. Cost Structure: A Higher Unit Price Does Not Raise the Bill Proportionally
The cost of long tasks is not determined by unit price alone, but by total token volume × hit rate × proportion of repeated computation. Context prefixes are highly repetitive in long tasks, and prefix caching amortizes that repeated computation, so when the unit price goes up, the total bill usually grows significantly less than the price increase.
Controllable optimization measures (all general practices):
- Stable prefixes: place the system prompt, specification documents, and interface contracts at the very front of the context and keep them byte-level stable to improve cache hits.
- Layered context: keep only decision-relevant information in the main context and load details on demand via retrieval.
- Budgets and observability: set token and duration limits per task, and record separate metrics for input, output, and cache hits.
- Write artifacts to disk: save intermediate results to files instead of repeatedly stuffing them back into the context.
To carry this workflow on general cloud capabilities, a common combination is a container platform running the executors, object storage holding the artifacts, a message queue handling task distribution, and logging plus monitoring and alerting services providing observability, with model services accessed through a unified gateway to enable routing and rate limiting.
6. A Reusable Evaluation Checklist
- Long-horizon capability: does it run for 30 minutes or more without interruption; is there an explicit acceptance checklist; can it recover from errors on its own.
- Reasoning stability: is external computation verification introduced; are loop detection and budget caps in place.
- Task routing: do simple tasks take the lightweight path; is the conclusion stated before the argument.
- Cost control: are prefixes stable; are separate metrics such as cache hits recorded; is there a hard budget.
- Engineering quality: functional correctness first, with visual design and interaction as a separate iteration.
7. Conclusion
The 10 million token test yields three firm conclusions: the reliability of long-horizon agentic coding comes from explicit plans, persistent state, and embedded verification; complex reasoning requires external computation and budget constraints to stay stable; and model selection should be tiered by complexity. The only “surprise” worth watching for is overthinking—more capable does not mean better in every scenario. Applying the right capability to the right task is where engineering returns come from.
