Long-Context AI Agent Coding: A Hands-On Test at 10 Million Tokens

    This article reports on a hands-on evaluation of long-horizon AI agent coding that consumed more than 10 million tokens across agentic programming, complex reasoning, lightweight Q&A, and cost structure. Instead of ranking models, it answers three engineering questions: where capability boundaries lie, what the failure modes are, and why the bill grows the way it does. Key findings include usable long-range autonomous execution, persistent instability in complex reasoning, over-thinking on simple tasks, and a cost structure where unit price changes do not translate directly into the final bill. It closes with a practical checklist covering layered acceptance, budget guardrails, verifiability, routing, and observability.

    1. Why Test at the 10 Million Token Scale

    Single-turn Q&A benchmarks only reflect how a model performs under short context and single-step reasoning. Real engineering work is a long chain: decomposing requirements, designing a solution, writing code, running it, reading logs, rolling back, and verifying again. These tasks share three traits: context keeps expanding, tool calls are frequent, and failures require self-repair. Any meaningful evaluation therefore has to be built on a large enough token budget.

    This test consumed more than 10 million tokens in total, covering four scenario types: agentic coding, complex logical reasoning, lightweight Q&A, and cost structure. The goal is not to declare a winner, but to answer three engineering questions: where the capability boundary sits, what the failure modes look like, and why the bill grows the way it does.

    2. Capability Observation 1: Long-Horizon Autonomous Execution Is Now Usable

    For a database design and implementation task, we deliberately kept constraints minimal and provided only the business goal, in order to observe autonomous planning. The model first produced a design: it split the work into core functional modules, defined the table structures, specified fields and relationships, and wrote its own acceptance checklist, laying out a closed loop of implement, self-test, and fix.

    Execution then proceeded without human intervention. The model worked continuously for close to an hour with no interruption, no infinite loop, and no skipped steps. The delivered system’s core functionality could read and write normally, and data writes completed without errors. This demonstrates that three underlying capabilities have reached engineering usability:

    • Long-horizon planning: turning a vague goal into a task graph with dependency ordering, rather than piling up code in one pass;
    • Tool use and state maintenance: staying aligned with the goal across repeated file reads and writes and command execution;
    • Self-correction: reading error output and backing out a change when something fails, instead of repeating the same mistake.

    One caveat: UI polish and interaction details remain weak. That is a different dimension from functional correctness and should be accepted separately in engineering terms.

    The task orchestration logic can be abstracted schematically as:

    1. plan = model.propose_plan(goal, constraints) # outputs modules, table structures, acceptance checklist
    2. for step in plan.tasks: # advance in dependency order
    3. result = agent.execute(step) # read/write files / run commands / invoke tests
    4. if not result.ok:
    5. plan = model.repair(plan, result.log) # replan from the log instead of blindly retrying

    3. Capability Observation 2: Complex Reasoning Is Still Unstable

    On logic puzzle tasks, the model performed well: it correctly identified implicit premises and produced self-consistent explanations. On hard math problems and a few minimal tests, however, two typical failure modes appeared:

    1. Loop-style thinking: repeatedly validating the same branch, with token consumption climbing fast without converging;
    2. Wrong conclusion stated confidently: with no verifiable intermediate quantities, the error could not be caught by self-checking.

    The engineering response is not to swap in a stronger model, but to externalize the reasoning process into a checkable structure: require the model to explicitly list known quantities, constraints, and intermediate results; hand computable parts to deterministic tools; and set a maximum number of reasoning steps and a budget cap, degrading to “provide an approach rather than an answer” once the limit is exceeded.

    1. Constraints: max_steps=8, max_tokens=4000
    2. Output: {known quantities, constraints, intermediate steps[], conclusion, self-check items[]}
    3. Policy: computable sub-problems -> call a deterministic computation tool; over limit -> return the approach and flag uncertainty

    4. Unexpected Finding: Over-Thinking on Lightweight Tasks

    The most counter-intuitive result showed up on simple questions: the more capable version sometimes produced a wrong answer because it kept re-deriving and second-guessing itself, while the lightweight version was more direct and more efficient. This suggests model capability does not map monotonically to business value; reasoning depth needs to match task complexity.

    The practical recommendation is to build a routing layer: first classify task complexity, send simple Q&A down a low-latency, low-cost path, and route long-horizon engineering and complex reasoning to the high-capability path. Routing can be implemented with rules, historical hit rates, or a lightweight classification model. The aim is to save the compute that over-thinking would otherwise burn.

    5. Cost Structure: Unit Price and the Actual Bill Are Not in Sync

    In long tasks, a unit price increase often grows the bill less than expected, because mechanisms such as context caching mean repeated prompt prefixes and codebase context are not billed again; cache hits also reduce time to first token. Conversely, infinite loops and repeated retries are the main source of runaway bills.

    Cost governance should therefore focus on three points: first, set hard caps on steps and token budget; second, keep prompt prefixes stable and compress historical context to raise cache hit rates; third, wire logs, monitoring, and alerting into a unified observability system so abnormal consumption can be cut off in real time. General-purpose cloud capabilities such as object storage, message queues, and container platforms can carry long-task artifacts, asynchronous scheduling, and elastic compute.

    6. Implementation Checklist

    • Layered acceptance: set separate standards for functional correctness, stability, and UI/experience;
    • Budget guardrails: three caps per task on steps, tokens, and duration, with degradation when exceeded;
    • Verifiability first: require explicit intermediate results and self-check items, and hand computable parts to deterministic tools;
    • Tiered routing: split models by complexity so lightweight tasks do not over-consume;
    • Full-chain observability: record planning, calls, failures, and retries to form a traceable evaluation baseline.

    The core conclusion from the 10-million-token test: long-horizon agentic coding has entered the usable range, while reasoning stability and how well compute is matched to the task determine whether real projects succeed. Build the evaluation method, budget guardrails, and observability system first, then discuss model selection. That is the more reliable engineering path.