Choosing a Programming Agent: Long Tasks, Multi-Agent Collaboration, and Cost Evaluation
This article explores a practical evaluation framework for selecting programming agents. It focuses on three key dimensions: long-task iteration capability, multi-agent collaboration, and cost estimation. Readers will learn how to assess an agent's performance in continuous execution, multi-agent stability, and overall cost-effectiveness to make informed decisions for their own projects.
I. Why New Evaluation Dimensions Are Needed
Programming agents are evaluated differently from standard conversational models. A conversational model simply answers a question and finishes, whereas an agent might execute tens to hundreds of steps continuously, with errors in each step propagating to subsequent ones. Therefore, relying solely on public benchmark scores is insufficient. You must answer three questions: Can the model maintain its direction over a long chain of steps? Can multiple agents collaborate and stably converge? How much does it cost to complete a task?
This article addresses these three questions by providing an actionable evaluation framework for your own projects. It does not cite specific model test conclusions. Readers should validate using their own codebases and tasks, and the metrics and steps below can be directly applied.
II. Dimension 1: Long-Task Iteration Capability
Long-task iteration refers to the agent continuously executing, checking results, and making corrections around a single goal without step-by-step human confirmation. Common tasks include building a multi-page frontend application from requirements, locating bugs and adding tests in an existing project, or performing cross-file renaming or interface migrations.
During evaluation, it is recommended to fix three things: task input, repository state, and pass/fail criteria.
- Task input: Use the same requirements document and the same initial commit, keeping prompts consistent across different models.
- Repository state: Record dependency versions, test commands, and the runtime environment to ensure the same starting point for every execution.
- Pass/fail criteria: Break down “completion” into checkable items, such as build passing, all specified tests passing, and key page interactions being manually reproducible.
It is recommended to track the following metrics:
- Task completion rate: The percentage of times all pass criteria are met in N independent runs. A larger N yields more stable conclusions. Usually, run at least 5 times and report the distribution rather than just the average.
- Human intervention count: The number of times the agent pauses for confirmation, and the reason for each.
- Tool call rounds and token consumption: Used for later cost calculations.
- Self-correction count: Whether the agent can locate the cause after a test failure and fix it within the same task run.
In a local command-line environment, a common scenario is “start service, access page, check for errors, modify code, re-run.” Whether this closed loop can be completed autonomously is a crucial indicator of whether the model is suitable for unattended tasks. During testing, note that the agent might declare completion without actually verifying it. Therefore, the pass/fail judgment should be done by scripts or test suites, not solely by the agent’s own claims.
III. Dimension 2: Multi-Agent Collaboration
As tasks get longer, a single agent often faces the issue of its context being filled with tool outputs, and its planning can easily deviate from the goal. Splitting tasks among multiple execution agents, where each maintains its own context, is a common countermeasure.
Typical architectures include three roles:
- Main control agent: Responsible for breaking down tasks, assigning subtasks, and aggregating results.
- Execution agents: Each handles a subtask without sharing intermediate context.
- Checker agent: Conducts independent reviews of execution results, such as running tests or validating data formats.
Tasks suitable for parallelization share a common characteristic: subtasks are independent of each other, and the processing pattern for a single subtask is fixed. For example, batch processing dozens of structurally similar documents, extracting fields and calculating metrics one by one, and finally merging them into a table by an aggregation agent fits this pattern.
Parallel scheduling requires four controls: limiting concurrency, setting timeouts for each subtask, limited retries upon failure, and format validation before returning results. Below is a skeleton code highlighting these control points. agent is the asynchronous invocation function, and validate needs to be implemented by the caller based on their output format.
import asyncioMAX_CONCURRENCY = 4 # Maximum number of subtasks running simultaneouslyTIMEOUT_S = 300 # Timeout in seconds for a single subtaskMAX_RETRIES = 2 # Maximum retry attempts after failureasync def run_one(agent, task, sem, validate):async with sem:reason = "unknown"for _ in range(MAX_RETRIES + 1):try:result = await asyncio.wait_for(agent(task["input"]), timeout=TIMEOUT_S)if validate(result, task["schema"]):return {"task_id": task["task_id"], "status": "ok", "result": result}reason = "schema_mismatch"except asyncio.TimeoutError:reason = "timeout"except Exception as exc:reason = f"error:{type(exc).__name__}"return {"task_id": task["task_id"], "status": "failed", "reason": reason}async def run_all(agent, tasks, validate):sem = asyncio.Semaphore(MAX_CONCURRENCY)return await asyncio.gather(*(run_one(agent, t, sem, validate) for t in tasks))
gather returns a status record for each subtask and will not interrupt the entire batch due to a single subtask error. This way, failed subtasks can be marked individually while other results are retained, allowing the aggregation agent to clearly point out the missing parts.
It is recommended to standardize subtask descriptions into a field table for easier scheduling and troubleshooting:
| Field | Description | Example |
|---|---|---|
| task_id | Unique identifier for the subtask | report_0042 |
| agent_role | Execution role | extract / review / summarize |
| input_ref | Input location, e.g., object storage path | s3://bucket/reports/0042.pdf |
| timeout_s | Timeout in seconds | 300 |
| max_retries | Maximum retry attempts | 2 |
| output_schema | Output structure version | extract_v2 |
The multi-agent architecture also comes with trade-offs. Every additional agent means an extra context and a set of token consumption, increasing coordination costs simultaneously. Splitting is only worthwhile if subtasks can genuinely be completed independently. When a task is complex but cannot be split, it is better to optimize the context management of a single agent, such as only putting necessary files into the context and compressing tool outputs.
IV. Dimension 3: Usage and Cost
Token consumption for agent tasks is significantly higher than conversational tasks. A single long task might involve numerous tool calls, each carrying context. Therefore, simply comparing unit prices does not reflect the true cost.
You can estimate the cost of a single task using the following formula:
Cost per task ≈ Average tokens per round × Rounds per task × Unit price × Retry coefficient
The retry coefficient can be estimated based on measured failure retries. When estimating, it is recommended to run small-scale tasks to get real data first, and then extrapolate the total for batch tasks. Estimating directly from theoretical values often yields results that are too low.
Cost-effectiveness comparison should be based on the completion status of the same task. Assuming Model A has a higher completion rate but consumes more tokens per task, you should compare “how much it costs per successfully completed task” rather than the unit price itself.
Self-hosting and managed services represent two different cost paths. Self-hosting avoids continuous pay-per-token billing but requires engineering costs for inference framework selection, VRAM planning, concurrency scheduling, and version upgrades. For small to medium-sized teams without dedicated infrastructure teams, choosing a mainstream managed large model service platform, combined with object storage, message queues, and logging services, is typically the more practical approach.
