Evaluating Multimodal LLMs and Building a Low-Cost Coding Agent
As multimodal large language models (LLMs) rapidly advance, developers are shifting their focus from basic capabilities to stability, cost-effectiveness, and ease of deployment. This article explores how to objectively evaluate coding models across four dimensions: task capability, long context handling, predictable costs, and agent stability. It also outlines a practical architecture for building a low-cost, reliable coding agent, detailing phases from task clarification to automated verification, and providing strategies to further optimize operational costs.
In recent years, the capabilities of multimodal large language models (LLMs) have improved rapidly. Tasks such as code generation, repository analysis, document understanding, and image recognition are gradually shifting from “can it be done?” to “is it stable, cost-effective, and easy to deploy?” For developers, the real focus should not be whether a model can generate a snippet of code in a single conversation, but whether it can consistently participate in the complete software engineering process: understanding project structures, locating issues, modifying multiple files, running tests, continuing to fix based on results, and maintaining controllable costs over the long term.
Therefore, rather than simply discussing whether a model offers a “good experience,” it is better to establish a more objective evaluation framework. This article will explore four aspects: whether capabilities meet coding task requirements, whether long context is truly effective, whether invocation costs are predictable, and how to build a stable coding agent.
1. Focus on Real-World Requirements, Not Just Demos
Many model demonstrations focus on single-file code generation, simple Q&A, or short text modifications. While these scenarios showcase a model’s expressive ability, they do not fully represent the actual development experience. Tasks in engineering projects are often much more complex, typically encompassing the following challenges:
Project Understanding
The model needs to identify directory structures, module responsibilities, configuration files, dependency relationships, and existing coding standards. Simply sending a problem description to the model is usually insufficient for it to grasp the complete business context.Cross-File Modifications
A single requirement might simultaneously involve data structures, service logic, interface definitions, test code, and configuration files. The model must not only generate code but also ensure that modifications are consistent across different files.Context Continuity
During multi-round debugging processes, the model must remember previous changes, test results, and unresolved issues. Otherwise, it may repeatedly modify the same code, overwrite correct code, or reintroduce old bugs.Verifiable Results
Code correctness cannot be judged solely by text quality; it must be verified through static checks, unit tests, build processes, and runtime results.
Therefore, when evaluating a coding model, priority should be given to moderately complex tasks from real projects, rather than just testing a few examples that look impressive.
2. Capability Evaluation: Four Key Metrics
1. Code Generation Quality
Code generation quality is not just about syntactic correctness; it also includes boundary conditions, exception handling, interface consistency, and maintainability. You can design a set of test tasks with progressively increasing difficulty:
- Supplement business logic based on existing interfaces;
- Add parameter validation to an existing module;
- Refactor duplicate code;
- Fix defects based on test cases;
- Add unit tests for legacy modules;
- Replace internal implementations without changing external behavior.
During testing, it is recommended to retain the original requirements, model outputs, actual modifications, and test results to avoid drawing conclusions based solely on subjective impressions.
2. Long Context Handling
A long context window does not mean the model can unconditionally understand an entire code repository. The longer the context, the more noise there is, making retrieval and localization even more critical.
A more reliable approach is to use hierarchical context:
- Layer 1: Provide a project overview, including directory structure, startup instructions, and main modules.
- Layer 2: Provide file summaries relevant to the current task.
- Layer 3: Provide the complete code that needs modification.
- Layer 4: Add test failure information, log snippets, and historical change descriptions.
This approach is more cost-effective than feeding all files at once and reduces the chance of the model being distracted by irrelevant code. Even if a model supports a massive context window, it is not recommended to send the entire repository without filtering.
3. Task Stability
Stability is primarily reflected in whether the results are broadly consistent when the same task is executed multiple times, and whether the model exhibits noticeable behavioral drift. Observations can be made from the following angles:
- Does it frequently misunderstand requirements?
- Does it arbitrarily modify unrelated files?
- Does it generate non-existent functions or configuration items?
- Can it accurately locate the cause after a test failure?
- Does it repeatedly undo correct modifications made in previous steps?
- Can it adhere to specified output formats and operational boundaries?
For a coding agent, stability is often more important than occasionally generating high-quality code. A single impressive result does not mean the workflow is viable; maintaining controllability across dozens of consecutive tasks is what holds engineering value.
4. Multimodal Assistance
Multimodal capabilities can be used to identify UI screenshots, flowcharts, error pages, architecture diagrams, and scanned documents. For example, developers can submit a page screenshot for the agent to analyze layout issues, or submit a flowchart for the model to help organize API call relationships.
However, image understanding results also require verification. For images dense with colors, dimensions, coordinates, and details, the model may make misjudgments. Therefore, image information is better suited for assisting in localization and providing suggestions, while key parameters should still be confirmed through structured data or actual code.
3. Building a Predictable Cost Model
When using LLMs to develop coding agents, costs are typically composed of input, output, cache, and auxiliary tool calls. A general formula can be used for estimation:
Cost per task =Input tokens × Input unit price+ Output tokens × Output unit price+ Cache read tokens × Cache unit price+ External tool call cost
If a task requires reading a context of 500,000 tokens and generating 20,000 tokens of output, the input cost will usually be much higher than the output cost. If a large amount of context can be cached and reused, the cost of subsequent multi-round calls may decrease further.
In actual projects, one should not only account for the single call price but also calculate the total cost of the complete task chain:
Monthly cost =Average cost per task× Daily tasks× Working days per month+ Failed retry cost+ Testing and tool call cost
The most easily overlooked aspect here is the failed retry cost. A single generation failure is not terrible, but if the agent retries multiple times consecutively due to poorly organized context, the actual expenses will rapidly increase. Therefore, reducing costs should not rely solely on unit price discounts; it should start with process design.
4. Recommended Architecture for a Low-Cost Coding Agent
For a deployable coding agent, it is not recommended to adopt a simple “user asks question — model modifies all code” pattern. A more robust solution can be broken down into the following phases.
Phase 1: Task Clarification
First, transform natural language requirements into structured tasks, including at least:
- Target functionality;
- Involved modules;
- Restricted modification areas;
- Inputs and outputs;
- Acceptance criteria;
- Test commands to execute.
If the requirement itself is unclear, the agent should prioritize asking questions rather than directly writing code.
Phase 2: Repository Retrieval
Filter files relevant to the task through directory scanning, keyword search, symbol localization, and dependency analysis. Retrieval results can be provided to the model in summary form first; the complete content is only read after relevance is confirmed.
This “index first, expand later” approach offers three benefits:
- Reduces irrelevant context;
- Lowers single call cost;
- Prevents the model from missing critical files due to information overload.
Phase 3: Generate Modification Plan
Before actually changing the code, let the model output a change plan, for example:
1. Modify the data structure file to add field validation;2. Update service layer logic while keeping the old interface compatible;3. Add exception branch tests;4. Execute static checks and unit tests;5. Perform a secondary fix based on test results.
The planning phase reduces erroneous modifications caused by the model acting directly and facilitates manual review by developers.
Phase 4: Minimal Scope Modification
The agent should only modify files directly related to the current task per session and keep a record of changes. For high-risk files, it is recommended to use patch-style modifications rather than having the model re-output the entire file.
Protection rules should also be set:
- Prohibit modifying sensitive configurations;
- Prohibit deleting test files;
- Prohibit executing high-risk commands;
- Prohibit accessing directories outside the task scope;
- Automatically create version snapshots before modifications.
Phase 5: Automated Verification
After code modification, a verification process must be executed, including format checks, static analysis, unit tests, build checks, and necessary integration tests. Verification results should be fed back to the model, but only relevant error information should be provided to avoid dumping a large amount of irrelevant logs into the context.
If a test fails, the agent should work in a loop of “read error — locate file — analyze cause — generate patch — re-verify,” rather than blindly rewriting all the code.
5. How to Further Control Costs
1. Control Output Length
Require the model to return only necessary content, such as modification summaries, patches, test results, and risk explanations. For large-scale code, do not let the model repeatedly output unmodified files.
2. Use Caching and Summarization
Stable content like project descriptions, coding standards, and directory indexes are suitable for caching. Frequently changing code and logs should be loaded dynamically per task. Summarizing historical conversations also prevents infinite context growth.
3. Task Tiering
Tasks can be categorized into three types:
- Simple tasks: code completion, formatting, comment generation;
- Medium tasks: single-module modifications, test additions, defect fixes;
- Complex tasks: cross-module refactoring, architecture adjustments, long-chain troubleshooting.
Simple tasks can use low-cost models, while complex tasks use more capable models. This is more economical than applying the highest-tier solution to all requests.
4. Limit Retry Attempts
Set a maximum loop count for each task, such as a maximum of a few rounds of “modify — test — fix.” After exceeding the limit, transfer to manual processing to prevent the agent from continuously consuming budget in the wrong direction.
6. How to Evaluate the Final Experience
Whether a coding model is worth long-term use should be judged comprehensively from the following metrics:
- Success rate of a single task;
- Proportion of manual modifications required after the first generation;
- Test pass rate;
- Average task duration;
- Average cost per effective change;
- Number of times unrelated files were modified;
- Ability to automatically recover after failure;
- Actual acceptance level among team members.
Among these, “cost per effective change” is a more valuable reference than simple token unit price. A low-priced solution that frequently fails may ultimately be more expensive than a slightly pricier one that succeeds on the first try.
Overall, when using multimodal LLMs for coding agents, the core competitiveness lies not just in model parameter size or context window length, but in the balance between capability, stability, cost, and engineering workflow. For individual developers and small teams, the most practical route is usually not to pursue automating all work at once, but to start with code retrieval, test generation, error analysis, and small-scope patches, gradually building an automatable workflow that is verifiable, rollback-able, and cost-accountable.
Once model invocations are brought under clear task boundaries, context strategies, and test loops, low cost does not mean reduced quality. Instead, through more refined process design, you can achieve stable and sustainable improvements in development efficiency.
