Benchmarking Efficiency and Stability of LLM Agents Under a Unified Framework
This article presents a controlled benchmarking methodology for evaluating large language model agents on complex front-end development tasks. It defines a four-layer environment for variable isolation, a three-category acceptance process, and a metric system covering latency, action counts, retries, context usage, and repair rounds. The focus is on engineering implementation—structured logging, retry policies, and data interpretation—so that results are reproducible and can be attributed to model capability rather than framework noise.
1. Problem Background
Modern AI agents can now handle complete front-end development tasks, from requirement understanding to implementation. However, evaluation practices remain inconsistent. Common approaches either look only at whether the final artifact is usable, or compare the response time of a single API call. Both perspectives miss the process-level details. A task that starts from a request and ends with acceptance involves a certain number of actions, tool invocations, failures, and retries. Together, these factors determine the actual engineering cost.
This article discusses how to design a controlled, horizontally comparable evaluation method to compare different models running on the same agent framework while completing complex front-end tasks. It does not draw conclusions about any specific product. The focus is on the evaluation methodology, the metric system, and the engineering implementation.
2. Controlled Variables: A Prerequisite for Fair Comparison
For a horizontal comparison to be valid, only one variable should change at a time. If the orchestration framework, task description, assets, context length, browser environment, and acceptance criteria all change simultaneously, the results cannot be attributed to any single factor. A recommended approach is to split the evaluation environment into four layers:
- Orchestration framework layer: The scheduling loop, tool registration, prompt templates, and retry strategy remain identical.
- Task layer: The requirement document, deliverable checklist, and acceptance terms are word-for-word identical.
- Resource layer: The context window limit, task token budget, asset dataset, and random seed (if supported) are fixed.
- Verification layer: The browser version, viewport size, screenshot timing, and automated checking scripts are unified.
Only when the one variable being replaced is changed can the resulting performance difference be explained as a difference in model capability or stability.
3. Task Design: Covering Real-World Difficulties
Evaluation tasks should not be trivial. A front-end composite task with good discriminative power typically includes the following elements:
- Multiple interrelated page states, such as a project overview, asset panel, comment list, version management, and publish preview.
- Multiple role-based views, where different identities see different permissions, requiring the agent to correctly implement permission logic.
- Complex interactive behaviors, including asset drag-and-drop, coordinate-based annotation, version switching, approval, and rejection.
- State persistence, where data must remain intact after a page refresh.
- Responsive layout, with separate checks for desktop and mobile.
Input materials should only provide raw data—for example, public images, member information, and seed files for version history—but not a ready-made page template. This forces the agent to organize the information architecture from scratch rather than replicating a given style.
Acceptance should be divided into three categories:
- Functional acceptance: Automated scripts execute each interaction test case and record the pass rate.
- Visual acceptance: Screenshots are taken at a fixed viewport to check for layout overflow or element overlap.
- Engineering acceptance: Deliverables are checked for completeness, including source code, screenshots, execution logs, self-assessment reports, and metric files.
4. Metric System
A single completion rate does not reflect efficiency. At minimum, the following metrics should be collected:
| Metric | Meaning | Capability Reflected |
|---|---|---|
| End-to-end latency | Time from task start to acceptance | Overall efficiency |
| Number of action turns | Number of decisions the model makes | Planning quality |
| Number of tool calls | Number of read/write operations, command executions, browser interactions | Tool usage efficiency |
| Number of failures and retries | API errors, timeouts, invalid output formats | Service stability and recovery capability |
| Peak context usage | Maximum number of tokens in a single request | Context management capability |
| Number of repair rounds | Number of modification cycles after acceptance failure | Self-correction capability |
Retries need to be classified separately. Internal automatic retries occur at the request layer and usually only add to the latency of a single call. Task-level reruns mean the entire task is restarted from the beginning, and the time accounting is completely different. Mixing the two in a report distorts the comparison.
5. Engineering Implementation of Metric Collection
Collection should happen at the orchestration framework layer, not rely on the model’s self-reported execution. A practical record structure looks like this:
record = {"run_id": "...","variant": "candidate_a","start_ts": 0,"end_ts": 0,"turns": 0,"tool_calls": 0,"api_errors": 0,"retries": {"internal": 0, "task_level": 0},"context_peak_tokens": 0,"repair_rounds": 0,"acceptance": {"functional": None, "visual": None, "engineering": None}}
Every model request should be instrumented, recording start and end time, return status, and input/output token counts. Every tool call should similarly record a parameter summary and result status. Logs should be emitted as structured text to enable batch aggregation.
For retryable errors, an exponential backoff with random jitter is recommended to avoid congestion from simultaneous replays:
def call_with_backoff(fn, max_attempts=5, base=1.0, cap=30.0):for attempt in range(max_attempts):try:return fn()except TransientError:if attempt == max_attempts - 1:raisedelay = min(cap, base * (2 ** attempt))sleep(random_uniform(0, delay))
Only retry transient errors such as timeouts, rate limiting, and temporary service unavailability. Parameter errors and authentication errors should fail immediately. Retrying all errors indiscriminately masks real configuration issues and makes latency data meaningless.
6. Interpreting Results
Once data is collected, do not look only at whether the task is completed. Follow this analysis order:
- Verify acceptance results first. Ensure that all groups meet the minimum requirements, exclude non-compliant samples, and then compare efficiency.
- Decompose the latency composition. Separate model inference time, tool execution time, waiting time, and retry time. If a group’s latency is mostly waiting time, the problem is likely service stability, not inference capability.
- Compare the number of action turns and tool calls. Fewer turns with high information density per turn usually indicates clear planning. Many turns with repeated edits to the same file often point to a breakdown in context understanding.
- Record first-attempt quality separately from post-repair quality. First-attempt quality reflects one-shot generation capability; post-repair quality reflects error-correction capability. They should not be merged into a single score.
- Evaluate visual results with the same rules. Personal preferences should not drive conclusions. Scoring criteria must be defined before the evaluation begins.
The sample size from a single experiment is usually limited. Conclusions should be expressed using medians and distribution ranges from multiple runs, not the best value from a single run.
7. Common Issues and Improvement Directions
- Loss of state: Data disappears after a refresh, usually because state is only held in memory. Key state should be synchronized to browser local storage or a backend store, and the acceptance test should include a “refresh and check” step.
- Unstable drag-and-drop and coordinate positioning: Annotation positions should be saved using container-relative coordinates, and coordinate conversion logic should be tested at different viewport sizes.
- Mobile content overflow: Tables and canvas-like components are the most prone to this. The acceptance script can check whether the page width exceeds the viewport, and wrap wide tables in a horizontally scrollable container.
- Context bloat: In long tasks, accumulating history messages consumes the effective context window. Periodically compress historical content via summarization, keeping only key file paths and state snapshots.
8. Summary
Comparing multiple models should not rely solely on the final page quality. By fixing the orchestration framework, unifying the task and acceptance rules, and separately recording latency, turns, tool calls, retries, and repair cycles, reproducible conclusions can be obtained. For engineering teams, the value of this approach is to convert “is it fast” into actionable questions such as “where is the latency spent” and “can the system recover reliably after failure.”
