Evaluating and Deploying Code Agents with Mid-Sized Dense Models
This article explains how to evaluate and deploy code agents built on mid-sized dense models. It distinguishes code completion from task completion, examines memory and throughput trade-offs between dense and mixture-of-experts architectures, and outlines how to preserve verifiable state across multi-turn engineering work. It also describes a two-layer offline evaluation design and practical execution boundaries for moving from trials to production.
1. Clarify What to Evaluate: Code Completion or Task Completion?
Code completion and code agents solve different problems. The former mainly generates a piece of code from local context, and the developer is responsible for judging, integrating, and verifying it. The latter must understand requirements, locate relevant modules, propose and apply changes, run checks, and revise the solution based on feedback. A model that can write a correct function may not be able to determine which module should be changed, or distinguish a code regression, an environment failure, and an ambiguous requirement when a test fails.
Consider a task to fix duplicate writes during import. Generating a deduplication function is not difficult. The real engineering difficulty is determining at which layer duplication occurs: does the input itself contain duplicate records, or does a task retry cause the same batch of data to be executed twice? Deduplicating only within a single request leaves the cross-retry problem unresolved; directly changing the write logic may break existing update semantics. When evaluating an agent, check whether it found the correct boundary, preserved existing behavior, and covered the failure path with tests, rather than only checking whether the generated code looks plausible.
This also explains why models with similar general knowledge performance can diverge on repository-level tasks. File location, tool calls, error interpretation, and cross-turn goal retention are all necessary parts of a task. Improving these parts may be more valuable than simply raising knowledge question-answering scores. Conversely, good code task results do not imply that a model is stronger in every scenario.
2. Dense Architectures Are Easier to Plan and Deploy, but Not Necessarily Cheaper to Infer
For a dense model, it can be approximated as follows: when generating each token, the main weights in each layer participate in computation. A mixture-of-experts model routes to a small number of experts in some layers. Therefore, when comparing the two types of models, distinguish total parameter count from active parameter count per token. Total parameter count affects weight capacity and distribution, while active parameter count affects per-step computation. Neither alone can predict real throughput.
Dense models usually do not need to handle expert placement and routing-induced load imbalance, and their parallel layout is relatively straightforward. However, if the model must be split across GPUs, it may still be limited by inter-device communication; when the weights fit, a mixture-of-experts model may also gain a throughput advantage from lower active computation. Architecture determines where resource overhead is distributed, not which model is necessarily faster.
Before deployment, break the GPU memory budget into three parts:
- Weights: Estimate by multiplying parameter count by storage bytes per parameter. Quantization can compress weights, but group metadata, scaling factors, and unquantized portions also consume space. The theoretical value cannot be treated directly as the deployment footprint.
- Context cache: After multiple rounds of file reads, tool feedback, and test output, the input becomes longer. The cache usually grows with effective context and the number of active requests. Therefore, being able to run a single request does not mean there is still enough headroom under concurrent requests.
- Runtime overhead: Temporary compute buffers, parallel communication buffers, and memory fragmentation all reduce available space. Use peak usage under real workloads, not idle usage immediately after service startup.
Quantization selection should also not focus only on how much GPU memory is reduced. A more practical approach is to compare different precisions using the same set of repository tasks. In addition to final pass rate, observe tool-call format errors, repeated edits, and missed long-context constraints. Some configurations may increase tokens generated per second while lengthening delivery time because they require more correction rounds. The goal of deployment is not to make the model barely fit into GPU memory, but to enable it to complete tasks reliably under peak load.
3. For Multi-Turn Engineering Tasks, Preserve Verifiable State
Repository-level task failures often occur not because the agent lacks a particular language knowledge point, but because it loses confirmed constraints across multiple turns. For example, a requirement explicitly asks to preserve interface compatibility, but after several rounds of log analysis, the agent misjudges an old parameter as redundant and removes it. Pasting the entire history back into the context does not always solve the problem: large logs consume budget, early assumptions become mixed with later conclusions, and judgments that have already been rejected may again influence edits.
A more reliable approach is for the application layer to maintain an inspectable task state: what the acceptance criteria are, where confirmed evidence comes from, which files have been changed, which checks have been run and with what results, and what uncertainties remain. For test results, record actual execution and retain necessary failure snippets, rather than marking the model’s claim that something “should pass” as a pass. When resuming a task, restore these verifiable facts first instead of relying on retention of the model’s internal reasoning process.
Context retrieval can follow a “locate, then expand” order: first use directories and symbols to find relevant modules, then read key implementations, callers, and tests. When facing large build output, prioritize the failed command, the first relevant error, and necessary context, while storing the full log separately for later lookup. This controls input cost while preserving traceability.
If the workflow also receives UI screenshots, diagrams, or screen recordings, multimodal input can help understand where a problem appears and the interaction sequence, but it cannot replace executable verification. A screenshot can show that a button is displayed abnormally, but it may not show whether the cause is a style regression, missing data, or improper loading-state handling. Combine visual cues with stable reproduction steps, code evidence, and regression checks, rather than judging fix success from an image alone.
4. Offline Evaluation: Separate Model Capability from System Performance
Public benchmarks are suitable for judging which candidate models are worth trying on which types of tasks, but they cannot directly represent performance in a team’s repository. Internal samples should cover common tasks such as defect repair, test addition, small-scope refactoring, and interface changes, and should include varying levels of difficulty. Historical tasks can reduce the cost of authoring test cases, but use the repository snapshot before the fix to avoid leaking the final patch, later discussion, or existing answers to the agent. Each task should have predefined verifiable acceptance criteria and should allow solutions that differ from the historical patch but are behaviorally correct.
Controlled experiments are best divided into two layers. The first layer fixes the repository state, dependency environment, tool permissions, context strategy, and task budget, and changes only the model, in order to identify differences caused by the model. The second layer allows each candidate solution to use inference configurations and task orchestration suitable for itself, and compares the final deliverable effect. The former answers “what does changing the model itself bring,” while the latter answers “which setup is more suitable for production.” If the two layers are mixed, improvements in retrieval strategy or retry mechanisms may be mistakenly counted as model capability improvements.
Evaluation should answer at least four questions:
- Is the task actually completed? Correcting the target behavior is only the starting point. Also check whether existing behavior regressed, whether unrelated changes were introduced, and whether the change meets the acceptance criteria. New tests should also be independently reviewed to prevent issues from being hidden by weakened assertions.
- Is the result stable? Run key tasks independently multiple times, and record the first-round success rate and the final success rate within budget separately. When failures occur, distinguish localization errors, implementation errors, environment failures, and budget exhaustion. If many failures stem from dependencies not being ready, fix the execution environment first rather than using those failures to eliminate the model.
- Where is the actual time spent? In addition to measuring end-to-end latency and high-percentile latency, break down queueing, model inference, tool execution, test waiting, and human review. If most time is consumed by the full test suite, increasing generation speed may have little impact on the delivery cycle.
- How much does completing one task actually cost? Divide the hardware, execution environment, and human review rework cost of all attempts by the number of tasks that meet acceptance requirements. Failures and retries cannot be excluded from the numerator; otherwise, a low-cost but unstable solution may be overestimated.
When summarizing, report by task type separately rather than giving only one total score. A solution may be good at single-module repair but prone to missing callers in cross-module refactoring. If the team’s main work happens to be cross-module changes, a leading total score is not enough to support adoption.
5. From Trial to Production: Build Execution Boundaries into the Workflow
Initially, let the agent read necessary files, generate patches, and run approved checks in an isolated workspace. Repository content, issue descriptions, and tool output are data to be processed, and the agent should not expand its own permissions. Production credentials should not enter the execution environment; external network access and write scope should be opened as needed for the task. Actions with greater impact, such as merging code or modifying release configuration, should retain independent approval, and actual tool calls, change diffs, and verification results should be recorded.
At the same time, set clear stop conditions. If the same type of failure occurs over consecutive turns, key assumptions cannot be verified, or the task requires changes beyond the approved scope, the agent should submit the current diff, executed checks, and unresolved issues to the developer. This handoff point is more useful than endless retries: it preserves the investigation already completed and avoids expanding the fix scope just to make one check green.
Availability of weights also does not mean deployment has no additional conditions or costs. Before introducing any open-weight option, check the license terms for commercial use, modification, and redistribution, and include hardware, version maintenance, and runtime monitoring in the cost. The benefits of private deployment should also be measured specifically, for example, whether internal code must remain in a controlled environment, whether request volume is sufficient to justify always-on resources, and whether the team has the capability to maintain an inference service.
Ultimately, only when a mid-sized dense model can stably submit verifiable, reviewable patches on target tasks while keeping latency, resource usage, and human rework within acceptable ranges does deployment convenience become truly meaningful. If the advantage appears only on public leaderboards or in a one-off demo, keep it in the trial stage; if the advantage can be repeated on the local task set and in a controlled pilot, then gradually expand its use.
