Evaluating AI Agent Code Reproduction Capabilities and Cost Breakdown

    This article examines why strong code-generation benchmark scores often fail to translate into real-world engineering performance when AI agents are asked to reproduce deep learning experiments. It breaks down the stages of a reproduction task, four common failure modes of lower-capability model tiers, and how to trace execution logs to pinpoint root causes instead of guessing. It also compares higher-capability tiers, explains how prompt caching and retry rates drive per-task cost, and offers practical recommendations for permissions, observability, rollback, tier routing, and cost tracking.

    1. Background: Why “Being Able to Write Code” Is Not the Same as “Being Able to Reproduce”

    Over the past year or two, scores on code-generation benchmarks have kept climbing. Yet developers who connect models to AI coding tools and grant them broad file and command permissions often get an experience that looks nothing like the leaderboards. The reason is straightforward: reproducing a deep learning experiment from a paper is a typical long-chain, weakly constrained, environment-dependent task. It requires the model to make dozens or even hundreds of correct decisions in a row, while benchmark problems are usually short-chain, strongly constrained, isolated questions.

    A complete reproduction task involves at least the following stages:

    1. Paper parsing: extracting model architecture, hyperparameters, data splits, and evaluation metrics from a document with complex formatting;
    2. Environment planning: determining how the dependency stack, build toolchain, accelerator drivers, and runtime versions fit together;
    3. Environment setup: correctly configuring proxies, mirror sources, and dependency caches under network restrictions;
    4. Data preparation: locating datasets, handling custom formats, and writing preprocessing and augmentation logic;
    5. Training and validation: aligning logs and metrics with the paper’s claims and locating the source of any deviation;
    6. Self-checking: tracing back through its own actions after an error and correcting course instead of stacking new mistakes.

    A failure in any one of these stages fails the whole task. Differences in model capability show up mainly in the ability to self-correct after failure, not in how elegant the first piece of code looks.

    2. Typical Failure Modes: Four Problems in Lower-Capability Model Tiers

    After connecting smaller, lightweight model tiers to a high-permission AI coding tool, the common problems fall into four categories that cover most real-world “crash” scenarios.

    First: aimless environment traversal. Without a clear hypothesis, the model repeatedly lists directories, digs through old projects, and opens unrelated files, burning steps without advancing the task. This is essentially a missing search strategy: it does not know “what information is missing,” so it substitutes enumeration for reasoning.

    Second: side effects spilling over. To work around some restriction, the model copies work products into local directories, modifies global configuration, or writes temporary files into shared directories, leaving the workspace in disarray. The cost of later investigation ends up far higher than the cost of redoing the work.

    Third: command-level defects. When moving large numbers of small files across file systems, the model writes the match scope of a copy or sync command incorrectly and pulls in parent directories, contaminating data. These errors are especially frequent on shared storage and distributed file systems, because metadata operations on small files are expensive and easily trigger timeouts and partially completed states.

    Fourth: no rollback. After hitting an error, the model tends to pile on new patch-style operations instead of returning to the last stable state and replanning, ending up with an execution chain of errors stacked on errors.

    A simplified illustration shows how the problem gets amplified:

    1. # Counter-example: copy logic with an unscoped range can pull in non-target directories
    2. def stage(src, dst):
    3. copy_tree(src, dst) # src is not checked against an allowlist
    4. run(cmd_from_llm_output) # executes model-generated commands directly, no dry-run

    The improvement is to make “scope validation + dry-run + rollback” a hard constraint:

    1. def stage(src, dst, allowlist, dry_run=True):
    2. assert is_within(src, allowlist), "source out of allowed scope"
    3. plan = build_copy_plan(src, dst) # build the plan first
    4. if dry_run:
    5. return plan # dry-run, nothing written to disk
    6. with snapshot(dst) as snap: # create a rollback snapshot
    7. execute(plan)
    8. return snap

    3. Execution Chain Tracing: Turning “It Feels Wrong” into an Actionable Conclusion

    In the face of failure, the most effective move is not to swap models and hope for luck, but to analyze the execution chain structurally. It is worth recording at least the following fields to build a replayable trace:

    • Step index and action type (read file / write file / run command / search);
    • Input and output summaries (saved truncated to avoid log explosion);
    • Per-step latency and cumulative token consumption;
    • Permission boundaries and whether any interception was triggered;
    • Failure point markers and rollback counts.

    With a trace in hand, diagnosis becomes deterministic: pull the three steps before and after the failure point and build a minimal reproduction. The copy defect above was located this way to the specific stage of “staging through a temporary directory + wrong copy scope,” rather than being vaguely attributed to “the model is bad.” This reflects an engineering principle: prove the chain is broken first, then discuss model capability.

    4. Capability Tiers and Task Matching: Performance and Cost of Higher Tiers

    When the same task is handed to a higher-capability tier with more thorough reasoning, it usually starts smoothly and completes. The key behavioral difference is that it reads the documentation to form a hypothesis first, then verifies in small steps, and when it hits environment problems it checks dependencies and paths first instead of traversing blindly.

    Cost deserves equal attention. For a reproduction task of moderate complexity, end-to-end execution takes on the order of twenty minutes, and pure API call fees land in the range of a few RMB, which is acceptable on a per-task basis. What really drives the bill is not unit price but three variables:

    1. Retry rate: the multiplier effect of failed reruns;
    2. Context length: long documents and long logs significantly raise input-side consumption;
    3. Cache hits: once a prefix is cached, billing for repeated context drops sharply.

    5. Caching and Billing: The Underrated Cost Lever

    Caching policies differ widely across providers, but the general rule is: the bigger the price gap between a cache miss and a cache hit, the more a long-context repeated call benefits. When the miss-to-hit price ratio reaches two orders of magnitude, a coding session that stably reuses the same system prompt and repository context sees its marginal cost approach zero; when the gap is only one order of magnitude, the same usage costs an order of magnitude more.

    So the focus of cost optimization is not pushing unit price down, but raising the stability of the cacheable prefix:

    • Put the system prompt, project conventions, and directory descriptions at the very front and keep them byte-stable;
    • Move volatile information (timestamps, random IDs, live logs) to the end or strip it out;
    • Avoid meaninglessly rewriting the prefix mid-session;
    • For large documents, do structured extraction first, then inject the result as stable context.

    Note that specific billing rules should follow the provider’s official documentation; this article only discusses the general mechanism.

    6. The Real Cost of Subscription Coding Plans

    Subscription “coding plans” spread quickly over the past year, but they reveal a plain fact: model inference has a real cost, and pricing below the cost line must come from subsidies. When a plan prices a single request noticeably above the industry norm, the more reasonable reading is not “it is expensive” but it is closer to the real cost. Practical advice for developers:

    • Make decisions on per-task cost rather than monthly fee, and build your own “per-task cost baseline”;
    • Set a clear admission threshold for lightweight tiers so they do not take on high-permission, long-chain tasks;
    • Configure budget caps and step caps for higher-capability tiers to prevent runaway loops;
    • Prefer platforms with timely plan support and a stable model release cadence, to avoid migration costs from interrupted plans.

    7. Evaluation and Integration Checklist

    • Task set design: cover four sub-task types—document parsing, environment setup, custom data preprocessing, and metric alignment—with no fewer than three samples each;
    • Permission policy: least privilege by default, writes limited to allowlisted directories, command execution forced through dry-run;
    • Observability: full-chain logging with step-by-step replay;
    • Rollback: snapshot at every stage, return to the last stable state on failure;
    • Tier routing: lightweight tiers handle retrieval, summarization, and single-file edits; higher-capability tiers handle long-chain planning and reproduction;
    • Cost dashboard: track duration, tokens, cache hit rate, and cost per task to build trend comparisons.

    8. Conclusion

    The weakness of lightweight model tiers on end-to-end reproduction tasks is not a single-point capability gap but a systemic shortfall in long-chain decision-making and self-correction. Higher-capability tiers, paired with sound permission constraints, chain tracing, and cache-friendly practices, can complete high-quality reproduction within a controlled budget. For teams, real competitiveness comes from the evaluation system and engineering guardrails, not from chasing a single leaderboard score. In general engineering practice on platforms such as Baidu AI Cloud, making observability, permission boundaries, and cost management default capabilities is the prerequisite for bringing large models reliably into the development workflow.