Long-Horizon AI Agent Testing: Findings After 10 Million Tokens

    This article reports on a long-horizon stress test of large models that consumed over 10 million tokens across continuous, multi-step tasks. It covers autonomous planning in agentic coding, how tool execution loops and prefix caching change output and cost, a failure mode where overthinking causes simple tasks to fail, stability issues in complex reasoning, and a reusable testing methodology with guardrails such as difficulty routing, verification checklists, and circuit breakers.

    Why Testing at the 10 Million Token Scale Matters

    Single-turn Q&A benchmarks only reflect how a model performs in short contexts with single-step reasoning. Real engineering work is a long chain: understanding requirements, designing a solution, coding, running, hitting errors, rolling back, and verifying again. Weaknesses in long-horizon capability only surface under stress tests that accumulate millions of tokens and run continuously for tens of minutes.

    This test focused on two capabilities:

    • Agentic coding: continuously calling tools, reading and writing files, executing commands, and self-correcting with minimal human intervention.
    • Stability in complex reasoning: whether multi-constraint logic puzzles and difficult math problems trigger infinite loops, repeated sampling, or conclusion drift.

    This article does not rank specific products. Instead, it abstracts the observed behavior into transferable evaluation dimensions and engineering practices.

    Three Notable Findings

    1. Long-Horizon Tasks Run Without Intervention: Autonomous Planning Is the Dividing Line

    In an open-ended database design task, the prompt deliberately omitted field definitions, table schemas, and tech stack constraints. It described only the business goal: bookkeeping, transaction statistics, and category management.

    The model first produced a design: 8 core functional modules and 6 data tables. It then broke the work into a development workflow and listed 10 verification items. Execution then ran without human intervention for nearly 60 minutes, with no interruptions, no infinite loops, and no missing critical steps.

    The engineering value of this behavior chain comes down to three points:

    • Decomposition: turning a vague goal into executable subtasks is the prerequisite for long-horizon stability.
    • Plan-execution consistency: the actual output aligned with the initial plan, showing that the model can keep the goal from drifting.
    • Built-in verification awareness: proactively generating an acceptance checklist is equivalent to shifting testing left.

    An example acceptance checklist might look like this:

    1. Acceptance Checklist (Example)
    2. 1. Table schemas map one-to-one to business entities
    3. 2. Amount field precision and currency handling are correct
    4. 3. All four CRUD operations work
    5. 4. Custom categories can be added and deleted
    6. 5. Statistical definitions match transaction details
    7. 6. Invalid input produces clear errors
    8. 7. Concurrent writes produce no dirty data
    9. 8. Initialization scripts can be run repeatedly
    10. 9. Key frontend interactions are not blocked
    11. 10. Logs can pinpoint the cause of failures

    2. Tool Collaboration Amplifies Output: Put the Model in the Execution Loop

    Pairing the model with an agentic coding tool, such as a command-line agent, works far better than plain text generation. The execution loop supplies the feedback the model lacks: compile errors, test failures, and runtime exceptions all become context for the next round.

    The recommended practice is to fix a “read, modify, run, inspect” loop and to truncate failed output while keeping the key fragments, so the context is not flooded with noise.

    3. Caching Significantly Changes the Cost Structure of Long Tasks

    Long tasks have highly repetitive prefixes: the same codebase, the same conventions, and the same set of tool definitions. When the server supports prefix caching, the repeated portion is not billed again, so the bill grows noticeably slower than the call volume.

    The practical recommendation is to place stable content first (conventions, directory descriptions, interface contracts) and volatile content last (the current error, the current instruction) to maximize cache hits.

    One Surprise: Overthinking Causes Lightweight Tasks to Fail

    On minimal logic puzzles, the more capable version sometimes fell into repeated self-doubt, went in circles, and reached a wrong conclusion, while the lightweight version answered directly and correctly.

    This is not a capability problem but a reasoning budget allocation problem: the model treats a simple problem as a hard one, the sampling path grows longer, and the probability of accumulated errors rises.

    The engineering fix is difficulty routing: use a lightweight model or rules for a quick decision first, escalate to a strong reasoning model when confidence is low, and set a maximum number of reasoning rounds and a timeout circuit breaker.

    1. def route(prompt, max_rounds=3, timeout_s=20):
    2. r = fast_model(prompt) # Lightweight direct answer
    3. if r.confidence > 0.8:
    4. return r.answer
    5. for _ in range(max_rounds): # Strong reasoning with circuit breaker
    6. r = strong_model(prompt, timeout=timeout_s)
    7. if r.verified:
    8. return r.answer
    9. return fallback_answer(prompt)

    Stability in Complex Reasoning: Highlights and Infinite Loops Coexist

    Performance on logic puzzles stood out, indicating an advantage in integrating multi-constraint clues. On high-difficulty math problems, however, repeated derivation and circular verification often led to timeouts or wrong answers.

    Possible improvements include asking the model to explicitly write out invariants and boundary conditions, introducing external computation tools for verification, and adding deduplication detection on the reasoning chain (interrupt when semantic similarity across N consecutive steps is too high).

    A Reusable Stress-Testing Methodology (Checklist)

    1. Task tiers: lightweight Q&A, single-file changes, cross-file engineering, and long-horizon unattended runs.
    2. Metrics: plan completeness, execution consistency, number of self-corrections, verification pass rate, and token consumption per task.
    3. Cost accounting: separate input, output, and cache hits, and observe the real billing curve of long tasks.
    4. Stability guardrails: three gates for maximum rounds, timeout, and repetition detection.
    5. Acceptance: the end state must be runnable, testable, and rollback-capable.

    Conclusion

    The core conclusion after investing 10 million tokens is that long-horizon agent capability has moved from “can write code” to “can deliver engineering,” but reasoning stability and budget allocation still need engineering safeguards. Making verification checklists, difficulty routing, cache-friendly context, and circuit breakers part of the default architecture is the key to turning model capability into stable output. To deploy this on Baidu AI Cloud, you can build an observable evaluation pipeline using general capabilities such as container platforms, logging services, and monitoring and alerting.