Agent Programming and Reasoning Stability: Observations from a Multi-Million-Token Evaluation

    A multi-million-token evaluation compares high-capability and lightweight model forms on long-horizon agent programming, complex reasoning, simple tasks, and cost. The findings cover stronger autonomous execution under engineering constraints, unstable complex reasoning, overthinking on light tasks, and how routing, caching, checkpoints, and budgets affect total cost.

    Agent Programming and Reasoning Stability: Observations from a Multi-Million-Token Evaluation

    As open-weight models continue to draw attention, developers are focusing on agent programming, long-horizon task planning, and complex reasoning. We recently ran a multi-dimensional evaluation that consumed more than ten million tokens, centered on a general question: can a model autonomously plan, call tools, correct itself, and control cost on real engineering tasks? The evaluation does not target any specific product. It abstracts two common capability forms: a high-capability version and a lightweight version. The former emphasizes complex tasks and long-horizon autonomous execution; the latter emphasizes low latency, low cost, and direct answers on simple tasks. This article does not recount a single product experience. It extracts reusable engineering observations and practical recommendations.

    1. Evaluation Design: From Single-Turn Q&A to Long-Horizon Task Loops

    Traditional model evaluations often rely on single-turn Q&A, short-text generation, or static benchmarks. They struggle to cover the real challenges of agent programming. An agent must maintain state across multi-turn tool calls, recognize failures, roll back errors, and finish the task within budget. This evaluation therefore used layered task sets and a unified cost accounting method:

    • Long-horizon agent tasks: database schema design, development of a mobile runtime environment simulator, multi-file code refactoring, and similar work. The model must split the task, produce a plan, call tools, and verify results on its own.
    • Complex reasoning tasks: hard mathematical proofs, situational logic problems, and multi-constraint planning problems, used to observe answer accuracy and reasoning stability.
    • Lightweight tasks: simple everyday knowledge questions, single-step information lookup, and short code completion, used to observe over-planning.
    • Cost metrics: cumulative token consumption, cost per task, billing changes after cache hits, number of human interventions, and loop-detection counts.
    • Quality metrics: task completion rate, first-pass rate, self-check coverage, error-rollback success rate, and reproducibility.

    Total consumption exceeded ten million tokens, and long-horizon tasks accounted for a substantial share. Overall, the high-capability version stood out in hour-scale continuous autonomous execution, but showed interesting weaknesses on some extreme tasks and lightweight scenarios. The lightweight version was more direct and efficient on simple tasks. The findings below are organized into four dimensions.

    2. Finding 1: Long-Horizon Agent Programming Improved, but Depends on Engineering Constraints

    On long-horizon agent programming tasks, the high-capability version could execute autonomously for more than an hour without step-by-step human prompting, and complete relatively complex engineering workflows. Its advantages showed up in three ways:

    1. Stronger task decomposition: For compound tasks such as “design a database and generate data-access code,” the model first produced a staged plan, then advanced through table structure, indexes, migration scripts, the access layer, and test cases.
    2. More stable tool use: The model could close the loop across code generation, file read/write, command execution, and result validation, and adjust the next action based on error messages.
    3. More proactive self-correction: When tests failed, the model located the failing cases, changed the implementation, and reran them, rather than ending the task immediately.

    That does not mean the system can be left completely unattended. The core risks of long-horizon tasks are error accumulation and repeated execution. Without checkpoints, permission controls, and budget limits, an agent can keep spending tokens on a wrong path. In practice, the agent execution loop should include a state machine and loop detection:

    1. function run_agent(task, budget, max_steps):
    2. plan = planner(task)
    3. state = init_state(task)
    4. while not state.done and state.cost < budget and state.steps < max_steps:
    5. action = policy(state, plan)
    6. result = tool_exec(action)
    7. state = update(state, result)
    8. if detect_loop(state):
    9. state = replan(state)
    10. if need_human(state):
    11. state = request_human(state)
    12. checkpoint(state)
    13. return verify(state)

    Here, detect_loop can look for repeated actions, repeated errors, context similarity, and differences in tool returns. checkpoint saves intermediate artifacts so the run can roll back. The stronger the long-horizon capability, the more it needs engineering guardrails. Otherwise, autonomy amplifies uncontrolled cost.

    3. Finding 2: Complex Reasoning Has Bright Spots, but Stability Remains the Key Variable

    On situational logic problems and multi-constraint reasoning tasks, the high-capability version showed solid abstraction ability: it could identify implicit conditions and provide reasonable explanations. On hard mathematical proofs and some extreme tasks, however, two problems appeared. One was falling into a verification loop. The other was producing an answer that looked complete but contained a critical step error.

    This means complex reasoning cannot be judged only by single-question accuracy. Reasoning stability and the ability to recognize failure also matter. In engineering practice, a three-layer strategy is useful:

    • Layered sampling: Sample high-value reasoning questions multiple times, then filter answers with consistency voting or a verifier.
    • External verification: Hand computable or executable parts to tools, such as symbolic computation, unit tests, or constraint solvers, to check intermediate results.
    • Budget control: Set a maximum number of steps and tokens for reasoning. After the threshold, force the current conclusion and mark uncertainty.

    The weakness in complex reasoning does not make the model unusable. It means model reasoning should be combined with programmatic verification. For developers, the greatest danger is not a wrong answer, but continued confident output along a wrong path. Evaluations should therefore record metrics such as loop count, ineffective verification count, and confidence on incorrect answers.

    4. Finding 3: Lightweight Tasks Showed Overthinking; Routing Matters More Than a Single Model

    The most unexpected result was this: on simple everyday knowledge questions, the high-capability version sometimes failed to give the correct answer because it over-planned, while the lightweight version was more direct and efficient. Faced with a simple scenario, the high-capability version assumed multiple edge conditions, repeatedly checked constraints, and drifted away from the simplest answer. The lightweight version reached a conclusion in one step.

    This points to a common misconception: not every task should call the strongest model. An agent system should route tasks dynamically based on complexity, risk, latency requirements, and budget. Pseudocode:

    1. function route(task):
    2. if task.complexity < LIGHT_THRESHOLD and task.risk == "low":
    3. return light_model(task, max_steps=2)
    4. if task.needs_tools or task.is_long_horizon:
    5. return high_model(task, max_steps=20, budget=task.budget)
    6. return high_model(task, max_steps=8, budget=task.budget)

    At the prompt layer, a meta-instruction can also ask the model to decide first whether deep reasoning is needed, or a lightweight model can classify the task up front. Early-stop conditions on simple tasks prevent the model from spending too much reasoning budget on low-value problems. Performance on lightweight tasks shows that matching model capability to the task matters more than simply chasing parameter count.

    5. Finding 4: Unit Cost Rose, but Caching and Tiered Strategy Can Lower the Total Bill

    Compared with earlier versions, the high-capability version has a higher price per token, but caching on long tasks can reduce part of the cost. Long-horizon tasks contain a large amount of repeated context, tool descriptions, project files, and history. When the cache hits, billed tokens are lower than nominal consumption. Growth in the total bill is less pronounced than the increase in unit price.

    Cost can be controlled in four ways:

    1. Context caching: Cache stable system prompts, tool definitions, code skeletons, and retrieval results. Cache keys should include task type, normalized prompt, context hash, and tool schema version.
    2. Tiered routing: Send simple tasks to the lightweight version and complex tasks to the high-capability version. For extreme tasks, add a verifier instead of retrying without limit.
    3. Budget caps: Set a token budget, a step budget, and a human-escalation threshold for each task. When a limit is exceeded, return intermediate results and request confirmation.
    4. Result reuse: Build a result store for repetitive code generation, document summaries, and test-case generation to reduce repeated reasoning.

    A cache key can be designed as:

    1. cache_key = hash(
    2. task_type +
    3. normalized_prompt +
    4. context_hash +
    5. tool_schema_version +
    6. model_capability_level
    7. )

    Caching does not reduce cost unconditionally. If task context changes frequently or tool definitions are unstable, the hit rate falls. Evaluations should therefore record nominal tokens, billed tokens, cache hit rate, and cost per task, rather than looking only at unit price.

    6. A Reusable Evaluation Checklist and Practical Recommendations

    Based on this multi-million-token evaluation, we recommend the following checklist when assessing agent programming and complex reasoning:

    • Layer the task set: assign separate weights to lightweight tasks, complex reasoning, and long-horizon agent tasks so one dimension does not distort the result.
    • Make success executable: prefer test cases, constraint checks, and artifact verification over subjective scoring.
    • Record failure modes: count loops, over-planning, misplaced confidence, tool misuse, and context forgetting separately.
    • Control human intervention: record how often and why people intervene, as a measure of real autonomy.
    • Make cost accountable: track token consumption, cache hits, retries, and cost per task.
    • Keep configuration reproducible: fix prompt templates, tool schemas, budget parameters, and evaluation data versions.

    In production, treat the high-capability model as an executor for complex tasks and the lightweight model as a router for high-frequency tasks, then combine them with verifiers, checkpoints, caching, and budget control. Progress in agent programming is worth attention, but real production value comes from managing capability limits, cost limits, and failure limits together.