Open-Source LLM Selection: Hands-On Evaluation for Coding and Agent Tasks
This guide explains how to choose open-source large language models for coding and agent workloads. It covers how to read model specifications, how license terms and token costs affect total cost, how to build a task-specific evaluation sandbox, how to budget context windows, what GPU memory limits mean for self-hosting, and a practical selection workflow.
How to Choose an Open-Source LLM: Start with the Task, Then Check the Parameters
Choosing an open-source large language model, evaluating it for coding and agent use, and avoiding common self-hosting pitfalls are problems many teams will face in 2026. In the past, teams often picked models by their overall leaderboard score. However, an overall score mixes code generation, long-document understanding, and multi-step tool calling into a single average. After averaging, it is hard to tell whether a model is reliable for your specific tasks.
This article refers to two mainstream open-source approaches as the “large-capacity route” (Route A) and the “high-efficiency route” (Route B). The exact parameters, prices, and license terms of both routes change with each release, so this article does not list unverified figures. Readers should check the official technical reports, pricing pages, and license texts from each vendor, and record the date they checked.
1. Read the Spec Sheet, Not Just the Total Parameter Count
Public materials usually list the total parameter count, the active parameter count, the context window, supported modalities, the license, and API pricing. Each field answers a different question.
- The total parameter count determines the size of the weight files.
- The active parameter count determines how many parameters take part in each inference step. It affects compute per request and speed.
- The context window determines how many tokens you can input at once. It does not guarantee that the model uses the full window effectively.
- The license determines whether you can use the model commercially, modify it, and redistribute it, and what obligations apply to derivative works.
- API pricing only reflects the unit cost of calling a cloud service. It has nothing to do with the hardware cost of self-hosting.
Pay close attention to the MoE (Mixture of Experts) architecture. In an MoE model, each token activates only some of the experts, so the active parameter count and compute are low. However, the weights of all experts must still be stored in GPU memory or system memory, and some experts may need to be offloaded to CPU or disk. Therefore, a low active parameter count does not mean low memory usage.
2. Licenses Are a Hidden Cost
License terms often affect cost more than people expect. Take the MIT License as an example. It generally allows commercial use, modification, and redistribution, and it does not require derivative code to be open-sourced. Custom licenses vary widely. Some restrict monthly active users, redistribution methods, or specific use cases.
The content in this section is not legal advice. Legal teams should confirm the license of the model weights, the copyright status of generated code, and the commercial terms for outputs against the specific license texts. During evaluation, teams can start with a checklist and record, for each model, the license name, version, release date, whether commercial use is allowed, whether attribution is required, and whether distribution of derivative models is restricted.
Price also has to be considered in the context of the task. A model with a low unit price can still produce a higher bill than a model with a higher unit price if the task needs more follow-up turns, longer chain-of-thought output, or more tool calls. Compare models using the actual token consumption of your tasks, not unit prices alone.
3. Coding and Agent Tasks: Build Your Own Evaluation Sandbox
Repository-level software engineering benchmarks, such as the SWE-bench family and Terminal-Bench, are closer to real development than single-file code generation problems. They require the model to understand cross-file dependencies, run tests after changing code, and keep fixing based on failure messages. Public benchmarks serve only as a reference, however, and cannot replace your own codebase.
In general, the large-capacity route has an advantage in cross-file understanding, multi-step planning, and mixed multimodal tasks. For example, it can locate a front-end component from a UI screenshot and then update the back-end API to match. The high-efficiency route performs more consistently on tasks with clear boundaries, such as code refactoring, unit test generation, and dependency upgrades. Its per-response latency is usually lower, which makes it better suited to agent loops that make many tool calls.
These judgments must be verified on your own tasks. Record evaluation results using the table below.
| Record item | Description |
|---|---|
| Task ID and type | For example, “cross-module refactor” or “unit test completion” |
| Test pass status | Based on your own test suite |
| Average number of fix rounds | Number of edits from the first output until the tests pass |
| Time per task | Includes model inference and tool execution time |
| Manual interventions | Number of times a person had to rewrite or guide the output |
| Failure type | For example, format error, logic error, tool call failure, or context overflow |
Select 50 to 100 real issues from your own projects, covering both simple and difficult tasks. Both models should use the same prompts, the same tools, and the same timeout settings. Otherwise, the comparison will not be meaningful.
4. Manage the Context Window as a Budget
A million-token window is large, but that does not mean you should load every file into it. Irrelevant content distracts the model and increases cost and latency.
Split the input budget for each request. For example, system instructions might take about 5%, retrieved code snippets about 40%, task-related document summaries about 20%, the current code context about 25%, and the remaining 10% reserved for output. These ratios are only a starting point and should be adjusted to the actual task.
Retrieval augmentation is usually more effective than concatenating full texts. In practice, build an index of the codebase first, generate summaries by module, and then retrieve the files and functions most relevant to the task semantically. For workflows that involve many screenshots, watch the token usage of images. Images usually consume more tokens than text carrying the same amount of information. Lowering the resolution or cropping irrelevant areas can noticeably reduce the bill.
5. Deployment: GPU Memory Is a Hard Limit
The main advantage of self-hosting is that data stays in your own environment, which helps meet data sovereignty and compliance requirements. However, deployment is not cheap, and GPU memory is usually the first bottleneck teams hit.
Estimating the memory needed for weights is simple: multiply the parameter count by the bytes per parameter. BF16 is about 2 bytes per parameter, INT8 about 1 byte, and INT4 about 0.5 bytes. Take a MoE model with 750B total parameters as an example. Its BF16 weights take about 1.5 TB, and its INT4 weights take about 375 GB. This means that even if only 40B parameters are active, a single 80 GB GPU cannot hold the full weights. Besides the weights, the KV cache, activations, and runtime overhead also use extra memory, so the resources actually required are often higher.
Quantization reduces memory usage, but the effect depends on the quantization algorithm, the model architecture, and the task type. Some tasks show almost no degradation at 4-bit, while long chain-of-thought reasoning or code generation tasks may degrade noticeably. After quantizing, compare pass rates on your own evaluation set and observe how performance changes as context length increases. Do not rely only on vendor marketing materials.
When testing a deployment plan, record three metrics: peak GPU memory, throughput (tokens processed per second), and time to first token. Also document the hardware model, concurrency, batch size, and input and output lengths. Numbers without these conditions cannot be compared with other setups.
On the operations side, large models take a long time to load, so cold starts can affect service availability. If your traffic has clear peaks and troughs, run offline batch processing on the large-capacity model and serve online interactive requests on a faster model. Also keep a fallback plan. For example, switch to a backup model when the primary model fails, or use a simplified prompt template.
6. A Practical Selection Workflow
The first step is task profiling. Record the share of plain-text inputs versus mixed image-and-text inputs. Measure the distribution of task complexity, such as simple formatting, cross-module changes, and core algorithm design. Describe whether the interaction is one-off generation or multi-round debugging with tool calls. Note the cost of a single failure.
