Evaluating Open-Source LLMs for Agentic Workflows and Code Generation: A Practical Guide
This article provides a framework for evaluating open-source large language models (LLMs) specifically for AI agent tasks and code generation. Instead of relying on public benchmarks, it emphasizes building a custom evaluation set based on your own business tasks. It breaks down agent capabilities into four testable areas—task decomposition, tool calling reliability, long-context memory, and error recovery—and code generation into three difficulty tiers. It includes a detailed evaluation checklist with measurable metrics, configuration examples, and a practical workflow for constrained code modification. The guide also covers licensing and compliance considerations for open-source model adoption in production environments.
Turning “Capabilities” into Measurable Metrics
Open-source LLMs come with many marketing claims about their performance in agentic workflows and code generation. For developers, the only question that matters is: can the model reliably complete tasks in your specific business context? Public leaderboards are useful for initial screening, but they cannot replace tests based on your own team’s workloads. This article does not endorse any specific model; instead, it provides a reusable evaluation framework.
Before choosing a model, break down the two capability areas into testable questions. Agentic capability focuses on whether the model can decompose tasks, call tools correctly, and maintain state across multiple turns. Code generation capability focuses on whether the model understands project structure, produces runnable modifications, and self-corrects based on test feedback.
Agent Capabilities: Four Dimensions Worth Verifying
1. Task Decomposition and Multi-Step Execution
Complex tasks usually require planning before execution. Taking “analyze a batch of logs and generate a fault report” as an example, a reasonable execution chain would be: understand the goal and list steps, call a read tool to fetch logs, analyze in chunks and extract anomalies, and finally generate a structured report. Each step’s output serves as the next step’s input. When testing, record whether the model skips steps and whether it adjusts its plan when intermediate results are abnormal.
2. Tool Call Format and Reliability
Tool call failures are among the most common issues in agent applications. Typical causes include malformed parameters, missing required fields, and calling tools when they should not be called. Here is an example tool definition:
{"name": "query_database","description": "Query business data based on conditions","parameters": {"type": "object","properties": {"table": { "type": "string" },"filters": { "type": "object" },"limit": { "type": "integer" }},"required": ["table"]}}
The definition itself is straightforward; the difficulty lies in the calling pipeline. A robust flow should include: JSON Schema validation of the model output; on validation failure, send the error message back to the model and allow a limited number of retries; set a timeout for each call; and log all calls and return values. The exact function calling format varies by inference framework and model version, so you must test it in your actual framework rather than relying solely on examples.
3. Long Context and State Memory
Agent tasks may span dozens of interaction turns, with intermediate artifacts accumulating. Context window length is only the first step; more important is whether the model can locate key information from a large amount of history—for instance, an error code or a configuration item from several turns earlier. To test this, embed a critical fact early in a long conversation and ask about it several turns later, observing whether the model reliably recalls it.
4. Error Recovery
When an agent encounters a tool error, a network timeout, or an empty response, it should decide whether to retry, change parameters, or stop and report the issue. This matters more than the quality of a single answer when determining system usability. We recommend constructing a dedicated set of failure scenarios for testing.
Code Generation Capabilities: From Snippet Completion to Multi-File Changes
Code model capabilities can be divided into three difficulty tiers, each with different requirements for context, dependency resolution, and test feedback.
| Task Type | Typical Work | Context Needs | Dependency Resolution | Test Feedback | Main Risks |
|---|---|---|---|---|---|
| Snippet Completion | Completing function bodies, generating boilerplate code | Primarily the current file | Minimal | Usually none | Inconsistency with project style |
| Single-File Modification | Fixing a function, adding parameter validation | Single file and its imports | Local | Optional | Missing impact on callers |
| Multi-File Modification or Refactoring | Changing interfaces across modules, bulk migrations | Entire repository structure | Requires cross-file tracking | Required | Uncontrolled change scope |
The further down the table, the more the model needs to understand the global project and the more it needs tests to gate the output. Evaluations should report pass rates for each tier separately, avoiding using snippet completion results to infer multi-file modification capability.
When working with programming assistant tools, common capabilities include: describing requirements in natural language and having the model plan multi-file edits; running tests, locating failures, and iteratively fixing them; and providing risk warnings for changes. Whether the model adheres to the tool’s interaction protocol, generates directly applicable patches, and corrects its own errors in response to feedback determines the actual user experience.
The following pseudo-code illustrates a constrained workflow:
User instruction: Add parameter validation to the user service module and add unit testsConstraints:- Only modify in an isolated work branch; direct writes to the main branch are forbidden- Test command is fixed to pytest tests/user_service- Maximum retry attempts for one task is 3- Every file modification, test execution, and command invocation is written to an audit logExecution flow:1. Scan the project structure and locate user_service related files2. Read the existing code and identify entry functions that lack validation3. Generate a patch that inserts parameter validation logic4. Write corresponding test cases5. Run tests; if failures occur, read the error, fix, and rerun; if the retry limit is exceeded, stop and report6. After all tests pass, output a change summary and patch, and wait for human review and mergeRollback method: Discard the work branch; do not force revert the main branch
The point of this workflow is not how smart the model is, but whether permissions, tests, and rollback are defined in advance.
Selection Evaluation Checklist
We recommend building an evaluation set from real business tasks, with samples taken from historical tickets, actual requirements, and known defects. The evaluation set should be large enough; with too few samples, the success or failure of a single task could change the conclusion. The table below lists suggested fields to record.
| Metric | Meaning | Measurement Method | Suggested Recording |
|---|---|---|---|
| Tool Call Success Rate | Proportion of successfully completed calls | Count against evaluation set | Break down by tool category |
| Parameter Validity Rate | Proportion of first outputs passing Schema validation | Automated validation | Record distribution of failure reasons |
| Code Runability Rate | Proportion of generated code that compiles or starts | Execute in a runtime environment | Break down by programming language |
| Test Pass Rate | Proportion of existing and new tests passed after modification | Use a fixed test command | Record average number of retries |
| P95 Latency | Response time upper bound for 95% of requests | Load test or online sampling | Note input length and concurrency |
| GPU Memory Usage | Memory requirement during inference | Measure in actual deployment environment | Note quantization method and batch size |
| License Restrictions | Conditions for commercial use, distribution, and fine-tuning | Read original license text | Confirm with legal or compliance team |
Every metric should include the conditions under which it was measured. The same model can produce very different results across input lengths, quantization methods, and concurrency levels. Numbers without measurement conditions should not be used directly for decision-making.
Licensing and Compliance
Open source does not mean free to use without restrictions. Before selection, confirm the following: whether the license permits commercial use; whether there are limits on user scale, redistribution, or release of derivative models; and whether the data used for fine-tuning complies with your company’s data compliance requirements.
