How to Measure LLM Agent Accuracy and Deploy Multi-Agent Clusters
This article explains how to measure LLM agent accuracy and how to deploy multi-agent clusters in production. It covers the three main drivers of accuracy improvement (tool calling, failure recovery, and context management), a standardized accuracy measurement framework with report fields, DAG-based task decomposition for multi-agent systems, a comparison of single-agent versus multi-agent architectures, and the infrastructure components and risk controls required before enterprise deployment.
1. Key Takeaways First
Engineering leads reading this article should remember three points. First, accuracy improvements come from three types of changes: tool calling, failure recovery, and context management, but each has applicable boundaries. Second, any accuracy figure must come with its measurement methodology, otherwise it cannot be compared. Third, before agents enter an enterprise environment, identity and permissions, auditing, rollback, and human fallback must already be in place.
2. Where Do Accuracy Improvements Come From
An agent’s work is more complex than single-turn Q&A. It must plan multiple steps, call external interfaces, and adjust the next step based on execution results. Over the past one or two years, most accuracy improvements in real implementations have concentrated in three areas. The effect of these improvements depends on the specific task and implementation, and cannot be generalized as conclusions for all scenarios.
First, tool calling is more stable. Many models have been trained on large volumes of function-calling samples, making it easier to output parameters that conform to a JSON Schema and to handle nested structures. After a call errors out, the model can read the error message, modify the parameters, and retry. This reduces failures caused by format errors. However, correct format does not mean correct semantics. Parameters may be syntactically valid yet contain wrong values, such as writing the end date into the start date field. When tool descriptions are vague or fields are numerous with similar names, these errors remain common.
Second, the agent can roll back and re-plan after failure. In long tasks, an error in one step affects all subsequent steps. A common approach is a Plan-Execute-Reflect loop: execute a step, check the result, and if an anomaly is found, return to the previous checkpoint and re-plan the remaining steps. This mechanism prevents errors from propagating, but it has two prerequisites. First, rollback can only undo internal state; it cannot undo external side effects that have already occurred, such as a message already sent or a payment already submitted. Second, if the reflection step uses the same model and the same judgment criteria, it may repeatedly reach the same wrong conclusion. Therefore, steps with side effects need compensating actions, and operations between checkpoints should ideally be designed to be idempotent.
Third, long-context management has improved. Agents generate large amounts of intermediate state and logs. If the model cannot find key historical information, it tends to repeat operations already performed or forget earlier constraints. A common approach is to write state to external storage and put only what the current step needs into the context. The risk of this approach lies in retrieval. If retrieval misses a constraint, the model will make the same mistake again. External storage merely moves the problem from context to retrieval, and retrieval quality needs to be tested separately.
3. How to Measure Accuracy
When discussing accuracy, the measurement methodology must be clearly stated. The common methodology is to fix a set of tasks and count the proportion whose final results pass the acceptance criteria. With different methodologies, numbers from two teams cannot be directly compared. The table below lists the fields an evaluation report should include.
| Field | What Must Be Specified | Consequence of Not Specifying |
|---|---|---|
| Sample size | Number of test tasks and sample source (desensitized real tickets, manually written, or simulated) | With too few samples, differences of a few percentage points may just be random fluctuation |
| Difficulty distribution | Stratified statistics by step count, tool count, or manually labeled difficulty | If easy tasks dominate, average accuracy will be inflated |
| Acceptance criteria | Rules for passing, ideally automatically reproducible, e.g., tests pass or exact field match | If criteria vary with human judgment, results cannot be verified |
| Human correction | Whether it counts toward results. Recommended: exclude by default and report the human correction rate separately | Human-corrected results would be credited as completed by the agent itself |
| Retries | Whether success after retry counts as success. Recommended: report first-pass rate and post-retry pass rate separately | Retries mask instability |
| Version and configuration | Model version, prompt version, tool version, temperature and other parameters, plus runs per task | Results cannot be reproduced, and you cannot tell which change caused the improvement |
| Cost and latency | Average calls per task, token consumption, median and P95 duration | Higher accuracy may come at the cost of sharply higher cost |
| Human intervention rate | Proportion of tasks requiring human takeover or confirmation | Higher accuracy does not equal business benefit; labor cost may not have decreased |
Below is a template for an evaluation report, with numbers left blank to be filled in with actual run results:
Evaluation set: tasks, sourced from desensitized historical tickets, divided into three tiers by step count, tasks per tier. First-pass rate %, post-retry pass rate %. Human correction rate %. Average model calls per task , median token consumption , P95 duration seconds. Model version , prompt version , each task run _ times.
4. How a Multi-Agent Cluster Decomposes Tasks
A single agent suits tasks with clear goals and few steps. For larger goals, a controller agent can first perform decomposition, then hand subtasks to sub-agents with different roles for parallel execution.
The decomposition result is typically a directed acyclic graph (DAG). Each node is a subtask, and each edge represents a dependency. Nodes without prerequisites can execute concurrently; dependent nodes wait for their predecessors to complete. During decomposition, every subtask must have a verifiable acceptance criterion, otherwise the controller cannot determine whether it is finished.
Below is an example of decomposing a software development task. The permissions and audit columns in the table are content that must be added during deployment.
| Subtask | Dependency | Role | Tool Permissions | Acceptance Criteria | Approval & Audit |
|---|---|---|---|---|---|
| Requirement decomposition | None | Planner | Read-only access to requirement docs | Outputs a verifiable feature list, each feature with acceptance conditions | Output archived; no approval needed |
| Interface implementation | Requirement decomposition | Coder | Read/write to code repo, limited to designated feature branch; direct merge to main forbidden | Unit tests pass | Each commit records operator and session ID |
| Test writing | Requirement decomposition | Tester | Test environment access only; no production database credentials | Covers all features | All test environment operations logged |
| Code review | Interface implementation | Reviewer | Read-only access to code repo | No blocking issues; conclusion with rationale | Review comments retained; human confirmation required before merge |
The scheduler must also handle several issues. Parallelism must be limited, otherwise many subtasks calling the model simultaneously will cause cost and rate limits to spiral out of control. Each subtask needs a timeout; after timeout it is cancelled and enters retry or is handed to a human. Retries must rely on idempotent operations, otherwise the same email may be sent twice. Parallel subtasks writing to the same file will conflict, so decomposition must ensure non-overlapping write scopes, or conflict detection must happen during the merge phase.
The following code demonstrates the basic structure of scheduling. It uses only the Python standard library; save it as dag_demo.py and it runs directly. The stub functions are placeholders and call no model or tool.
import asynciofrom dataclasses import dataclass, fieldfrom typing import Awaitable, Callable, Dict, ListRunner = Callable[[Dict[str, str]], Awaitable[str]]@dataclassclass Task:name: strrunner: Runnerdeps: List[str] = field(default_factory=list)max_retries: int = 2timeout_s: float = 60.0async def run_with_retry(task: Task, inputs: Dict[str, str]) -> str:last_error = Nonefor attempt in range(task.max_retries + 1):try:return await asyncio.wait_for(task.runner(inputs), timeout=task.timeout_s)except Exception as exc:last_error = excif attempt < task.max_retries:await asyncio.sleep(min(2 ** attempt, 10))raise RuntimeError(f"Task {task.name} failed after {task.max_retries} retries") from last_errorasync def run_dag(tasks: List[Task], concurrency: int = 4) -> Dict[str, str]:by_name = {t.name: t for t in tasks}for t in tasks:for d in t.deps:if d not in by_name:raise ValueError(f"{t.name} depends on unknown task {d}")results: Dict[str, str] = {}pending = set(by_name)sem = asyncio.Semaphore(concurrency)async def execute(name: str) -> None:async with sem:inputs = {d: results[d] for d in by_name[name].deps}results[name] = await run_with_retry(by_name[name], inputs)while pending:ready = [n for n in pending if all(d in results for d in by_name[n].deps)]if not ready:raise ValueError("Circular dependency detected; scheduling cannot continue")pending -= set(ready)outcomes = await asyncio.gather(*(execute(n) for n in ready), return_exceptions=True)for outcome in outcomes:if isinstance(outcome, BaseException):raise outcomereturn resultsdef make_stub(name: str) -> Runner:async def run(inputs: Dict[str, str]) -> str:await asyncio.sleep(0.1) # placeholder: replace with model or tool call in productionreturn f"{name} done, prerequisites: {sorted(inputs)}"return runasync def main() -> None:tasks = [Task("decompose_requirements", make_stub("decompose_requirements")),Task("implement_interface", make_stub("implement_interface"), deps=["decompose_requirements"]),Task("write_tests", make_stub("write_tests"), deps=["decompose_requirements"]),Task("code_review", make_stub("code_review"), deps=["implement_interface"]),]results = await run_dag(tasks, concurrency=2)for name, output in results.items():print(name, "->", output)if __name__ == "__main__":asyncio.run(main())
This code has clear boundaries. It has no authentication, persistence, cancellation mechanism, or audit logging, and failed tasks are not written to a dead-letter queue. It only proves the scheduling structure works; it cannot be used in production directly. When integrating with real systems, you need to add the capabilities above and ensure every runner meets idempotency requirements.
5. Single Agent or Cluster
When choosing an architecture, the differences between the two mainly appear in cost, latency, and failure modes. The table below lists four common dimensions.
| Dimension | Single Agent | Multi-Agent Cluster |
|---|---|---|
| Call cost | Fewer calls, relatively concentrated context | Each sub-agent calls the model; cost grows with subtask count |
| Latency | Steps are serial; latency grows with step count | Independent subtasks can run in parallel, but decomposition and merging add overhead |
| Failure modes | One error may affect the whole chain | Inconsistent subtask interfaces, merge conflicts, controller decomposition errors |
| Suitable tasks | Clear goal, few steps, easy-to-verify results | Decomposable tasks with clear dependencies, each with acceptance criteria |
If you cannot write acceptance criteria for subtasks, do not split into a cluster. Start with a single agent, build the tool gateway, evaluation set, and audit logging first, then consider decomposition.
6. Foundational Components for Deploying Digital Workers
Once digital workers enter an enterprise environment, the following foundational components are needed. Missing any one of them increases the difficulty of troubleshooting and accountability.
- Identity and permissions: each agent uses an independent identity with only the minimum permissions needed to complete its tasks.
- Tool gateway: all tool calls go through a unified entry point handling parameter validation, authentication, rate limiting, and whitelisting.
- State storage: saves task state and checkpoints, supports recovery from failure points, and supports post-hoc replay.
- Message queue: distributes subtasks; failed messages go to a dead-letter queue for troubleshooting.
- Audit logging: records inputs, model outputs, tool calls, approvers, and timestamps. Retention periods follow compliance requirements.
- Evaluation set and regression: after every change to prompts, models, or tools, compare results on the same task set.
- Human fallback: low-confidence or high-risk tasks are handed to humans, who can take over and continue execution.
- Secrets management: credentials are stored in a secrets management service, never in code, config files, or logs.
7. Risk Mitigation Measures
- Least privilege: each sub-agent can only access the tools and data scope needed for its subtask. Write permissions are off by default and enabled per task.
- Sandboxed execution: code execution, file operations, and external network access run in isolated environments with restricted outbound addresses.
- Approval: operations such as deleting data, making payments, sending external messages, or modifying permissions require human confirmation before execution.
- Rollback: save snapshots before write operations, or define compensating actions for each step with side effects. Rollback must be drilled regularly; don’t try it for the first time after an incident.
- Data desensitization: remove personal information such as ID numbers, phone numbers, and bank card numbers before sending data to the model; logs are desensitized as well.
- Cost and concurrency limits: set token budgets, maximum call counts, and timeouts for each task. When limits are exceeded, circuit-break and hand over to humans.
- Prompt injection defense: web pages, documents, and email content returned by tools are treated as data, not executed as instructions. If model output asks to ignore established rules, the workflow should refuse to proceed.
- Environment isolation: test, staging, and production environments use different credentials; agents can access only the test environment by default.
8. Conclusion
Agent accuracy improvements have a real technical foundation, but every improvement has prerequisites. When evaluating a solution, first look at its measurement methodology, then at cost, latency, and human intervention rate. Only with all these numbers in place can accuracy be used to compare solutions. Before deployment, the four items of identity and permissions, auditing, rollback, and human fallback must be in place first; only then should you discuss scaled decomposition.
