Latency-Aware Coding Agents
A coding agent does more than generate text. It reads files, searches a repository, edits code, runs commands, observes the results, and decides what to do next.
Each step takes time. The delay a user experiences therefore depends on the whole agent loop:
flowchart LR
U["User request"] --> S["Session and environment setup"]
S --> M["Model chooses the next action"]
M --> T["Tool executes"]
T --> O["Result returns to the model"]
O --> D{"Task complete?"}
D -- "No" --> M
D -- "Yes" --> V["Tests and verification"]
V --> R["Useful result"]
A model can generate tokens quickly and still complete a task slowly. It may make too many serial tool calls, repeatedly inspect the same files, wait for a slow environment, retry avoidable failures, or produce a patch that requires substantial rework.
The practical target is time to a useful, verified result.
Begin With Three Different Meanings Of Speed
Section titled “Begin With Three Different Meanings Of Speed”Several measurements are commonly described as agent speed.
| Measurement | What it tells you | What it misses |
|---|---|---|
| Time to first token | How quickly visible output begins | Whether the agent finishes the task |
| Tokens per second | How quickly the model generates after starting | Tool time, retries, and number of turns |
| Time per turn | How long one model-and-tool exchange takes | How many turns the task needs |
| End-to-end task latency | How long the complete run takes | Whether the result is correct |
| Time to verified result | How long it takes to produce and validate an acceptable result | Later human review or production failures |
For coding work, the final measurement is usually the most meaningful.
A simplified latency model is:
task time = setup and queue time + model inference time + tool and environment time + verification time + retry and recovery time - work safely overlapped in parallelThis is not an exact formula. Some work overlaps, model providers stream output, and tools may run concurrently. It is still a useful way to locate the real bottleneck.
Token Generation Is One Part Of The Agent Loop
Section titled “Token Generation Is One Part Of The Agent Loop”Suppose two agents use models with different generation speeds.
| Behavior | Agent A | Agent B |
|---|---|---|
| Model generation | 20 seconds | 40 seconds |
| Serial tool calls | 12 | 5 |
| Tool and command time | 90 seconds | 35 seconds |
| Retry time | 45 seconds | 0 seconds |
| Total | 155 seconds | 75 seconds |
Agent A has the faster model. Agent B finishes the task sooner because its trajectory is shorter and contains less wasted work.
The trajectory is the sequence of model actions, tool calls, observations, and state changes produced during a run. Agent latency depends heavily on trajectory quality:
- Did the agent identify the relevant files early?
- Did it use the right search tool?
- Did it inspect independent evidence concurrently?
- Did it make a focused edit or rewrite unrelated code?
- Did it test at useful checkpoints?
- Did it recover cleanly when a command failed?
This is why latency work belongs partly in model training, partly in agent design, and partly in infrastructure.
Find The Critical Path
Section titled “Find The Critical Path”The critical path is the longest chain of dependent work that must complete before the task can finish.
Consider a request to update an API and its documentation. The agent may need to:
- locate the API implementation
- inspect its tests
- read the public documentation
- understand the current contract
- edit the implementation
- update tests and documentation
- run verification
The first three inspections may be independent. The implementation edit depends on what those inspections reveal. Final verification depends on the edits.
flowchart TD
Q["Task"] --> A["Read implementation"]
Q --> B["Read tests"]
Q --> C["Read documentation"]
A --> S["Synthesize current contract"]
B --> S
C --> S
S --> I["Edit implementation"]
I --> T["Update tests"]
I --> D["Update documentation"]
T --> V["Run verification"]
D --> V
Running A, B, and C concurrently can shorten the critical path. Starting I before their evidence is understood may create rework.
Parallelize Independent Reads, Preserve Dependencies
Section titled “Parallelize Independent Reads, Preserve Dependencies”Parallel tool use is valuable when operations:
- do not depend on one another’s output
- do not mutate shared state
- have bounded resource consumption
- return results that can be combined coherently
Good candidates include:
- reading several known files
- searching different parts of a repository
- checking documentation and source code
- running independent static checks
- gathering separate diagnostic signals
Keep operations serial when:
- a later command needs an earlier command’s output
- two edits affect the same files or interfaces
- one step changes the environment used by another
- a test must run against a completed change
- concurrent commands compete for a scarce or stateful resource
Parallel execution can also create new delays. Too many results may consume context, simultaneous commands may overload the sandbox, and overlapping edits may require conflict resolution. The objective is a shorter valid critical path, not the largest possible fan-out.
See Parallel Coding Agents for Large Refactors for worktrees, dependency graphs, isolated writers, and integration controls.
Match The Execution Mode To The Work
Section titled “Match The Execution Mode To The Work”Coding agents commonly operate in two modes.
Interactive foreground work
Section titled “Interactive foreground work”The user stays engaged and reviews progress frequently.
This mode fits:
- explaining unfamiliar code
- investigating a local error
- making a small bounded edit
- iterating on UI or behavior
- tasks where the user may redirect the agent
Useful properties include:
- low startup time
- short model turns
- quick tool feedback
- visible progress
- easy interruption
- small, reviewable changes
Long pauses are costly because the user is waiting and may lose their mental context.
Background work
Section titled “Background work”The task runs while the user does something else.
This mode fits:
- long test suites
- multi-package migrations
- repository-wide analysis
- extended research
- large but well-scoped implementation plans
Useful properties include:
- an isolated and reproducible environment
- durable state across process failures
- checkpointing and retries
- explicit budgets and stop conditions
- asynchronous notifications
- a final summary with verification evidence
A background run can tolerate more elapsed time, but it needs stronger operational controls. A foreground session can ask the user for clarification quickly; an unattended run must know when to pause instead of making a risky assumption.
| Decision | Foreground | Background |
|---|---|---|
| Human availability | Present | Intermittent |
| Typical feedback loop | Seconds or minutes | Minutes or hours |
| Clarification | Ask immediately | Pause or follow a predefined policy |
| Environment | Often the active workspace | Prefer an isolated workspace or remote sandbox |
| Recovery | User can restart or redirect | Checkpoint, retry, and report |
| Output | Incremental interaction | Reviewable result and evidence |
Some tasks sit between these modes. A run that keeps the user waiting for several minutes while also lacking background durability provides a poor experience. The system should either maintain a responsive feedback loop or make the work safely asynchronous.
Route Tasks Instead Of Using One Setting For Everything
Section titled “Route Tasks Instead Of Using One Setting For Everything”Model and effort selection can be manual or automatic.
Manual routing gives the user direct control:
- use a fast, economical model for routine edits
- use a stronger or higher-effort model for ambiguous architecture work
- move a long task to a background agent
- ask one model to plan and another to execute
Automatic routing classifies the request and selects a model or effort level. A useful router may consider:
- expected number of files and tools
- ambiguity in the request
- need for planning or deep repository exploration
- risk of changing shared interfaces
- available latency and cost budget
- whether the user is waiting
- whether a reliable verifier exists
Routing is itself a prediction and can be wrong. Track the selected route, allow overrides, and measure outcomes separately for each route.
As of July 29, 2026, Cursor’s Auto mode uses Cursor Router with cost, balance, and intelligence preferences. This is one product implementation of the broader pattern. The available models, routing rules, and prices can change quickly, so current product decisions should be checked against Cursor’s official documentation.
Capability, Latency, And Cost Form A Tradeoff
Section titled “Capability, Latency, And Cost Form A Tradeoff”A faster agent is not useful if its failure rate creates more work. A highly capable run may also be wasteful when a simple task has a cheap and reliable solution.
Evaluate at least three dimensions:
- Capability: How often does the agent produce an acceptable result?
- Latency: How long does that result take?
- Cost: How much model and infrastructure usage does it require?
These dimensions form a tradeoff surface rather than one universal ranking.
flowchart LR
Q["Task characteristics"] --> R{"Select operating point"}
R --> F["Fast and economical"]
R --> B["Balanced"]
R --> H["Higher capability or effort"]
F --> E["Measure verified outcome"]
B --> E
H --> E
E --> U["Update routing policy"]
For repeated work, compare cost per successful task, not cost per request:
cost per successful task = total model and environment cost -------------------------------- number of accepted resultsA cheap run followed by two retries and a manual repair may cost more than a stronger first attempt.
Train And Evaluate Efficient Agent Behavior
Section titled “Train And Evaluate Efficient Agent Behavior”Model behavior influences how long the loop takes. Training or prompt optimization can encourage an agent to:
- search before editing
- collect independent evidence in parallel
- avoid reopening unchanged files
- choose a precise tool instead of a long workaround
- run focused tests before a full suite
- stop when the task is complete
- avoid unsupported claims and unnecessary narration
Efficiency rewards require care. Directly rewarding fewer tokens or fewer tool calls can teach the model to skip necessary investigation and testing.
A safer evaluation order is:
- verify that the result is correct
- verify that required constraints were followed
- compare latency, cost, tokens, and tool use among acceptable results
flowchart TD
R["Completed rollout"] --> C{"Correct?"}
C -- "No" --> X["Reject or assign failure reward"]
C -- "Yes" --> P{"Policy and safety constraints met?"}
P -- "No" --> X
P -- "Yes" --> E["Measure latency, cost,<br/>tokens, and tool trajectory"]
E --> S["Prefer efficient successful behavior"]
This prevents a fast incorrect answer from outranking a slower correct one merely because it used fewer resources.
The Tool Contract Affects Performance
Section titled “The Tool Contract Affects Performance”An agent works more efficiently when its tools have:
- clear names and descriptions
- stable argument schemas
- concise, structured results
- actionable error messages
- predictable permissions and timeouts
- behavior similar to what the model saw during training or evaluation
For example, semantic code search may locate a concept even when the query does not match an exact identifier. Plain text search is often faster and more precise when the identifier is already known. A capable agent should learn when each tool is appropriate.
Changing a schema, response format, or error convention can lengthen trajectories even if the underlying tool still works. The agent may send invalid arguments, misread results, or fall back to less efficient operations.
The related training requirement is covered in Training-Production Parity.
Measure The Whole Workflow
Section titled “Measure The Whole Workflow”Collect distributions, not only averages. A mean can hide the small number of very slow runs that dominate user frustration and infrastructure cost.
| Area | Useful measurements |
|---|---|
| Outcome | task success, tests passed, reviewer acceptance, regression rate |
| End-to-end time | p50, p95, and p99 time to verified result |
| Model | time to first token, generation rate, tokens, model turns |
| Tools | calls by tool, error rate, p50/p95 latency, bytes returned |
| Trajectory | serial depth, parallel fan-out, repeated reads, retries |
| Environment | queue time, startup time, command time, reset failures |
| Verification | test time, verifier failures, post-agent repair time |
| Economics | cost per run, cost per accepted result, compute utilization |
Segment the data by task type and difficulty. A repository explanation, a one-line bug fix, and a multi-service migration should not share one latency target.
Also inspect traces. A metric can show that a run was slow; the trace shows whether it waited for infrastructure, chose a poor tool sequence, or repeatedly repaired its own edits.
Composer As A Current Case Study
Section titled “Composer As A Current Case Study”The source talk described the first Cursor Composer model released in October 2025. That version used reinforcement learning in realistic coding environments and emphasized fast interactive work, production search and editing tools, parallel tool use, and end-to-end software-engineering evaluations.
The product has advanced since the talk:
- Composer 2’s technical report describes continued pretraining followed by large-scale RL in the production-equivalent Cursor harness.
- The report evaluates completion tokens, end-to-end latency, inference cost, and correctness rather than treating token generation speed as the only efficiency measure.
- Composer 2.5 is the current Composer release as of July 29, 2026. Cursor describes it as suitable for both interactive sessions and long-running tasks, with adaptive effort based on task complexity.
- Composer 2.5 is based on Moonshot’s Kimi K2.5 checkpoint. Cursor currently lists standard and fast variants with different latency and token prices.
The original claims that Composer was four times faster than similarly capable models and that a particular custom kernel achieved a specific speedup belong to the 2025 release context. They should not be carried forward as timeless comparisons.
A Practical Design Sequence
Section titled “A Practical Design Sequence”For a latency-sensitive agent workflow:
- Define what counts as a verified result.
- Choose foreground or background execution.
- Set latency, cost, turn, and tool budgets.
- Map the expected dependency graph.
- Parallelize only independent, bounded operations.
- Give the agent concise and stable tool contracts.
- Preserve an easy path for clarification or safe suspension.
- Record the full trajectory and environment timings.
- Compare routes using success, latency, and cost together.
- Revisit the policy as models, tools, and user behavior change.
Common Mistakes
Section titled “Common Mistakes”Optimizing tokens per second in isolation
Section titled “Optimizing tokens per second in isolation”The model becomes faster while environment startup, serial tools, or retries remain the actual bottleneck.
Rewarding fewer tool calls without a correctness gate
Section titled “Rewarding fewer tool calls without a correctness gate”The model learns to inspect less evidence or skip verification.
Parallelizing dependent edits
Section titled “Parallelizing dependent edits”The apparent speedup is lost during conflict resolution and retesting.
Sending every task to the strongest model
Section titled “Sending every task to the strongest model”Routine work becomes slower and more expensive without a corresponding increase in accepted results.
Sending every task to the fastest model
Section titled “Sending every task to the fastest model”Complex work requires retries, escalation, or extensive human repair.
Reporting only average latency
Section titled “Reporting only average latency”Long-tail stalls remain invisible even though users and infrastructure absorb their cost.
Summary
Section titled “Summary”- Coding-agent latency comes from the complete model, tool, environment, and verification loop.
- Time to a verified result is more useful than tokens per second for evaluating real coding work.
- Efficient trajectories use the right tools, avoid repeated work, and parallelize independent operations.
- Foreground and background agents need different feedback, isolation, and recovery behavior.
- Route tasks using capability, latency, cost, risk, and user availability.
- Apply efficiency preferences only after correctness and policy constraints are satisfied.
- Measure latency distributions, trajectory shape, tool behavior, success, and cost together.
References
Section titled “References”- Source talk: Building Cursor Composer - Lee Robinson, Cursor
- Cursor: Building a Fast Frontier Model with RL
- Cursor Composer 2 Technical Report
- Current Cursor Composer overview
- Cursor changelog and Router announcement
- Parallel Coding Agents for Large Refactors
- Evaluating Coding Agents
- RL Environments for LLM Agents