AI coding agents can write code, inspect files, run commands, analyze errors, and modify an application with limited developer input. This makes them useful for repetitive development work, but every additional action consumes compute.
The important question is not simply how much an AI coding agent costs per request. Developers should also understand how much compute is used on actions that do not directly contribute to the final result.
An agent may spend time reading unnecessary files, repeating tool calls, generating intermediate responses, or retrying failed operations. Measuring these activities can help teams build more efficient AI-assisted development workflows.
What Does "Wasted Compute" Mean?
Wasted compute does not necessarily mean that the agent made a mistake.
It can include work that produces little or no useful value for the final task.
For example:
Developer Request
|
v
AI Coding Agent
|
+-- Reads relevant files
|
+-- Reads unrelated files
|
+-- Runs tests
|
+-- Repeats a search
|
+-- Fixes an error
|
v
Final CodeThe relevant file search and successful test execution contribute directly to the task.
Repeated searches or unnecessary context may not.
The goal is therefore to measure where compute is being spent rather than assuming every operation is useful.
Where Does an AI Coding Agent Use Compute?
An AI coding agent can consume compute in several areas.
Model Inference
Every model request requires computation.
An agent may make multiple model calls during one task:
Request
|
+-- Planning
|
+-- Code analysis
|
+-- Tool decision
|
+-- Error analysis
|
+-- Final responseOne developer request can therefore result in several inference steps.
Repository Analysis
The agent may inspect:
Source files
Configuration
Tests
Dependencies
Documentation
Build files
The larger the repository, the more information may need to be processed.
Tool Execution
Coding agents can use tools to:
Search files
Run tests
Build projects
Execute commands
Inspect Git changes
Analyze compiler errors
These operations consume local or remote compute.
Repeated Attempts
An agent may run a command, receive an error, modify the code, and run the command again.
Some retries are necessary.
Others may indicate that the agent does not have enough information to make a good decision.
Measure Agent Steps
A useful first metric is the number of steps required to complete a task.
For example:
Task | Agent Steps | Successful |
|---|---|---|
Rename API method | 4 | Yes |
Add validation | 8 | Yes |
Fix failing test | 15 | Yes |
Refactor module | 28 | Yes |
The number of steps alone does not prove inefficiency.
A complex refactoring task naturally requires more work.
It becomes useful when comparing similar tasks.
If two similar requests require four steps in one workflow and 20 in another, the difference deserves investigation.
Measure Tool Calls
Tool calls are often easier to measure than raw compute.
Consider:
File Search: 12
File Reads: 25
Builds: 4
Test Runs: 6
Git Operations: 3Now ask:
Which operations were necessary?
Which operations were repeated?
Which operations returned useful information?For example, six test runs may be reasonable when fixing a complex issue.
However, repeatedly running the entire test suite after a small change may be inefficient if a focused test would provide the same feedback.
Track Repeated Operations
Repeated operations are one useful signal.
Suppose an agent performs:
Search: CustomerService
Search: CustomerService
Search: CustomerService
Search: CustomerServiceIf the search results are unchanged, the repeated work may not provide additional value.
A simple telemetry record could look like:
public sealed record AgentStep(
string Tool,
string Operation,
long DurationMs,
bool Succeeded);The application can then analyze how often the same operation occurs during a run.
Measure Context Size
AI coding agents often need repository context.
Consider an agent working on one C# class.
It might need:
CustomerService.cs
Customer.cs
CustomerRepository.cs
CustomerTests.csBut if it starts loading hundreds of unrelated files, the amount of information being processed increases.
Track metrics such as:
Files inspected
Lines inspected
Tokens sent to the model
Tool results returnedA useful question is:
How much repository context was required to complete the task?
Not All Large Context Is Waste
Large context is not automatically inefficient.
A complex architectural change may genuinely require understanding many files.
For example:
Authentication change
|
+-- API
+-- Middleware
+-- Configuration
+-- Database
+-- TestsTrying to reduce context too aggressively could actually make the agent less accurate.
The goal is not minimum context.
The goal is relevant context.
Separate Useful and Unsuccessful Compute
A better measurement model separates successful work from unsuccessful work.
For example:
Total tool calls: 30
Successful calls: 24
Failed calls: 6
Repeated calls: 4This provides more information than simply saying the agent used 30 tool calls.
You can calculate a simple efficiency metric:
Useful Step Ratio
=
Successful Useful Steps / Total StepsFor example:
24 / 30 = 80%This should be treated as an internal engineering metric, not a universal measure of AI quality.
Track Failed Builds and Tests
Build and test failures can be particularly useful signals.
For example:
Build 1 - Failed
Build 2 - Failed
Build 3 - PassedThe failures may be completely justified during debugging.
But if similar tasks consistently require many failed attempts, developers should investigate why.
Potential causes include:
Incomplete repository context
Poor tool instructions
Ambiguous requirements
Large unrelated context
Weak test feedback
Agent configuration problems
Compare Similar Tasks
Benchmarking becomes more useful when tasks are controlled.
For example, create a test set containing:
Task A - Add a validation rule
Task B - Fix a null reference
Task C - Add a unit test
Task D - Rename a method
Task E - Update an API endpointRun each task multiple times and record:
Metric | What It Shows |
|---|---|
Model calls | Inference activity |
Tool calls | Agent interaction |
Files inspected | Repository exploration |
Test runs | Verification effort |
Failed operations | Unsuccessful work |
Duration | Overall execution |
Token usage | Model context and output |
This creates a much better picture than testing one large task.
A Simple Agent Efficiency Record
A production or internal benchmarking system can store information like:
public sealed record AgentRunMetrics(
string TaskId,
int ModelCalls,
int ToolCalls,
int FailedCalls,
int FilesRead,
int TestRuns,
long InputTokens,
long OutputTokens,
long DurationMs);This can later be used to compare different prompts, models, or agent configurations.
How to Reduce Unnecessary Compute
Give the Agent a Clear Task
A vague request can cause unnecessary exploration.
Instead of:
Improve this application.provide a specific objective:
Add input validation to the CreateOrder method and update its existing unit tests.The second request gives the agent a much smaller search space.
Limit Unnecessary Repository Exploration
If the task is limited to a specific module, make that scope clear.
Use Focused Tests
When possible, run the smallest relevant test set during iteration.
Avoid Repeated Context
If the agent already has the required information, repeatedly retrieving the same content adds little value.
Set Execution Limits
Useful limits include:
Maximum tool calls
Maximum retries
Maximum execution time
Maximum model callsThese limits can prevent runaway workflows.
Common Mistakes
Measuring Only Token Usage
Tokens are important, but local builds, tests, searches, and other tools also consume compute.
Treating Every Retry as Waste
Retries are sometimes necessary.
The useful question is whether the retry contributes to reaching the goal.
Optimizing for the Fewest Steps
A shorter workflow is not automatically better.
A single incorrect action can be worse than several correct steps.
Using Only One Benchmark
Different coding tasks produce very different workloads.
Ignoring Task Complexity
A five-step bug fix and a five-step architectural change are not equivalent workloads.
Best Practices
Measure complete agent runs, not just model requests.
Track model and tool calls separately.
Record failed and repeated operations.
Measure repository exploration.
Track token usage and execution time.
Benchmark representative coding tasks.
Compare similar tasks instead of unrelated workloads.
Use limits to prevent runaway agent execution.
Optimize for useful work, not simply fewer steps.
Review measurements alongside code quality and task success.
Advantages of Measuring Agent Compute
Makes expensive workflows easier to identify.
Helps compare different agent configurations.
Provides data for optimization.
Can reveal unnecessary repository exploration.
Helps with capacity planning.
Makes production agent behavior easier to understand.
Limitations
Compute efficiency alone does not determine whether an AI coding agent is useful.
An agent that uses more compute but consistently produces correct, tested code may be more valuable than a faster agent that requires substantial manual correction.
Therefore, compute should be measured alongside:
Task success
Code quality
Test success
Developer review time
Execution time
Compute usageConclusion
AI coding agents can perform many operations for a single developer request. Model inference, repository analysis, file searches, builds, tests, retries, and tool calls all contribute to the total compute used by the workflow.
The practical way to understand this cost is to measure the complete agent run.
Track model calls, tool calls, context size, failed operations, repeated actions, test runs, execution time, and token usage. Then compare similar tasks to identify patterns.
The objective should not be to make an AI coding agent perform the fewest possible actions. It should perform the right actions with as little unnecessary work as possible.
That distinction is important when moving AI coding agents from experimentation into real development workflows.

Join the conversation! Your thoughts help the community grow.