Long-Context AI Agent Coding: Findings and Limits from a 10-Million-Token Test

    This article reports on a hands-on test that consumed more than ten million tokens across agentic coding, complex reasoning, lightweight Q&A, and cost structure. It shows where long-horizon autonomous planning, tool-call loops with rollback, and prompt caching made extended runs usable, where over-reasoning hurt simple tasks, and how to turn these results into engineering practice through task tiering, acceptance checklists, auditable traces, and cost attribution. The discussion stays vendor-neutral and focuses on reproducible methods.

    1. Background: Why a 10-Million-Token Test Matters

    The quality of a single question-answer exchange is usually driven by prompt quality. What really separates systems is long-horizon work: a model has to keep its goal from drifting, avoid skipping steps, and stay able to roll back errors across a continuous run that can last tens of minutes or longer.

    To study this, we ran a cross-cutting test that consumed more than ten million tokens in total, covering four threads: agentic coding, complex reasoning, lightweight Q&A, and cost structure. The aim was to observe where stability breaks down when no human is stepping in.

    One clarification on scope: this article does not evaluate any specific vendor or product. It discusses reproducible engineering methods and general capability behavior only. Every conclusion is explained through three factors — task type, constraint strength, and a closed verification loop — so readers can transfer the findings to their own stack.

    2. Surprise One: Long-Horizon Autonomous Planning and Execution Is Now Usable

    In an open-constraint database design task, we supplied only the business goal (bookkeeping and transaction statistics) and left the schema and module breakdown unspecified. The model first produced a design: 8 functional modules and 6 data tables. It then filled in the development workflow and a verification plan on its own, listing 10 acceptance items, and entered a continuous execution state for roughly 60 minutes — no interruptions, no infinite loops, and no missed critical steps.

    This behavior breaks down into three capabilities:

    • Task decomposition: turning a vague goal into modules and data tables, forming an executable work breakdown structure.
    • State retention: maintaining a mental model of “done / not done” across a long context, avoiding duplicated work.
    • Self-correction: when an interface does not connect or fields conflict, falling back to the last stable point instead of piling on more patches.

    The engineering takeaway is that long-horizon tasks must carry their own acceptance loop. A checklist structure like the following can be fixed in place:

    1. Acceptance checklist (example)
    2. 1. Primary and foreign keys are complete, with no orphaned references
    3. 2. Amount field precision and currency are consistent
    4. 3. Transaction statistics reconcile with the underlying detail records
    5. 4. Abnormal inputs are handled with fallbacks; no uncaught errors are thrown
    6. 5. Critical paths have logging and metrics instrumentation

    3. Surprise Two: Tool Calls and Rollback-Ready Execution Cut Manual Takeover

    When paired with coding tools, the model’s value is not getting the code right on the first attempt. It is automating the loop of read files → modify code → run tests → inspect logs → fix again. In our test, long tasks kept moving forward because every step had observable feedback: compile results, test results, and runtime logs formed an external source of truth that the model used to correct course.

    Make the loop explicit rather than relying on implicit memory:

    1. for step in plan:
    2. result = run_tool(step) # compile / test / static checks
    3. if not result.ok:
    4. patch = model.fix(result.log)
    5. result = run_tool(step, patch)
    6. record(step, result) # persist to disk, enabling rollback and audit

    Three points matter: tools return structured results; every change is rollback-ready; and the execution trace is persisted so runs can be reviewed and costs attributed.

    4. Surprise Three: Caching in Long Contexts Dilutes Total Cost

    The real cost pressure in long tasks comes from repeated prefixes: the system prompt, repository context, and specification documents are carried along at every step. When the input prefix is stable and reusable, a caching mechanism turns the repeated portion into a low-cost read, so the total bill grows noticeably slower than a linear per-token extrapolation would suggest.

    Three metrics are worth putting on a dashboard:

    • Cache hit rate: the higher the share of stable prefix, the lower the marginal cost.
    • Context growth: whether the content added at each step stays controlled, avoiding a run that “gets heavier as it goes.”
    • Total cost per task: aggregated per task rather than estimated per session.

    In practice, placing specifications, directory descriptions, and interface contracts in the stable prefix region, and volatile retrieved fragments at the tail, improves both hit rate and output stability.

    5. The Unexpected: Over-Reasoning Derails Lightweight Tasks

    On common-sense, lightweight questions such as one about a car wash, the strong-reasoning version sometimes got stuck weighing options repeatedly and produced a roundabout or wrong conclusion, while the lightweight version was more direct and efficient. Reasoning depth is therefore not monotonically beneficial; it needs to be scheduled per task tier.

    A routing strategy that can be put in place:

    1. if the task is closed-domain with a single correct answer:
    2. take the lightweight path and cap the reasoning budget
    3. elif the task needs multi-step tool use and long-horizon planning:
    4. take the deep path and enable the verification loop
    5. else:
    6. try the lightweight path first, and escalate if confidence is low

    Also set a “reasoning budget cap plus no-progress detection” on the deep path, so you do not keep paying for a loop that is going nowhere.

    6. Complex Reasoning: Bright Spots Alongside Stability Issues

    On logic-reasoning problems, the model performed consistently. On harder math problems and some lightweight tests, however, it produced infinite loops or wrong conclusions. The cause is usually not that it “cannot do it,” but that external validation is missing: math problems need formal verification, and logic problems need exhaustive search or proof by contradiction. The engineering approach is to bring in verifiers — unit tests, constraint solvers, symbolic computation — as a second opinion, decoupling “model generation” from “machine judgment.”

    7. Implementation Advice: Engineer the Surprises, Institutionalize the Unexpected

    • Task tiering: three tiers — lightweight, standard, and long-horizon — each with its own model and budget configuration.
    • Verification first: write the acceptance checklist before letting the model execute.
    • Auditable traces: logs, metrics, and tracing covering the full chain.
    • Cost attribution: aggregate tokens and cache hits per task to build a unit-price dashboard.
    • Fallbacks: roll back when there is no progress; downgrade when the budget is exceeded.

    8. Conclusion

    The core judgment from a test at the ten-million-token scale is that long-horizon agentic coding is already usable in production, provided you have a closed verification loop, rollback capability, and observable cost. Lightweight scenarios, by contrast, call for deliberately lower reasoning depth. Institutionalizing these three points is what turns occasional surprises into steady output. To deploy this on Baidu AI Cloud, you can use a container platform to host the execution sandbox, object storage to keep traces, and logging plus monitoring and alerting services to observe cost and health.