Evaluating General-Purpose Coding: Visual Replication and Long-Horizon Tasks
This article redefines how we evaluate AI coding tools beyond single-file code generation. It introduces a reproducible evaluation framework with layered scenarios, four-dimensional metrics, and anti-contamination mechanisms, then details engineering practices for visual replication and long-horizon tasks. Readers will learn how to build persistent task lists, small-step rollback, and automated gates to measure functional correctness, visual consistency, process stability, and cost efficiency in real development pipelines.
1. Why General-Purpose Coding Needs a New Evaluation
In the past, evaluating an AI coding tool often meant checking whether it could produce runnable code at the single-file or single-function level. Real engineering work goes far beyond that: engineers provide a UI screenshot and ask for the styles to be reproduced, describe a business rule that requires changes across multiple modules, or expect the tool to keep fixing bugs, adding tests, and refactoring over dozens of turns. These tasks span visual understanding, code generation, engineering constraints, and state retention, commonly grouped under “general-purpose coding.”
A set of comparative findings from the source material—where an AI coding model performed more strongly in visual coding, visual replication, and long-horizon tasks across 200 real-world scenarios compared with similar solutions—essentially reveals a trend: the focus of evaluation is shifting from “can it write a correct piece of code” to “can it continuously deliver usable results under complex constraints.” This article does not restate specific products but abstracts this trend into actionable evaluation and engineering methods.
General-purpose coding includes at least four capabilities:
- Semantic-to-code mapping: turning natural-language requirements into structured implementations;
- Visual-to-code mapping: reproducing layout and styles from screenshots, design mockups, or hand-drawn sketches;
- Long-horizon state retention: remembering constraints, avoiding regressions, and converging step by step across multiple turns;
- Engineering adaptation: respecting existing directory structures, dependency versions, code styles, and testing conventions.
2. Designing the Evaluation Framework for Reproducibility
2.1 Scenario Layering
Divide the scenario library into three layers to avoid a “question-bank effect”:
- Atomic layer: single functions, single components, single style fragments;
- Composite layer: page-level replication, small features spanning multiple files;
- Long-horizon layer: tasks requiring more than twenty turns, including regression and refactoring.
2.2 Metric Definitions
Do not rely only on “pass rate.” Use four-dimensional metrics instead:
- Functional correctness: unit tests plus human acceptance, tracked in parallel;
- Visual consistency: layout position error, color and font-size deviation, responsive breakpoint behavior;
- Process stability: repeated reversals, forgotten constraints, changes that make things worse;
- Cost efficiency: number of turns, context length, number of human takeovers.
A sample evaluation record structure can be written as:
{"scene_id": "vp-042","layer": "composite","input_type": ["screenshot", "text"],"metrics": {"functional_pass": true,"visual_diff_score": 0.12,"rounds": 7,"human_takeover": false},"failure_tags": ["spacing deviation", "missing breakpoint"]}
2.3 Anti-Contamination Mechanisms
Rotate scenarios regularly and keep a portion as an “undisclosed set.” Also record how the model organizes context, because the same model under different context strategies can vary far more than models differ from each other.
3. Visual Replication: From Pixel Matching to Maintainable Code
The difficulty of visual replication is not “looking similar” but “looking similar and staying maintainable.” Many solutions can generate a high-similarity page in one shot, but the code is a “one-off artifact” with hard-coded coordinates that cannot be responsive or reused.
Recommended workflow:
- Structure extraction: first identify grids, hierarchy, and repeated blocks, then output a draft component tree;
- Token normalization: converge colors, spacing, and corner radii into design token variables;
- Component-based implementation: prefer layout capabilities (flexbox, grid) over absolute positioning;
- Visual regression: use screenshot comparison to close the loop and feed the diff list back to the model.
A reusable prompt skeleton example:
Goal: reproduce the page structure and visual hierarchy of the attached image.Constraints:1) Do not stack elements with absolute positioning; use flex/grid layout;2) Extract colors and spacing into variables with semantic names;3) Output a component split list before writing code;4) Provide adaptation notes for three breakpoints.
The key is to include both “visual similarity” and “code quality” in acceptance, otherwise the evaluation rewards shortcuts.
4. Long-Horizon Tasks: State, Constraints, and Regression Governance
Long-horizon tasks usually fail not because a single step cannot be written, but because of state drift: early constraints are forgotten, changes introduce regressions, and errors compound. Three engineering measures can mitigate this.
First, externalize state. Write requirements, constraints, completed items, todos, and known issues into a persistent task-list file, updated every turn, instead of relying entirely on the conversation context.
## Constraints- Keep the existing directory structure- Do not upgrade build tool versions## Progress- [x] Data layer interface- [ ] Page linkage- [ ] Regression tests## Known Issues- Missing empty-state rendering
Second, commit in small steps with rollback. Each turn should target one verifiable small goal and keep the previous version, so that when a regression appears you roll back immediately instead of stacking more patches.
Third, automated gates. Use type checks, static analysis, unit tests, and screenshot comparison as multiple layers of gates, turning “it feels better” into “the metrics are better.”
5. Common Failure Modes and Root Causes
- Constraint forgetting: early requirements are diluted in long contexts, requiring an external list and per-turn restatement;
- Visual overfitting: hard-coded values traded for similarity, requiring tokenization and layout constraints;
- Regression accumulation: lacking gates and rollback, requiring small-step verification;
- Context contamination: leftover failed attempts cause oscillation, requiring cleanup and a rebuilt summary;
- Acceptance misalignment: only demo effects are checked, not maintainability, requiring dual-track metrics.
6. Implementation Advice: Embedding Evaluation into the Development Workflow
For teams, the most valuable approach is to treat evaluation as a continuous pipeline rather than a one-time report:
- Build and version the scenario library, managed on par with the code repository;
- Run layered regression on every model or prompt-strategy change;
- Collect process data (turns, context length, takeover count) for cost assessment;
- Cluster failure tags into an improvement backlog;
- Carry it on the cloud as general-purpose capabilities: use object storage to save scenarios and screenshot baselines, use a container platform to run isolated evaluation jobs, use log and monitoring services to track metric fluctuations, and use a message queue to smooth peaks and parallelize tasks.
7. Conclusion
The competitive focus of general-purpose coding has shifted from single-point code generation to a combination of visual understanding, long-horizon state retention, and adherence to engineering constraints. The takeaway for developers and enterprises is clear: do not trust a single demo, but build a layered scenario library, dual-track metrics, and automated gates, and continuously validate AI coding tools in real development pipelines. Baidu AI Cloud also emphasizes carrying such evaluation and development workflows in an observable, rollback-capable, and reproducible way in related engineering practices, which aligns with the methodology described above.
