Large Language Model Long-Horizon Agents: Lessons from a 10-Million-Token Test

    This article reports on a large-scale evaluation of long-horizon LLM agents that consumed more than ten million tokens across four dimensions: autonomous planning and execution, complex reasoning, lightweight tasks, and cost structure. It shares the observed behaviors, explains their likely causes, and turns them into reusable evaluation methods and engineering recommendations, covering explicit verification checklists, external guardrails for reasoning loops, complexity-based model routing, context reuse for cost control, and a reproducible evaluation pipeline. Readers will find practical guidance on assessing and deploying long-running agents without ranking any specific model or product.

    1. Why Token-Scale Testing Matters

    Single-turn Q&A benchmarks can no longer reflect how large language models perform in real engineering work. Real tasks form long chains: requirement understanding, solution design, code generation, runtime verification, error read-back, and rework. Any fluctuation in one link gets amplified by the following steps. An evaluation therefore has to consume enough tokens to cover long contexts, multi-turn tool calls, and repeated self-correction.

    This test consumed more than ten million tokens in total, covering four dimensions: agentic coding, complex reasoning, lightweight Q&A, and cost structure. Note that this article does not judge any specific model or product as better or worse; instead, it abstracts the observed phenomena into reusable evaluation methods and engineering recommendations.

    2. Dimension 1: Long-Horizon Autonomous Planning and Execution

    The most valuable observation is that, given only a goal and no fine-grained constraints, the model can first produce a structured plan and then execute continuously for a long time without interruption.

    A typical process looks like this:

    1. Goal: build a database application with bookkeeping and transaction statistics
    2. Stage 1 Planning: split core feature modules -> design table schemas -> list a verification checklist
    3. Stage 2 Execution: generate code and migration scripts module by module
    4. Stage 3 Self-verification: run each checklist item, read errors, roll back and fix

    The key metrics should not be the final volume of code alone, but three things: whether the plan is executable, whether execution drifts from the plan, and whether verification closes the loop. In the test, the model worked autonomously for about an hour, without falling into an infinite loop and without skipping key steps. This shows that the “plan first, then execute” pattern genuinely helps with long-horizon tasks.

    The engineering recommendation is to make the verification checklist explicit so the model can self-check item by item before finishing:

    1. checklist = ["schemas are migratable", "statistics API returns correct results", "duplicate writes produce no dirty data"]
    2. for item in checklist:
    3. result = run_and_capture(item) # execute and capture output
    4. log(item, result) # structured logging for traceability

    Front-end aesthetics are often not a model’s strength, but a usable core path is acceptable; the UI layer should be constrained by mature component libraries and design specifications.

    3. Dimension 2: Stability Gaps in Complex Reasoning

    The model performs well on logic problems that require multi-step deduction. However, on hard math problems and some lightweight tests, two typical failures appeared: getting stuck in a loop of repeated deduction, and producing conclusions that look plausible but are wrong.

    There are usually three causes. First, the search space is too large and lacks pruning, so the model keeps circling on the same branch. Second, there is no external verification, so intermediate conclusions cannot be checked with tools. Third, as the context grows, attention gets diluted and early constraints are forgotten.

    The corresponding engineering fixes introduce external constraints and termination conditions:

    • Set a maximum number of reasoning steps, a maximum number of tool calls, and a timeout threshold to prevent infinite loops.
    • For verifiable sub-problems, force the use of calculation or test tools instead of letting the model “do the math in its head.”
    • Split long tasks into sub-tasks that can be accepted independently, reducing the reasoning depth of each turn.

    4. Dimension 3: “Overthinking” on Lightweight Tasks

    A counterintuitive phenomenon is that on extremely simple questions, the more capable version sometimes makes mistakes because it unfolds unnecessary complex reasoning, while the lightweight version answers directly with better efficiency and accuracy.

    This suggests that model selection should be routed by task complexity:

    1. if the task is simple factual or single-step transformation:
    2. route to the lightweight model for low latency and low cost
    3. else if the task requires multi-step planning or tool orchestration:
    4. route to the strong reasoning model with step and timeout limits

    The routing strategy can be built on signals such as input length, whether tools are needed, and historical failure rates, and continuously calibrated with online sampling data.

    5. Dimension 4: Cost Structure and Caching

    A version upgrade usually comes with a higher unit price, but the real bill for long tasks does not grow proportionally to the unit price. The reason is mechanisms such as prefix caching: when many requests share the same system prompt, code context, and tool definitions, the repeated parts do not need to be billed or computed again.

    The core of cost control is therefore not pushing the unit price down, but raising the context reuse rate: keep the system prompt stable, place volatile content later, and avoid needlessly rewriting the entire code context. With logging services and monitoring alerts, token consumption can be attributed per task to identify abnormal amplification points.

    6. A Reproducible Evaluation Pipeline

    It is recommended to solidify the evaluation into a pipeline, scheduled on a container platform, with artifacts stored in object storage and long tasks decoupled through a message queue:

    1. Task set layering: long-horizon engineering, complex reasoning, and lightweight Q&A each take a fixed proportion.
    2. Metric definition: task completion rate, number of human interventions, loop trigger rate, and tokens and time per task.
    3. Termination and rollback: unified step, timeout, and rollback policies.
    4. Result logging: keep intermediate artifacts and error logs to support post-hoc attribution.

    7. Conclusion

    The token-scale test leads to one core conclusion: long-horizon agent capability is already usable as productivity, but it needs external guardrails; reasoning stability and lightweight efficiency require layered model selection; and cost optimization depends on context reuse rather than price comparison alone. Turning these methods into a reproducible pipeline and running it on the general compute, storage, and monitoring capabilities of Baidu AI Cloud is what converts a single test into long-term engineering gains.