Hands-On Testing of Long-Horizon LLM Agents: Lessons from 10 Million Tokens

    This article reports on a long-horizon test of LLM agents that consumed more than 10 million tokens across agentic coding, complex logical reasoning, and lightweight daily Q&A. It explains the four-layer evaluation framework, then presents the main findings: long-running autonomous coding is now usable in engineering but has clear boundaries, complex reasoning shows promise yet remains unstable, lightweight tasks can suffer from overthinking, and caching changes the cost curve despite higher API prices. It closes with practical guardrails for production use.

    1. Test Background and Method: Why the Run Had to Reach 10 Million Tokens

    Single-turn Q&A benchmarks can no longer reflect how large models perform in real engineering work. What actually determines whether a deployment succeeds is whether the model can maintain goal consistency across long contexts, multiple rounds of tool calls, and repeated failures and retries. We therefore designed a long-cycle test that consumed more than 10 million tokens in total, covering three scenario types: agentic coding, complex logical reasoning, and lightweight daily Q&A. We also observed the billing structure alongside the runs.

    The evaluation framework can be summarized in four layers:

    • Task layer: a goal is provided without full constraints, testing autonomous planning;
    • Execution layer: an agentic coding tool handles file reads and writes, command execution, and result verification;
    • Observation layer: records the number of interruptions, infinite loops, repeated actions, and the rate of context expansion;
    • Cost layer: separates the billing share of input tokens, output tokens, and cache-hit portions.

    It is worth emphasizing that token consumption and task value are not linearly related. In long tasks, the truly expensive part is often not “writing code” but repeatedly reading large blocks of context and retrying after failures.

    2. Finding 1: Long-Horizon Autonomous Coding Is Engineering-Usable, but the Boundary Is Clear

    In two task types—database design and mobile emulator development—the best-performing model version was able to work autonomously for nearly an hour in a single stretch, with no human intervention, no infinite loops, and no missed critical steps.

    Take an accounting system as an example. Without fine-grained constraints, the model first produced a plan containing eight functional modules and six data tables, covering core capabilities such as bookkeeping and transaction statistics. It then broke down the development workflow on its own and, before finishing, generated a 10-item verification checklist. This closed loop of “plan first, execute next, self-check last” is the key to keeping long-horizon tasks from drifting off course.

    1. Goal input → Plan and module breakdown → Data table design → Component-by-component implementation
    2. → Integration and debugging → Verification against the self-check checklist → Output

    From an engineering perspective, the UI polish is still lacking, but the core flow is runnable. This indicates that the current focus of model capability is “functional correctness” rather than “experience refinement.” The models are therefore better positioned as executors, with humans responsible for acceptance criteria and for backing up the user experience.

    3. Finding 2: Complex Reasoning Shows Promise, but Stability Is Still a Weak Point

    On situational reasoning problems, the model performed well, identifying implicit premises and completing multi-step backward inference. However, on high-difficulty math proof problems, it produced incorrect conclusions; in some lightweight tests, it fell into an infinite loop of repeated self-confirmation.

    Infinite loops usually stem from three causes: missing verification conditions that prevent convergence, overly long context that dilutes early constraints, and abnormal tool returns that the model fails to recognize. A practical mitigation is to externalize convergence conditions:

    1. def should_stop(state, max_steps=40):
    2. if state.verified: # explicit acceptance condition
    3. return True
    4. if state.steps >= max_steps: # hard step limit
    5. return True
    6. if state.last_action == state.prev_action: # repeated action detection
    7. return True
    8. return False

    4. Finding 3: “Overthinking” Waste on Lightweight Tasks

    A counterintuitive phenomenon: on extremely simple questions, the more capable version sometimes answered incorrectly because it overcomplicated a simple problem and introduced unnecessary assumptions. The lightweight version, with a shorter path and a direct conclusion, actually achieved a higher accuracy rate.

    This suggests that model selection should be tiered by task complexity. Use the lightweight version for lightweight, high-concurrency scenarios and the high-capability version for long-chain engineering tasks, and make a complexity judgment at the routing layer to avoid using an expensive model for requests that are enumerable or template-based.

    5. Finding 4: Prices Rise, but Caching Changes the Cost Curve

    The API unit price of the new generation of models is usually higher than that of the previous generation, but the bill increase for long tasks is significantly smaller than the unit price increase. The reason is that in long tasks, the system prompt, project context, and history summaries are passed in repeatedly; once a cache hit occurs, this portion of the input is no longer billed at the original price.

    Optimization checklist: keep the system prompt and tool descriptions in a stable order, place volatile content at the end, summarize and compress history, and change large-file retrieval to on-demand reading. These practices reduce both token consumption and the risk of context expansion.

    6. Deployment Recommendations

    Overall, long-horizon agents have entered a usable range, but they require engineering guardrails: explicit acceptance criteria, circuit breakers for step count and repeated actions, tiered model routing, and cache-friendly context organization. If running on a container platform, logging services and monitoring alerts can be used to make task traces observable, turning “whether the model has drifted off course” into a quantifiable metric rather than something that depends on manual screen-watching.