A Three-Tier Gradient Testing Guide for Evaluating LLM Agentic Coding Capabilities

    Evaluating whether a large language model can simply generate a snippet of code is not enough to judge its real programming ability. This guide introduces a three-tier gradient testing approach for assessing LLM agentic coding capabilities: function-level code generation, multi-file engineering collaboration, and agentic reflection with self-debugging. It shows how to build reproducible, quantifiable, and discriminating test cases at each tier, how to score results across correctness, engineering quality, security, code aesthetics, and reflection using a weighted rubric, and how to execute generated code safely in sandboxed environments. By following this method, developers can turn abstract "model capability" into a repeatable, comparable, and regression-ready evaluation process that supports more rational and sustainable model selection.

    1. Rethinking Agentic Coding and LLM Code Evaluation

    Traditional AI coding interactions are usually question-and-answer style: the user provides a prompt, the model returns code in a single pass, and whether that code is correct, maintainable, and resilient to edge cases often has to be judged manually afterward. Agentic Coding goes a step further. It emphasizes that the model can, after generating code, inspect its own work, locate defects, plan repair actions, and progressively converge on a correct solution across multiple turns of interaction.

    For this reason, teams often ask the same questions when evaluating tools: How do you evaluate an LLM’s coding ability? How do you test agentic coding capability? How do you choose the right test gradient? If you only assess “whether the model can generate code that looks correct,” you will easily reach superficial conclusions. A more reliable evaluation should cover code correctness, engineering collaboration, reflection and debugging ability, and code aesthetics such as naming, structure, and error handling.

    The idea behind gradient testing is to observe model performance through a sequence of test cases that increase in difficulty and progress across dimensions. Rather than judging a single final answer, it observes how stable the model’s performance is under different levels of complexity and constraint. For developers, the payoff is clear: it converts the abstract notion of “model capability” into a reproducible testing process, producing evaluation conclusions that are quantifiable, comparable, and regression-ready.

    2. Gradient Testing Overview: From Point Correctness to an Engineering Loop

    The core of gradient testing is not piling on hard problems, but shaping test cases that draw clear capability boundaries. A practical gradient evaluation framework should satisfy at least three conditions: it must be reproducible (the same inputs, a fixed environment, and a fixed version can be re-run); it must be quantifiable (each case has clear pass criteria and scoring signals); and it must be discriminating (it can separate “syntactically correct” from “engineering-usable” and from “self-repairing”).

    Tier Evaluation Goal Input Form Expected Output Key Metrics Automation Level Common Pitfall
    Tier 1: Function-level code generation Judge basic coding correctness Single function, single algorithm, clear input/output Runnable function and unit tests Unit test pass rate, boundary coverage, static analysis High Only checking sample inputs, ignoring null and extreme values
    Tier 2: Multi-file engineering collaboration Judge engineering structure and module design Application requirements, directory constraints, interface requirements Directory tree, interface contracts, dependency list, run commands Runnability, module coupling, interface consistency Medium Only checking local functions, not validating overall structure
    Tier 3: Agentic reflection and autonomous debugging Judge self-inspection, reflection, and repair loop Tasks with injected defects or conflicting constraints Repair process, verification records, improved code Defect detection rate, repair success rate, turn efficiency Medium-low, requires manual spot checks Only judging the final result, ignoring the reflection trajectory

    In practice, common mistakes include: scoring only the final answer and ignoring intermediate reflection; letting test cases vary randomly, which makes results impossible to reproduce; scoring without weights, which prevents a unified comparison; using an unfixed test environment, so model performance is affected by dependency versions; and testing only syntactic correctness while ignoring error handling and engineering maintainability. Avoiding these problems is the prerequisite for a trustworthy evaluation.

    3. Tier 1: Function-Level Code Generation

    Tier 1 is used to filter the most basic code generation ability. It is suitable for assessing whether a model can write function implementations with correct logic, clear boundaries, and sensible naming.

    Sample task:

    1. # Task: implement a function that checks whether a given string is a palindrome, ignoring case and non-letter characters
    2. def is_palindrome(s: str) -> bool:
    3. ...

    At this tier, you cannot judge by a single normal input passing. You must add unit tests, boundary inputs, and automated scoring signals. At minimum, cover the following cases:

    Input Expected Output Observation Point
    "A man, a plan, a canal: Panama" True Whether it ignores case and non-letter characters
    "" True Whether it handles an empty string
    ".,!" True Whether it handles symbols-only input
    "abc" False Whether it recognizes a non-palindrome
    "Madam" True Whether it handles mixed case
    "0P" False Whether it handles a mix of letters and digits

    Reusable unit test example:

    1. import unittest
    2. class TestIsPalindrome(unittest.TestCase):
    3. def test_normal_case(self):
    4. self.assertTrue(is_palindrome("A man, a plan, a canal: Panama"))
    5. def test_empty_string(self):
    6. self.assertTrue(is_palindrome(""))
    7. def test_symbols_only(self):
    8. self.assertTrue(is_palindrome(".,!"))
    9. def test_non_palindrome(self):
    10. self.assertFalse(is_palindrome("abc"))
    11. def test_mixed_case(self):
    12. self.assertTrue(is_palindrome("Madam"))
    13. if __name__ == "__main__":
    14. unittest.main()

    Recommended automated scoring signals include:

    1. Unit test pass rate: whether all tests pass, and the number of failing cases.
    2. Boundary coverage: whether it proactively handles empty input, symbols-only input, mixed case, and invalid types.
    3. Static analysis results: whether tools such as ruff, pylint, and pyright report naming, complexity, type, or unused-variable issues.
    4. Implementation conciseness: whether there are obviously redundant branches, meaningless loops, or overly complex logic.
    5. Reasonableness of error handling: whether it gives clear behavior for invalid input instead of silently returning a wrong result.

    Tier 1 mainly filters out models that are “syntactically correct but logically fragile.” If a model does not even proactively consider edge cases, the stability of its later engineering-level tasks usually needs to be assessed with caution.

    4. Tier 2: Multi-File Engineering Collaboration

    Tier 2 moves the task from an isolated function to engineering collaboration. Here, the focus is no longer whether a single function runs, but whether the model can understand module boundaries, dependency relationships, directory conventions, and the overall way to run the project.

    Take a “to-do app” as an example. A minimal task template can be designed as follows:

    1. Task: implement a command-line to-do application that supports add, list, complete, and delete.
    2. Requirements:
    3. 1. Output a runnable multi-file directory structure;
    4. 2. Provide core interface contracts;
    5. 3. List dependencies;
    6. 4. Provide run commands;
    7. 5. Provide sample input and output;
    8. 6. Include at least one minimal test command.

    Tier 2 must require the model to produce reproducible artifacts. It is recommended to collect the following materials in a fixed way during evaluation:

    Artifact Type Requirement Evaluation Purpose
    Directory tree Shows file and module organization Judge whether the structure is clear
    Interface contracts Classes, functions, data structures, error types Judge whether modules connect correctly
    Dependency list Explicitly names third-party or standard libraries Judge whether the environment is reproducible
    Run commands Start, install, and test commands Judge whether it is runnable in practice
    Sample input/output Shows real usage Judge whether behavior matches requirements
    Test file At least one runnable test Judge whether results are verifiable

    A reference directory tree template:

    1. todo_app/
    2. ├── models.py
    3. ├── storage.py
    4. ├── service.py
    5. ├── cli.py
    6. ├── errors.py
    7. └── tests/
    8. ├── test_models.py
    9. └── test_service.py

    The interface contract can require the model to make the following structure explicit:

    1. class TodoItem:
    2. id: str
    3. title: str
    4. completed: bool
    5. class TodoService:
    6. def add(self, title: str) -> TodoItem: ...
    7. def list(self) -> list[TodoItem]: ...
    8. def complete(self, todo_id: str) -> TodoItem: ...
    9. def delete(self, todo_id: str) -> bool: ...

    The dependency list should separate the standard library from third-party libraries. For example, relying only on argparse, dataclasses, json, and pathlib should be preferred, avoiding unnecessary dependencies. Run commands should be fixed in an executable form, for example:

    1. python -m todo_app.cli add "write docs"
    2. python -m todo_app.cli list
    3. python -m todo_app.cli complete 1
    4. python -m pytest -q

    Tier 2 effectively exposes the model’s problem of being “locally correct but globally chaotic.” For example, an individual function may look reasonable, but module responsibilities are muddled, interfaces are inconsistent, and the project cannot be installed, run, or tested. These are precisely the key dividing lines between “knowing how to write code” and “knowing how to do engineering.”

    5. Tier 3: Agentic Reflection and Autonomous Debugging

    Tier 3 examines the core of Agentic Coding: whether the model can autonomously identify problems, verify hypotheses, adjust strategies, and complete fixes. Here you cannot judge only the final answer; you also have to look at the reflection trajectory and the tool-call process.

    Sample scenario:

    1. User: implement a function with caching, then tell me what problems it may have under high concurrency.
    2. Expected model behavior:
    3. 1. Provide an implementation first;
    4. 2. Proactively analyze risks such as thread safety, cache breakdown, and expiration policy;
    5. 3. Propose improvement options;
    6. 4. If allowed to run tests, verify the behavior after the fix.

    To ensure reproducibility, Tier 3 needs a fixed case table and an execution protocol. It is recommended to record at least the following fields: initial prompt, allowed tools, maximum turns, termination condition, defect injection type, recorded fields, and pass criteria.

    Case ID Initial Prompt Allowed Tools Max Turns Termination Condition Defect Injection Type Recorded Fields Pass Criteria
    T3-1 Implement a cached function and analyze high-concurrency problems Code execution sandbox, unit tests, static analysis 6 Tests pass after the fix with no regression Thread safety, cache breakdown, missing error handling Turns, actions, observations, fixes, test results Identify the main risks and provide a verifiable fix
    T3-2 Implement a user registration endpoint, handling duplicate registration Sandbox, unit tests, log inspection 8 Boundary tests pass Missing parameter validation, swallowed exceptions, concurrent duplicate writes Turns, failure reasons, strategy adjustments, verification commands Change strategy after a failing turn instead of repeating the same approach
    T3-3 Refactor a function so it passes the specified tests Sandbox, static analysis, test commands 6 All tests pass Confusing naming, excessive complexity, hidden side effects Turns, static warnings, refactoring actions, final report Provide explainable refactoring rationale and pass automated checks

    The recorded fields for Tier 3 should be unified as follows:

    1. turn: which turn it is
    2. action: generate, run, read, analyze, modify, retest
    3. observation: what the model observed
    4. hypothesis: what problem the model hypothesized
    5. fix: which fixes were applied
    6. verification: which command or test was used to verify
    7. result: success, failure, or partial success

    Pass criteria should not judge only “whether it ultimately passed,” but also whether the model exhibits loop-closing behavior. For example: Does it adjust strategy after a failure? Can it distinguish syntax errors, logic errors, and runtime-environment problems? Does it proactively add tests? Does it perform regression verification after a fix? Can it clearly explain unresolved problems? Tier 3 best reflects the difference between a model and static code generation tools, but it is also more susceptible to tool permissions and environment stability. Therefore, you must fix the version, fix the sandbox, and fix the log format.

    6. Building a Multi-Dimensional Scoring Table: Making Code Aesthetics Quantifiable

    Gradient testing solves “progressive difficulty”; a scoring table solves “from which angles to score.” To make the evaluation reusable, it is recommended to turn the scoring scale into a structured scoring table rather than just listing dimensions.

    Dimension Observation Signal 0 Points 1 Point 2 Points Automated Collection Method Weight
    Correctness Unit test pass rate, logic errors, boundary behavior Most cases fail or results are wrong Partial pass or needs manual correction All pass with stable boundaries Unit tests, regression tests, coverage 30%
    Engineering quality Module organization, interface consistency, dependency management Chaotic structure, cannot run or connect Runs but highly coupled High cohesion, low coupling, complete commands Directory scanning, static analysis, import analysis 20%
    Security Input validation, error handling, permission boundaries Clearly ignores invalid input or dangerous operations Has some but incomplete validation Sufficient validation, clear error handling Static rules, test cases, code review 15%
    Code aesthetics Naming, structure, comments, idioms Confusing naming, hard-to-read structure Basically readable but not well-standardized Self-explanatory naming, follows language idioms Static analysis, style tools, complexity tools 10%
    Reflection ability Self-inspection, defect detection, strategy adjustment No reflection or repeated failures Has reflection but incomplete fixes Forms a generate–self-check–improve loop Trajectory logs, turn records, manual spot checks 25%

    A recommended aggregation method: score each dimension as 0, 1, or 2, and compute the final score as Σ (dimension score ÷ 2 × weight). For example, if a model scores 2 for correctness, 1 for engineering quality, 2 for security, 1 for code aesthetics, and 2 for reflection, the final score is: 2/2×30 + 1/2×20 + 2/2×15 + 1/2×10 + 2/2×25 = 30 + 10 + 15 + 5 + 25 = 85.

    “Code aesthetics” is not mysticism; it is a set of observable signals: whether variable names are self-explanatory, whether a function has a single responsibility, whether error handling is graceful, whether it follows community idioms, and whether it reduces unnecessary complexity. Bringing these signals into a scoring table is more stable than relying on purely subjective judgment.

    7. Implementation Advice and Safe Execution

    In practice, it is recommended to solidify the test cases of the three tiers into a regression test set and incorporate them into a model evaluation pipeline. Automation scripts can handle Tier 1 tests, static analysis, and command execution; Tiers 2 and 3 are better kept with manual spot checks, because engineering structure and reflection trajectories still leave room for interpretation.

    When executing model-generated code, safety boundaries must be emphasized. Model-generated content is not inherently trustworthy, especially when it involves file operations, network requests, command execution, or dependency installation, in which case it should run in isolation. It is recommended to use a container or sandbox environment, restrict the scope of file system access, use a least-privilege account, limit network access, and set upper limits on CPU, memory, disk, and runtime. Never run unaudited generated code directly in a production or high-privilege environment.

    During selection, different business scenarios should focus on different tiers. General Q&A, script generation, and lightweight tool development can focus more on Tier 1; complex business systems, multi-module collaboration, and continuous integration scenarios should focus more on Tier 2; scenarios that need autonomous repair, test feedback, and process orchestration must evaluate Tier 3. Do not let one tier replace all judgments, and do not treat a single evaluation result as the conclusion about a model’s overall capability.

    Conclusion

    Agentic Coding represents an important direction in which AI programming moves from “generation” to “collaboration.” Through the progressive testing of three tiers—function-level, engineering-level, and agentic—combined with a multi-dimensional scoring table and automated collection, developers can more reliably evaluate a model’s performance in code correctness, engineering architecture, and code aesthetics.

    It should be noted that gradient testing is better suited to supporting judgment and relative positioning than to absolute conclusions. Model evaluation is affected by prompts, context length, tool permissions, environment versions, and dataset distribution; a model’s self-evaluation may also carry bias. Therefore, in actual selection, it is recommended to fix the evaluation version and environment, retain manual spot checks, and continuously calibrate against the team’s real business cases. Only when selection is built on reproducible metrics and engineering constraints can it become more rational and sustainable.