Agentic Coding in Practice: Three-Tier Testing to Find the Code Limits of Chinese LLMs
This article presents a three-tier testing approach for evaluating agentic coding in Chinese large language models. It explains why a single prompt-and-answer test is not statistically meaningful, then walks through environment preparation principles, the goals and scoring dimensions of each tier (single-file generation, multi-file engineering collaboration, and autonomous debugging), the metrics used to measure self-correction, common interpretation pitfalls, and how to turn the tiers into a repeatable evaluation pipeline.
1. Why Gradient Testing Instead of One-Shot Q&A
Traditional human-AI coding interaction is closer to one-shot text completion: the user describes a requirement, the model returns a block of code, and correctness depends entirely on the user’s own judgment. Agentic coding differs by introducing an actionable reasoning loop: the model does not just produce text, but plans around a goal, retrieves information, calls an execution environment, reads runtime results, and revises its approach when something fails. Evaluating this capability with a single task tells you almost nothing statistically, because the outcome is heavily influenced by prompt wording, context length, and the runtime environment.
A more reasonable approach is to set up tiers. The first tier examines local correctness, the second examines engineering consistency and cross-file collaboration, and the third examines the convergence efficiency of autonomous debugging and self-correction. The three tiers progressively increase context and dependency complexity, making it easier to locate the boundaries of a model’s capability and to compare different models or parameter configurations side by side.
2. Environment Preparation Before Testing
The stability of the evaluation environment directly determines how trustworthy the conclusions are. Four principles are recommended:
- Isolation: each test case uses its own working directory and its own dependency environment to avoid cross-contamination.
- Reproducibility: pin dependency versions and disable nondeterministic behaviors such as “always upgrade to the latest version.”
- Observability: persist the full output of builds, tests, and static checks so failures can be traced back.
- Resource constraints: set a timeout and an output length limit for each run to prevent infinite loops from consuming resources.
On the cloud, you can use a container platform to host isolated execution sandboxes, object storage to keep logs and artifacts from each run, and a message queue to smooth peaks and chain together a “schedule-execute-reclaim” pipeline. Logging services plus monitoring and alerting can then track trends in metrics such as failure rate and average number of repair rounds. The general-purpose cloud product catalog offered by Baidu AI Cloud can serve as a selection reference for building this kind of evaluation platform.
3. Tier One: Single-File Feature Generation and Aesthetic Baseline
The goal is to verify whether the model can get it right on the first try when given a clear contract. Test cases should include explicit inputs, outputs, and boundary conditions, for example implementing a rate limiter with caching or a function that parses nested configuration.
Scoring is best split into four axes: functional correctness (whether boundaries are covered), interface consistency (naming, parameter validation, and unified error returns), readability (function length, nesting depth, and appropriate comment density), and test completeness (whether the model proactively adds cases).
An illustrative prompt:
Implement a token bucket rate limiter with the following requirements:1) Capacity and refill rate must be configurable;2) The time source must be injectable for unit testing;3) Expose only two public methods: acquire/release;4) Provide no fewer than 5 boundary test cases.
The key observation at this tier is whether the model over-engineers. The aesthetic ceiling often shows up as restraint: no unrelated abstraction layers, no extension points reserved for requirements that do not exist.
4. Tier Two: Multi-File Engineering Collaboration
Upgrade the task to a small project: separate the data access layer, business logic layer, and interface layer, and let the model decide the directory structure, dependency injection approach, and error propagation strategy on its own. This tier truly tests global consistency: whether naming style is uniform, whether exceptions get swallowed, and whether configuration is scattered everywhere.
It helps to provide a “constraint checklist” as hard context, for example a unified return structure, a ban on reading environment variables directly in the business layer, and a mandatory timeout for all external calls. Scoring can add static check pass rate and the proportion of duplicated code. Common failure modes include: inconsistent cross-file references that break the build, correctness only on the happy path while failure branches are ignored, and generated tests that depend on real network access.
5. Tier Three: Convergence of Autonomous Debugging and Self-Correction
This is the core differentiator of agentic capability. The approach is to pre-plant several defects in the project (wrong boundary conditions, wrong type conversions, missing resource release), give the model only the failure logs, and observe whether it can locate and fix them.
Three metrics need to be quantified: repair success rate, average number of repair rounds, and whether regression defects are introduced. Ideal behavior is to first narrow down the suspicious area, then form a hypothesis, and finally verify with a minimal change. Undesirable behavior is repeatedly tweaking unrelated code, commenting out tests, or simply loosening assertions so the cases “pass.”
A reusable loop skeleton:
while not passing and rounds < N:read the failure outputsummarize possible causes and rank themmake a single minimal changererun the target test caserecord the diff of each round for regression review
6. Interpreting Results and Common Pitfalls
First, do not equate “it runs” with acceptable quality; readability and test coverage must be examined in parallel. Second, watch for prompt contamination: the evaluation set and prompt templates should be fixed and versioned. Third, guard against data leakage by avoiding test cases copied verbatim from public problem sets. Fourth, pay attention to cost: repeated retries with long contexts significantly amplify resource consumption, so round and timeout limits should be set.
7. Implementation Recommendations
Turn the three tiers into a continuously running evaluation pipeline: put test cases and expected results under version control, trigger a full regression whenever the model or parameters change, output structured reports, and connect them to monitoring and alerting. Teams can start by selecting desensitized samples from real internal requirements to expand the case library, so conclusions stay close to their own tech stack. Only by holding to the three principles of “progressive tiers + fixed metrics + environment isolation” can you reliably map the real ceiling of agentic coding in code generation quality and engineering aesthetics.
