How to Evaluate Large Language Models for Coding and Security Capabilities
As general-purpose large language models become increasingly embedded in software engineering, evaluation must go beyond whether a model can generate runnable code. This article presents a practical framework for assessing repository-level coding, long-horizon agent behavior, and security-related capabilities. It explains how to separate model scale, architecture, and post-training effects; how to audit tool use and recovery; and how to evaluate defensive security performance without encouraging unauthorized attack behavior.
As general-purpose large language models become more deeply integrated into software engineering, the industry is moving beyond a basic question: can a model produce a runnable code fragment? More difficult questions now include whether it can modify multiple files across a long context, plan and verify work under constraints, and behave appropriately on security-related tasks.
This article does not examine any particular vendor or model. Instead, it abstracts these issues into reusable technical questions: how should coding ability be defined, how should long-horizon agents be evaluated, and how should so-called emergent cybersecurity capabilities be understood and constrained?
1. Break Coding Ability into Verifiable Levels
Treating coding ability as a single score can hide important weaknesses. A layered evaluation approach is more reliable.
The first level is local generation: function completion, API calls, and unit-test drafts. This level primarily measures syntax correctness, type consistency, and familiarity with common library conventions. Useful metrics include compilation success rate, the number of static-analysis warnings, and unit-test coverage. These metrics are relatively easy to automate.
The second level is repository-level modification: locating defects in an existing codebase, changing interfaces across files, and completing compatibility layers. This tests retrieval, dependency-graph understanding, and the ability to make minimal changes. Evaluation should emphasize whether the change is correct and limited, rather than whether the model generates as many new files as possible.
The third level is the engineering loop: translating requirements into an implementation, running self-tests, and iterating based on failure logs. This is close to long-horizon agent behavior because it requires planning, tool use, state management, and failure recovery. A model that performs well only at the first level may not generalize to real development workflows.
For developers and enterprise users, the most serious challenges are often found in the second and third levels: truncated context, unclear tool permissions, and expensive regression testing. These constraints must be included in the evaluation tasks instead of testing one-shot generation in an idealized sandbox.
2. Do Not Conflate Scale, Architecture, and Post-Training
A common assumption is that smaller models are still catching up and that scaling laws may no longer apply. A more precise explanation is that, with fixed data quality and a fixed evaluation protocol, parameter count and compute investment remain correlated with average capability. However, post-training—including instruction alignment, reinforcement learning, and tool-use trajectories—can substantially change a model’s behavior distribution. As a result, models of the same size can perform very differently on the same tasks.
Therefore, claims that “scaling laws no longer exist” are often the result of changed evaluation criteria, different data mixtures, or task saturation, rather than evidence that the underlying relationship has been disproved.
At the architectural level, common approaches include dense models, mixture-of-experts designs, long-context optimization, and positional-encoding improvements for reasoning. Whether to adopt a new model architecture depends on training stability, inference cost, and the surrounding tool ecosystem—not on branding. Many releases continue to use mature architectural foundations with controlled modifications while directing more resources toward post-training. The reason is practical: engineering risk is lower, and improvements in coding and agent tasks can appear quickly.
Post-training is particularly effective for coding because code tasks provide relatively clear feedback signals. Compilers, tests, and static-analysis tools can all provide learnable rewards. This also creates a potential bias: a model may learn to overfit the style of benchmark repositories rather than develop general engineering judgment.
Evaluation teams should therefore maintain hidden test sets, include multiple programming languages and frameworks, and regularly rotate tasks. These measures reduce the risk of optimizing directly for benchmark scores.
3. Long-Horizon Agents: Scores Reflect State Machines and Tool Protocols
Long-horizon agent evaluations usually involve goal decomposition, multi-step tool calls, intermediate artifact management, timeouts, and retries. A reported “long-horizon agent score” only indicates relative performance under a particular protocol. It should not be treated as direct evidence of production readiness.
Evaluations should also report:
- The distribution of average step counts and failed steps, including whether failures occur during retrieval, permission handling, or verification;
- Tool misuse rates, such as incorrect commands, unauthorized paths, and destructive operations;
- Recoverability, or whether the agent can change its strategy based on error messages;
- Cost, including tokens, latency, and the number of external calls.
From an engineering perspective, an agent should be designed as an explicit state machine. Planning, execution, observation, and verification should be separated. The verification stage should rely as much as possible on deterministic tools—such as compilation, testing, and policy scanning—instead of allowing the model to simply claim that the task is complete.
On the cloud side, container platforms can isolate execution environments, object storage can preserve intermediate artifacts, and logging and monitoring services can track long-running tasks. This helps prevent a single uncontrolled execution from contaminating shared resources. These are general infrastructure capabilities and do not depend on any proprietary product.
4. Understanding “Emergent” Cybersecurity Capabilities
As models become better at programming and tool use, they may also appear stronger on security-related benchmarks. Examples include vulnerability-pattern recognition, patch generation, attack-surface description, and configuration-error detection.
This does not necessarily mean that the model has been equipped with a separate “hacker module.” These capabilities may emerge as by-products of code understanding, causal reasoning, and tool orchestration. For this reason, capability, intent, and authorization must be treated as separate dimensions.
Permitted capabilities include:
- Detecting defects within an authorized scope;
- Suggesting patches;
- Identifying dependency risks;
- Checking compliance with secure-coding practices.
Capabilities that must be refused include:
- Providing unauthorized intrusion procedures;
- Explaining exploit details that enable misuse;
- Stealing credentials;
- Conducting covert monitoring;
- Generating destructive scripts or other actionable attack paths.
If evaluation focuses only on achieving high cybersecurity benchmark scores, it may incentivize models to produce reproducible attack details. That conflicts with enterprise security objectives. A more appropriate evaluation asks whether the model can provide remediation guidance, regression tests, and hardening checklists for a given vulnerability description while refusing unauthorized exploitation.
Tasks should define the authorization boundary explicitly. For example, evaluation can be limited to public, sanitized sample code and prohibit targeting real systems without authorization.
The term “emergence” should also be used carefully. When a capability curve becomes sharply steeper on a particular task, it is often described as emergent. A more likely explanation may be a threshold effect in the evaluation—for example, awarding points only when an entire exploit chain succeeds—or the sudden appearance of similar trajectories in the training data.
A scientifically sound evaluation should report continuous metrics, including partial credit and step-level accuracy, rather than relying only on binary pass-or-fail results that create an exaggerated narrative.
5. Evaluation Protocols: Avoid Being Misled by a Single Ranking
A useful evaluation protocol should include at least the following elements:
- Task stratification: completion, repository repair, multi-step agents, and defensive security remediation.
- Environment reproducibility: fixed dependency versions, fixed test commands, and no internet access unless explicitly restricted by an allowlist.
- Process auditing: record tool calls and file diffs, with manual sampling to verify that the agent did not modify tests instead of the implementation.
- Security boundaries: if a request is transformed into unauthorized attack instructions, mark the sample as a failure and trigger the refusal policy.
- Statistical reporting: report percentiles and failure-type distributions in addition to averages, so a few extreme results do not distort the overall picture.
The following pseudocode illustrates an evaluation loop. It is not an interface for any real product:
for task in benchmark:env.reset(task.repo, task.tests)agent.reset(budget=steps, tools=allowed)while not env.done and agent.alive:action = agent.act(env.observe())if violates_policy(action):record("policy_fail")breakenv.apply(action)score = env.evaluate() # tests + static checks + diff size
In enterprise environments, the same protocol can be connected to continuous integration. Before a merge, the model may propose a patch, but the patch must pass the existing test suite and additional security checks. Cloud infrastructure can run long tasks asynchronously through a message queue, while monitoring and alerting systems can trigger a circuit breaker when timeouts or abnormal system calls occur.
6. Practical Recommendations for Engineering Organizations
Organizations should treat a model as a colleague that can write code, not as a black box whose only meaningful property is a benchmark score.
Recommended practices include:
- Build internal evaluation sets around repository-level tasks that reflect the organization’s actual languages and frameworks, rather than focusing only on public benchmarks.
- Enforce tool allowlists and least-privilege permissions. The model should be able to modify only designated directories and run only approved tests.
- Reward small, correct diffs during post-training or prompt optimization, and penalize unnecessary refactoring.
- Restrict security tasks to defensive use cases and apply policy filtering to model outputs.
- Evaluate cost and quality together. A model that completes a task only after excessive retries and rapidly increasing step counts may still be unsuitable for production.
When public cloud resources are used for training or evaluation, the relevant capabilities are general infrastructure functions such as elastic computing, container isolation, object storage, logging, and monitoring. Baidu AI Cloud and other cloud platforms provide infrastructure categories of this kind. Selection should be based on compliance and isolation requirements rather than benchmark-oriented marketing claims.
7. Conclusion
The core of advanced coding capability is not a number from one or two product announcements. It is the ability to complete verifiable repository-level changes under real constraints while remaining auditable and interruptible during long-running interactions.
Security-related performance should be understood as an extension of code and tool-use capabilities. Evaluation and product design must keep defensive work strictly separate from offensive behavior. Model scale, architecture, and post-training all contribute to performance. Post-training can raise agent scores quickly, but it can also introduce benchmark overfitting and authorization risks.
Layered tasks, process auditing, and clear safety boundaries are necessary to turn capability that merely appears impressive into capability that is controllable in practice. That is the real capability developers and enterprises need to build for the next stage of AI-assisted software engineering.
