Evaluating LLM Engineering Capabilities in Complex Code Repositories
This article explains why models that score near the top of public benchmarks often feel weaker in real projects, and proposes a system-level evaluation framework built around four dimensions: context management, tool-call reliability, error recovery, and cost per unit of effective output. It covers layered context assembly across retrieval, compression, and orchestration; structured output schemas, idempotency, and least-privilege sandboxing for tool calls; convergence-oriented recovery tied to a trustworthy verification loop; strategy routing to control spend; and a repeatable acceptance process with layered metrics, stability testing, and safety boundary checks. Readers will find practical code snippets and a checklist for shifting evaluation focus from benchmark scores to system reliability.
1. The Gap Between Benchmark Scores and Real-World Experience
A familiar pattern shows up in discussions of AI coding tools: a model may approach the level of top-tier closed-source models on public benchmarks, which is a genuinely positive signal that its underlying reasoning and code generation have reached a high level. Yet when the same model is dropped into a real project, developers often feel it is “not that strong.” This gap is not an illusion; it reflects the difference between the evaluation paradigm and engineering reality.
Public benchmarks typically share three traits: clearly bounded tasks, a controllable context size, and a pass/fail verdict from a single interaction. Real repositories are the opposite: tangled dependencies, build scripts mixed with generated code, legacy conventions that appear in no documentation, and a single change that ripples across multiple modules. A near-top benchmark score therefore only shows that the model’s ceiling under controlled conditions is high; it does not imply equivalent overall performance in an open engineering environment.
A more accurate framing treats the model as a decision-making component inside a system rather than an isolated test taker. Overall system performance is determined by four things: whether information supply is sufficient (context management), whether action execution is reliable (tool-call stability), whether the system converges after failure (error recovery), and the cost per unit of effective output (execution cost).
2. Context Management: From Stuffing It In to Selecting Precisely
The first hurdle in a complex repository is information access. Repository size often exceeds what fits in a single context window, and even when the window is large enough, indiscriminately stuffing in every file has two side effects: noise dilutes the critical signal as the model’s attention is scattered by irrelevant code, and cost and latency rise linearly.
A more effective engineering approach splits context management into three layers: retrieval, compression, and orchestration.
- Retrieval layer: combine symbol indexing with semantic search to locate candidate snippets, returning the modification target and its direct callers and callees first, rather than truncating by directory order.
- Compression layer: for long files, keep signatures, type definitions, and key branches, and summarize irrelevant implementations instead of injecting full text.
- Orchestration layer: clearly separate “global constraints,” “current task,” and “reference examples” so the model knows which part is a hard rule and which is merely a reference.
A simplified context assembly sketch:
def build_context(repo, target_symbol, budget=120_000):# 1) Locate the target and its dependency boundaryseeds = repo.index.lookup(target_symbol)neighbors = repo.graph.one_hop(seeds, direction="both")# 2) Trim in layers to stay within budgetparts = []parts.append(("constraint", repo.conventions.summary()))parts.append(("task", current_issue.description()))for item in rank_by_relevance(neighbors, seeds):snippet = repo.summarize(item, keep=["signature", "types", "branches"])if estimate_tokens(parts) + estimate_tokens(snippet) > budget:breakparts.append(("reference", snippet))return assemble(parts)
To evaluate this layer, do not look only at whether the answer is correct; look at the variance in success rate for the same task under different retrieval strategies. High variance means the model is highly sensitive to context quality, and the engineering side must invest more in governance.
3. Tool-Call Stability: Structured Output and Idempotent Design
In real projects the model rarely “only writes code.” It needs to read files, look up symbols, run builds, and execute tests. Tool calls therefore become the key reliability variable. Common problems include malformed argument structures, calls issued in the wrong order, execution attempted without prerequisites in place, and repeated identical read-only operations.
Three general techniques improve stability. First, constrain output structure: define parameter shapes with explicit schemas and validate strictly at the entry point, returning a parseable error on validation failure so the model can self-correct. Second, declare idempotency and preconditions: annotate each tool with whether it can be safely repeated and which prior states it requires, for example “a usable build artifact must exist before tests run.” Third, apply least privilege and sandboxing: restrict write operations to controlled directories and enable network access only when needed.
{"tool": "run_tests","args": { "scope": "changed_modules", "timeout_sec": 300 },"preconditions": ["build_artifacts_ready"],"idempotent": true,"on_failure": "return_structured_error"}
The recommended metric is task-level success rate rather than call-level success rate. A single task often involves a dozen or more calls, so 95% reliability per call can leave less than 60% once chained together. This compounding decay is exactly what benchmarks struggle to expose.
4. Error Recovery: Converging Matters More Than Getting It Right the First Time
In a complex repository, the probability of getting things right on the first attempt is naturally low. What really differentiates experience is the behavior pattern after failure: does the model repeat the same ineffective edit, or does it adjust its assumptions based on compiler errors and test failures?
Mechanisms that work in practice include: returning failure signals in structured form with file locations, error categories, and a minimal reproduction input; maintaining a history of attempts and actively down-weighting or switching strategies for paths that fail repeatedly; setting a retry limit and an escalation path so that automatic modification stops past a threshold and a diagnostic report is handed to a human; and forcing small, incremental commits for high-risk changes, running a minimal verification set at each step so errors do not accumulate beyond the point of diagnosis.
It is worth stressing that recovery capability must be bound to a verification loop. Without trustworthy build and test feedback, any “self-correction” is merely a stack of guesses.
5. Execution Cost: Account Per Unit of Effective Output
The easiest way to get cost evaluation wrong is to look only at unit price. A more reasonable measure is cost per unit of effective output: the total resources consumed to complete one change that passes acceptance, covering input and output token volume, tool-call rounds, the extra overhead from retries, and human intervention time.
Typical optimization paths are: compress ineffective context, cache stable retrieval results, schedule read-only and write operations separately, and relax model size for low-risk tasks while reserving stronger reasoning for high-risk ones. An illustrative routing policy:
def route(task):if task.risk == "low" and task.est_tokens < 8_000:return small_model_policy()if task.touches_public_api or task.touches_migrations:return strong_model_policy(with_mandatory_review=True)return default_policy()
6. A Recommended Evaluation Plan
Integrating the dimensions above into a repeatable acceptance process avoids subjective judgments of the “it feels stronger now” kind:
- Build an internal task set: extract changes from real commit history and keep the original failure traces as a baseline for comparison.
- Layered metrics: task success rate, average call rounds, recovery convergence rate, cost per unit of effective output, and human rework rate.
- Stability testing: run the same task repeatedly and observe result variance rather than a single run.
- Cost regression: recompute cost per unit of effective output after each policy change to prevent capability gains from coming with uncontrolled expense.
- Safety boundary checks: confirm the scope of write operations, that sensitive information is not leaked, and that high-risk changes always pass human review.
7. Conclusion
A model approaching top closed-source levels in controlled tests is positive progress on the capability supply side; but achieving a stable experience in complex code repositories still requires engineering work on context governance, tool contracts, recovery loops, and cost accounting. Shifting the evaluation focus from “scores” to “system reliability” is the reusable judgment framework. Organizations that want to deploy this kind of capability on Baidu AI Cloud can build an observable, rollback-capable evaluation and runtime environment on general cloud product categories such as container platforms, object storage, logging services, and monitoring and alerting, turning capability evaluation from a one-off activity into a continuous, controllable engineering practice.
