Evaluating LLMs for Coding: Intent Understanding and Code Generation from Selection to Implementation
This article explains why switching tools alone cannot solve developer productivity bottlenecks and proposes a four-layer capability model for evaluating AI coding tools: context understanding, generation and reasoning, tool orchestration, and collaboration. It covers context engineering techniques such as repository-level indexing, explicit context budgeting, and task atomization with upfront acceptance criteria; three human-AI collaboration modes; a quantitative metrics framework; a shift from compute cost to total cost of ownership; and a five-step approach to embedding tools into existing workflows. It also lists common risks and mitigation strategies, along with practical suggestions for building a closed loop in the Baidu AI Cloud ecosystem.
1. Introduction: Why Switching Tools Does Not Fix the Efficiency Bottleneck
Many teams follow a similar curve after adopting AI coding tools: initial excitement, growing dependence, and eventually a plateau. The reason is straightforward. Once tasks evolve from “completing a few lines of code” to “cross-file refactoring,” “long-chain root cause analysis,” and “multi-round requirement iteration,” a tool’s value is no longer determined by single-point generation quality. It is determined by three capabilities working together: context organization, task decomposition, and result verification.
Tool selection should therefore move beyond “whose output looks more human” and return to engineering questions: Can it reliably understand the project structure? Can it surface the key information within a limited context window? Can it break a requirement into verifiable atomic tasks? This article addresses these questions.
2. A Layered Model of AI Coding Tool Capabilities
To avoid being distracted by marketing claims, evaluate capabilities across four layers:
| Capability Layer | Focus | Typical Failure Mode |
|---|---|---|
| Context Understanding | Repository-level retrieval, dependency relationships, cross-file references | Reads a single file only; fixing one spot breaks three others |
| Generation and Reasoning | Multi-step reasoning, solution comparison, boundary condition handling | Produces code that “looks right” but does not run |
| Tool Orchestration | Command execution, log reading, failure retries | Cannot close the verification loop; requires repeated human fallback |
| Collaboration and Interaction | Multi-turn context retention, ambiguity clarification, change auditing | Drifts further with each edit; hard to roll back |
These layers are connected in series, so the weakest layer sets the ceiling. The most common misjudgment in practice is evaluating a complex task that depends on the context and orchestration layers using only the performance of the generation layer.
3. Context Engineering: The Decisive Factor Beyond the Model
Most failures on complex tasks are not because “the model cannot write code,” but because “the model did not see what it needed to see.” Context engineering is therefore the core issue, and it can be approached from three angles.
1. Repository-Level Indexing and Retrieval Strategy
- Prioritize the visibility of “entry files + routing/assembly layer + shared type definitions.”
- Use symbol-level slicing for very long files instead of simple line-based truncation.
- Set retrieval priorities: modules referenced more frequently receive higher weight.
2. Explicit Management of the Context Budget
Treat context as a finite resource and establish the concept of a “quota”:
System constraints and conventions ~10%Current task and acceptance criteria ~15%Key code snippets ~45%Historical decisions and change records ~20%Reserved reasoning and output space ~10%
Quotas are not rigid rules, but explicit allocation significantly reduces the chance that critical information gets buried.
3. Task Atomization and Upfront Acceptance Criteria
Rewrite a vague requirement such as “implement the payment module” into verifiable atomic tasks:
Task: Add an idempotent order status query APIConstraints: Reuse the existing authentication middleware; do not change the existing response structureAcceptance:1. Repeated calls with the same request produce no side effects2. Unit tests cover three paths: normal, timeout, and invalid parameters3. Changes are limited to no more than two files
Defining acceptance criteria upfront turns “after-the-fact review” into “in-process constraints,” which noticeably reduces rework.
4. Three Paradigms of Human-AI Collaboration
Choose a collaboration mode based on the level of task uncertainty:
- Copilot Mode (low uncertainty): Suitable for boilerplate code, unit test skeletons, comments, and documentation. The human leads; the tool accelerates.
- Pair Mode (medium uncertainty): Suitable for module refactoring and defect root cause analysis. The tool proposes options; the human makes trade-offs.
- Delegation Mode (high uncertainty, use with caution): Suitable for tasks with clear scope and automatic verification (such as batch migration, formatting, and dependency upgrades). Automated validation and rollback mechanisms are mandatory.
A common mistake is applying delegation mode to exploratory tasks. Exploratory tasks lack clear acceptance criteria, and once the direction is wrong, the correction cost far exceeds implementing the task manually.
5. Measuring Effectiveness: Building a Quantitative Metrics System
Without measurement, tool selection degrades into a contest of impressions. Track at least the following metrics:
| Metric | Meaning | Reference Observation Method |
|---|---|---|
| Acceptance Rate | Proportion of generated content actually retained | Compare generated output with the final commit |
| Rework Rate | Proportion requiring secondary modification after generation | Count the number of change rounds |
| Task Completion Rate | Proportion completed without human fallback | Use “whether human takeover was triggered” as the signal |
| Time per Task | Time from requirement input to passing acceptance | Compare the median before and after adoption |
| Defect Escape Rate | Defect density of generated code after merging to the main branch | Combine code review with defect tracking |
Note that single-day experience and single-generation results are not statistically meaningful. Evaluation should use “week” as the unit and “samples of similar tasks” as the comparison baseline.
6. Cost Perspective: From Compute Cost to Total Cost of Ownership
Many teams account only for API call costs while overlooking hidden costs:
- Review cost: Reviewing generated code often takes longer than reviewing hand-written code.
- Refactoring cost: Low-quality generation accumulates technical debt.
- Switching cost: Frequently changing tools requires rebuilding conventions and a team learning curve.
- Data compliance cost: Sending code externally involves asset security and compliance review.
A more reasonable accounting method is total cost of ownership (TCO):
TCO = API cost + review cost + rework cost + migration and training cost + compliance cost
When generation speed increases but review cost rises at the same time, overall efficiency may drop rather than improve. This is the root cause of the “slower the more you use it” phenomenon.
7. Engineering Implementation: Embedding Tools into Existing Workflows
A tool delivers value by fitting into existing workflows, not by creating a separate one. Implement in the following order:
- Step 1: Conventions first. Define code style, commit granularity, and review checklists so generated content follows consistent constraints.
- Step 2: Close the validation loop. Make static checks, unit tests, and integration tests mandatory gates that every generated artifact must pass.
- Step 3: Observability and auditing. Record the generation source, change scope, and owner to ensure traceability.
- Step 4: Gradual rollout. Start with low-risk modules (tooling scripts, test code) and gradually expand to core business logic.
- Step 5: Regular retrospectives. Drive adjustments with metrics data rather than impressions.
8. Common Risks and Mitigations
| Risk | Symptom | Mitigation |
|---|---|---|
| Over-trust | Generated code merged without review | Mandatory review plus automated validation |
| Context Pollution | Long sessions accumulate irrelevant information | Session slicing and task isolation |
| Hidden Homogeneous Code | Similar style and high duplication across generated code from multiple people | Build an internal reuse library and review rules |
| Hallucinated Interfaces | References to nonexistent fields or methods | Compile-time checks plus contract tests |
| Security and Compliance | Sensitive code sent externally | Private deployment or data masking strategy |
9. Practical Suggestions in the Baidu AI Cloud Ecosystem
If a team has already built its R&D system on the cloud, it can combine AI coding capabilities with general cloud services to form a closed loop:
- Use a container platform to host development environments and sandboxes for environment consistency.
- Use object storage to manage code snapshots and build artifacts.
- Use a message queue to decouple long-running tasks and avoid interaction blocking.
- Use log services and monitoring alerts to collect metrics such as acceptance rate and rework rate, forming a data foundation for continuous optimization.
The value of this combination lies not in single-point capability, but in making the “generate-validate-measure-improve” loop operational.
10. Conclusion: Efficiency Comes from the System, Not a Single Tool
Returning to the original question: which tool is the strongest? A more accurate answer is that within a given task type, team conventions, and validation system, the one with the highest stability is the strongest.
As task complexity increases, the real differentiator is not generation speed but three foundational capabilities: context organization, task decomposition, and result verification. Only when these capabilities are consolidated into team conventions and automated workflows does the cost of switching tools approach zero, and R&D efficiency moves from “relying on intuition” to “sustainable.”
The recommended implementation path can be summarized in one sentence: establish conventions and validation first, then discuss tools and models; quantify and review first, then discuss expansion and speed.
