10 Million Tokens of Real-World Testing: AI Agent Coding — Three Wins and One Surprise

    Based on hands-on testing that consumed roughly 10 million tokens of frontier LLM calls, this article evaluates how large language models perform as coding agents in long-horizon engineering tasks. It covers a reusable evaluation framework built around observable process metrics, three promising findings — sustained autonomous execution over ~60-minute engineering tasks, models proactively generating their own acceptance checklists, and context caching keeping long-session costs manageable — plus one unexpected failure mode: overthinking on simple tasks. The article closes with practical engineering recommendations for task routing, budget control, verification, and monitoring to help teams deploy AI coding agents reliably in production.

    As agent-based coding moves from demos into real engineering, a single Q&A that “looks fine” proves very little. What matters is whether a model can sustain planning, tool calls, self-correction, and final verification across long-running tasks; whether it stays direct and efficient on simple tasks; whether it remains stable during complex reasoning; and whether the token costs of long sessions stay under control. This article shares findings from real-world testing that consumed roughly 10 million tokens of a general-purpose large model, focused on agent-based coding and reasoning stability, and offers a reusable evaluation methodology along with engineering recommendations.

    1. Evaluation Design: Breaking “Can It Do the Job” into Observable Metrics

    Our testing looked beyond final answers, decomposing each task into an observable process: whether the plan was complete, whether execution was interrupted, whether the agent fell into loops, whether tool calls were effective, whether key steps were skipped, whether verification passed, how many human interventions were needed, and the per-task token consumption and cache hit rates.

    The task set covered three scenarios:

    • Complex engineering tasks (e.g., database design and business system development)
    • Situational logic puzzles
    • Competition-level math problems and lightweight business Q&A

    A higher-tier model version handled long-horizon tasks, while a lightweight version handled low-difficulty, low-risk tasks, allowing us to compare latency, cost, and accuracy between the two.

    A typical agent execution loop can be abstracted as:

    1. def run_agent(task, model, budget):
    2. plan = model.plan(task)
    3. state = init_state(task)
    4. observations = []
    5. for step in range(budget.max_steps):
    6. action = model.next_action(plan, state, observations)
    7. if action.type == "tool_call":
    8. obs = execute_tool(action.name, action.args)
    9. observations.append(summarize(obs))
    10. elif action.type == "patch":
    11. state = apply_patch(state, action.content)
    12. if verifier.passed(task, state):
    13. return {"status": "success", "steps": step}
    14. if detector.loop(state, observations):
    15. return {"status": "loop_failure", "steps": step}
    16. if token_cost(state) > budget.max_cost:
    17. return {"status": "budget_exceeded", "steps": step}
    18. return {"status": "max_steps_exceeded"}

    This loop looks simple, but it determines whether agent-based coding succeeds or fails: Is the plan executable? Are tool results summarized correctly? Is state persistable? Can failures be recovered? Can budgets be enforced?

    2. Win #1: Long-Horizon Tasks Move from “Writing Code” to “Driving Projects”

    In a database design task, the prompt gave few constraints — only the business objective. The higher-tier model first produced a complete design, including core functional modules, table schemas, a development workflow, and a verification checklist, then moved into autonomous execution. During testing, the model coded continuously for nearly 60 minutes with no interruptions, no dead loops, and no skipped key steps, following its original plan throughout. The final system was still weak on front-end aesthetics, but core functionality worked: adding records and full CRUD operations completed without errors.

    This shows that the key capability of agent-based coding is shifting from “generating code snippets” to “driving engineering tasks.” Long-horizon tasks demand three capabilities:

    1. Task decomposition — breaking a vague goal into modules, table schemas, interfaces, and pages.
    2. State retention — not losing context across multiple rounds of tool calls.
    3. Self-correction — locating errors, fixing them, and re-verifying after failures.

    Engineering teams should explicitly include these three capabilities in their evaluations rather than only checking whether the final code runs.

    3. Win #2: Models Now Proactively Build Acceptance Checklists

    Even more notable is the model’s verification awareness. It planned a multi-item acceptance checklist before development and attempted self-verification afterward. The agent is no longer just responsible for “writing” — it has started “proving that what it wrote is correct.”

    When deploying this pattern, move acceptance criteria to the front of the workflow: in the prompt, require the model to output a test plan, an acceptance checklist, and a rollback plan for failures. Externally, back this up with automated tests, static analysis, and API contract validation. And summarize tool call results in a structured way to avoid context bloat.

    4. Win #3: Context Caching Keeps Long-Session Costs Under Control

    The higher-tier version’s per-call pricing increased compared with the previous generation, but with context caching in long tasks, total bill growth was far less dramatic than the price increase alone would suggest. Cost can be modeled as:

    1. Total cost = uncached input tokens x input price
    2. + cache-hit input tokens x cache price
    3. + output tokens x output price
    4. + retry and tool-result round-trip costs

    Whether caching hits depends on whether the context prefix stays stable. In practice:

    • Put system prompts, tool definitions, repository summaries, and task specs in the stable prefix.
    • Place frequently changing tool results later in the context, and summarize them.
    • Set budget caps, maximum step counts, and timeout fallbacks for long sessions.

    For cloud deployments, you can persist task traces in object storage, collect call chains through a logging service, and track anomaly rates and per-task cost with monitoring and alerting — a minimum viable evaluation base. On Baidu AI Cloud, for example, the general-purpose object storage, logging, and monitoring services are sufficient to build this foundation.

    5. The Surprise: Overthinking on Lightweight Tasks

    The most interesting surprise in testing was failure on simple tasks. In lightweight business Q&A, the higher-tier version sometimes failed to give a direct answer due to repeated self-verification, misjudged task difficulty, or poor reasoning budget allocation, while the lightweight version responded directly and efficiently. The lesson: “a stronger model” does not mean “better on every task.”

    Engineering teams should introduce task routing: send low-difficulty, low-risk tasks to the lightweight version by default; escalate high-risk tasks to the higher-tier version with maximum reasoning steps, timeout fallback, and confidence thresholds.

    1. def route(task):
    2. if task.difficulty == "low" and task.risk == "low":
    3. return "fast_model", {"max_steps": 3, "timeout": "short"}
    4. return "high_model", {"max_steps": 30, "timeout": "long", "verify": True}

    6. Complex Reasoning: Highlights Coexist with Stability Gaps

    On situational logic puzzles, the model performed well, carrying out multi-step hypothesis and elimination reasoning. But on competition-level math problems and some lightweight tests, it still produced dead loops or wrong answers. Likely causes include: self-verification loops lacking external signals, unreasonable reasoning-step budgets, and misjudged problem difficulty. Recommended mitigations include external solvers, multi-model voting, loop-count limits, tiered test sets, and confidence calibration — to avoid mistaking “long reasoning” for “high-quality reasoning.”

    7. A Deployment Checklist

    1. Task tiering: Route models and budgets by difficulty, risk, and verifiability.
    2. Verification first: Require acceptance checklists, test plans, and rollback plans as outputs.
    3. State persistence: Save plans, patches, tool results, and failure reasons to support resuming from checkpoints.
    4. Context layering: Keep stable prefixes cache-friendly, summarize dynamic results, and control the context compression ratio.
    5. Budget and monitoring: Set per-task token caps, maximum steps, and alerts on P95 latency and loop rates.
    6. Continuous evaluation: Run regression against a fixed task set, tracking completion rate, human intervention rate, cache hit rate, and per-task cost.

    Conclusion

    Agent-based coding’s long-horizon planning, tool use, and verification loops are now ready for real engineering use, and context caching eases the cost pressure of long sessions. But overthinking on lightweight tasks and instability in complex reasoning remain boundaries that require engineering safeguards. The key to stable deployment is placing model capabilities inside an agent framework that is observable, constrained, and rollback-capable.