How to Evaluate LLM Coding and Defensive Security Capabilities
Evaluate large language models using real engineering tasks rather than leaderboard scores alone. This guide covers internal benchmark design, task-level productivity metrics, defensive security safeguards, API integration checks, and controlled comparisons through a shared integration layer.
Introduction
Large language models have made substantial progress in coding over the past year. Teams evaluating them often ask two questions: How far can a model go on real engineering tasks? And can its security analysis be trusted in automated workflows?
These questions should be considered separately. The first determines whether a model can complete an end-to-end development task. The second determines how much authority it should receive. This article outlines an evaluation process teams can run internally and the engineering details they should verify before integration.
1. Leaderboard Scores Are Not the Same as Productivity
Public benchmarks indicate what a model can achieve under benchmark conditions. Productivity depends on whether a team can consistently benefit from it. Task distribution, context length, tool permissions, and failure recovery all affect the gap between the two. A score on an individual benchmark does not establish whether a model can complete a full change in your codebase.
Model selection should therefore prioritize internal tasks, with public leaderboards serving as an initial filter. Use leaderboards to narrow the shortlist and your own evaluations to decide whether to integrate a model.
2. Measure Coding Ability with End-to-End Tasks
2.1 Single-Turn Generation vs. an Engineering Feedback Loop
Generating a function in a single turn primarily tests syntax and knowledge of common algorithms. Engineering work requires a complete feedback loop: understanding a multi-file repository, identifying the root cause of a problem, planning the scope of changes, using terminal and testing tools, and revising the implementation based on failure output.
A model’s ability to complete this loop determines how much repetitive development work it can take over. Strong first-pass code generation has limited practical value if the model cannot correct its work after tests fail.
2.2 Build an Internal Evaluation Set
Include at least four task categories:
- Historical bug fixes: Collect real, previously resolved bugs, retain reproduction steps and regression tests, and define explicit pass criteria for each task.
- Cross-file refactoring: Select changes spanning multiple modules, then check interface compatibility and whether existing tests still pass.
- Feature completion: Provide requirements and interface contracts, ask the model to complete the implementation, and validate it against predefined test cases.
- Test generation: Check whether generated tests cover edge cases rather than merely asserting that return values are not empty.
The evaluation set does not need to be large, but every task needs an automatically verifiable outcome. Otherwise, evaluation becomes subjective manual scoring.
2.3 Define Task-Level Metrics
Task success alone is not enough. Record the following metrics as well:
- First-attempt success rate: The proportion of tasks that pass on the first attempt.
- Average retry count: The average number of additional attempts required to reach a passing result.
- Time per task: Elapsed time from task assignment to a passing result.
- Human interventions: The number of times a developer must correct or guide the model.
- Total cost per task: Input and output tokens, additional calls caused by retries, and human review time.
The price per million tokens is only one cost input. Total usage required to finish the task matters more. A cheaper model that needs repeated retries may cost more overall.
An illustrative evaluation record:
record = {"task_id": "bug-007","category": "bug_fix","attempts": 3, # Number of calls needed to reach a passing result"passed": True,"first_try_pass": False, # Used to calculate first-attempt success rate"tokens_in": 18342,"tokens_out": 4210,"wall_time_s": 412,"human_interventions": 1,"reviewer_minutes": 6,}
2.4 Avoid Common Interpretation Errors
Success rates can fluctuate considerably with small samples. Results from 10 tasks provide directional evidence, not a precise measure of the difference between two models.
Keep sampling parameters, such as temperature, fixed. Run each task multiple times and compare result distributions rather than individual outcomes. Task wording can also substantially affect performance, so use the same prompt template for the same task set. Otherwise, comparisons are not meaningful.
3. Set Realistic Expectations for Defensive Security
3.1 Where Models Can Help
The positive value of security capabilities lies primarily in defensive work: code auditing, vulnerability identification, dependency risk explanation, remediation recommendations, and security test generation.
These tasks rely on understanding code semantics, an area where LLMs can provide practical assistance. They are particularly useful as a source of leads for human reviewers.
3.2 False Positives, Missed Issues, and Broken Business Logic
A model may flag legitimate code as vulnerable or miss subtle logic flaws. Seemingly reasonable fixes deserve particular scrutiny. A patch might close an input-validation gap while changing authorization checks or transaction boundaries, introducing new business logic errors.
Benchmark scores describe performance on specific datasets. They do not establish that an organization can safely allow a model to modify production code automatically.
3.3 Guardrails for Production Workflows
Apply the following safeguards when integrating security-related tasks:
- Human review: Require all security-related changes to be reviewed by someone with appropriate expertise before merging.
- Least privilege: Give the agent only the file and command permissions needed for the task. Do not provide direct access to production credentials.
- Isolated execution: Run tests and scans in containers or separate virtual environments, with restricted outbound network access.
- Complete logs: Record prompts, tool calls, command output, and final changes for later investigation.
- Reversible changes: Submit changes as separate branches or patches so they can be rolled back quickly.
3.4 Authorization Boundaries
Security tasks must be limited to code and systems for which explicit authorization has been obtained. Keep test environments separate from production and remove sensitive information from test data.
Scanning or exploitation testing against external targets is outside the scope of this article and should not be delegated to these automated workflows.
4. Engineering Checks for Model Integration
4.1 Common API Patterns
Most LLM services provide chat-completion-style APIs that represent conversation history as a message list and control output through request parameters. Beyond basic text generation, teams should verify four capabilities: streaming, multi-turn context, system prompts, and tool calling.
The following request is illustrative. Consult the relevant API documentation for exact fields.
{"model": "<model name available in the console>","stream": true,"messages": [{"role": "system","content": "You are a code review assistant. Your conclusions must be verifiable through tests."},{"role": "user","content": "Analyze how the following function behaves with empty input."}],"tools": [{"type": "function","function": {"name": "run_tests","description": "Run specified test cases in an isolated environment","parameters": {"type": "object","properties": {"test_path": {"type": "string"}},"required": ["test_path"]}}}]}
4.2 Streaming Output
Streaming responses split output into chunks. Clients must assemble them correctly, handle interrupted connections, and validate completeness after receiving the completion signal.
Tool-call arguments may also arrive incrementally. Accumulate the complete arguments before deserializing them; attempting to parse each fragment independently can cause argument errors.
4.3 Multi-Turn Context and System Prompts
Multi-turn conversations require the client to retain message history. When that history exceeds the model’s context limit, truncate or summarize it without losing critical constraints.
Keep the system prompt at the start of the conversation to define the role, output format, and safety constraints. Changes to the system prompt affect model behavior, so version it alongside the code.
4.4 Tool-Call Validation
Validation is central to tool calling. Model-generated arguments must pass schema validation before reaching the executor.
The executor should run only allowlisted commands, reject operations beyond its permissions, and cap output length to prevent excessive output from filling the context window.
4.5 Error Handling
Distinguish retryable errors from non-retryable ones. Rate limits and temporary service failures can be retried with exponential backoff. Invalid parameters and permission errors should be returned and logged without automatic retries.
Retain the request identifier for every call to support troubleshooting.
5. Compare Models Through a Shared Integration Layer
5.1 Reduce Migration Effort
If a team already has a wrapper compatible with a common API format, adding a model may require only changing the base URL, API key, and model name.
Compatibility does not mean identical behavior. Tool-call fields, streaming chunk formats, and error codes still need separate validation.
5.2 Design Controlled Comparisons
A shared integration layer makes it easier to run the same task set across different models. Keep prompt templates, available tools, timeout settings, and evaluation criteria identical. Change only the model being tested.
