Agent Engineering · Measurement
Local Coding Agents: How to Measure Harness Overhead and Compare Models

A local coding agent can appear slow before it reads a single file. The delay may come from the model, but it may also come from the harness overhead: prompt assembly, tool-schema serialization, process startup, safety checks, and retries. This guide separates those costs so model comparisons remain meaningful.
The practical question
Suppose an agent receives a small repository and a task such as “find the configuration entry for the HTTP timeout.” You press Enter, then wait two or three minutes before the agent opens its first file. That elapsed time is an observation, not an explanation.
The wait can include at least four different phases:
- the launcher starting the local runtime;
- the harness constructing the system prompt and tool definitions;
- the model generating its first response or tool request;
- the tool executor performing the first filesystem operation.
If these phases are reported as one number, a faster model can look slower because it is paired with a heavier harness. The purpose of this article is to measure the phases separately, not to declare a universal winner.
What to measure
1. Time to first response
Time to first response (TTFR) is the interval from the user action that starts an agent run to the first observable model output. Define the endpoint before testing. Possible endpoints include the first streamed token, the complete first assistant message, or the first tool-call request. These are different measurements and should not be mixed.
2. Time to first tool call
For coding agents, the first tool-call request is often more useful than the first visible token. It answers: “How long until the agent attempts to inspect or change the workspace?” Record the timestamp when the harness receives a valid tool invocation, not when the tool finishes.
3. Tool-schema overhead
A model usually receives a description of every available tool. This tool schema can contain names, parameter types, required fields, constraints, and long descriptions. Measure its serialized size separately from the rest of the prompt. Depending on the runtime, the schema may contribute to input-token processing, memory use, and the model’s decision space.
4. Recovery after a denied tool call
A realistic harness sometimes refuses a request: a path is outside the workspace, a command needs confirmation, or a policy blocks an operation. Measure how the agent behaves after a denied tool call. The useful outcome is not merely whether it eventually succeeds. Record whether it understands the denial, changes strategy, repeats the same request, or stops.
5. Task outcome
Latency without outcome is incomplete. Record whether the agent found the requested file, made the requested change, passed the agreed verification command, and avoided unrelated modifications. A shorter run that fails the task is not automatically better.
A minimal test design
Use one fixed repository, one fixed task, one fixed tool inventory, and one fixed runtime configuration. Change only the model when comparing models. If the harness must change because a model requires a different adapter, document that as part of the result.
A useful three-part benchmark contains:
- Cold start: launch the agent process and run the task without warming caches.
- Warm start: repeat the same task after the process and model files are already loaded.
- Denied-call recovery: inject one controlled denial during the task and measure the next response.
Run each case more than once. Do not report a single run as a stable performance characteristic. If you cannot perform repeated trials, label the result as an observation rather than a benchmark.
Prepare a controlled workspace
Make the task small enough to inspect manually but realistic enough to exercise the harness. For example, create a repository containing a source file, a configuration file, a test, and a short README. The exact repository is less important than keeping it unchanged across runs.
mkdir -p agent-bench/src agent-bench/tests
cd agent-bench
printf '%s\n' \
'[server]' \
'request_timeout_ms = 1500' \
> config.toml
printf '%s\n' \
'def request_timeout_ms(config):' \
' return config["server"]["request_timeout_ms"]' \
> src/settings.py
printf '%s\n' \
'from src.settings import request_timeout_ms' \
'' \
'def test_timeout(config):' \
' assert request_timeout_ms(config) == 1500' \
> tests/test_settings.py
The commands above are an example fixture, not a verified result from a particular agent. If your harness automatically adds files, ignores untracked files, or uses a different working-directory rule, record that before testing.
Instrument the harness, not just the terminal
Wall-clock timing from a human observer is too coarse for phase analysis. Add structured events at the boundaries that matter. JSON Lines, or JSONL, is convenient because each event can be appended without rewriting previous records.
{"event":"run_started","ts_ns":0}
{"event":"prompt_built","ts_ns":0,"prompt_bytes":0,"tool_schema_bytes":0}
{"event":"request_sent","ts_ns":0}
{"event":"first_output","ts_ns":0}
{"event":"first_tool_call","ts_ns":0,"tool":"read_file"}
{"event":"tool_denied","ts_ns":0,"reason":"outside_workspace"}
{"event":"recovery_output","ts_ns":0}
{"event":"run_finished","ts_ns":0,"status":"success"}
Replace the zero values with timestamps from a monotonic clock. A monotonic clock is required for elapsed durations because wall time can change during a run. Preserve the raw event log and derive summary values from it later.
Recommended event boundaries
| Event | Meaning | Why it matters |
|---|---|---|
run_started |
The user action has reached the launcher. | Defines the start of end-to-end latency. |
prompt_built |
System prompt, conversation, and tool schema are assembled. | Separates harness preparation from model work. |
request_sent |
The request is handed to the local model runtime. | Marks the model-facing interval. |
first_output |
The first model output is received. | Supports TTFR. |
first_tool_call |
A parsed tool invocation is ready for execution. | Measures time until action. |
tool_denied |
The executor refuses a controlled request. | Starts the recovery interval. |
recovery_output |
The next assistant response after the denial is received. | Measures recovery latency and behavior. |
Calculate the intervals
Derive values from event timestamps rather than recording rounded values by hand.
ttfr_ms = (first_output - run_started) / 1_000_000
time_to_first_tool_ms = (first_tool_call - run_started) / 1_000_000
prompt_build_ms = (request_sent - run_started) / 1_000_000
model_to_first_output_ms = (first_output - request_sent) / 1_000_000
recovery_ms = (recovery_output - tool_denied) / 1_000_000
These equations are only valid if all events use the same monotonic clock and the event order is unambiguous. If streaming is buffered by a client library, first_output may represent the buffer flush rather than the model’s actual first token. Document that limitation.
For a repeated test, report a distribution rather than only an average. The median shows a typical run; a high percentile shows how bad a slow run can be. Keep the raw samples so another reader can recompute the summary.
Measure tool-schema overhead directly
Count the serialized tool definition before it enters the request. Record at least byte length and, when your tokenizer is available, token count. A byte count is portable; a token count is closer to model-processing cost but depends on the tokenizer.
# Example inspection commands; adapt paths to your harness.
wc -c tools.json
wc -l tools.json
sha256sum tools.json
Compare two configurations with the same task and model:
- Minimal inventory: expose only the tools needed for the task.
- Full inventory: expose the normal production tool set.
The difference between the two runs is evidence about the combined effect of tool inventory and prompt construction. It is not, by itself, proof that every additional schema token causes a fixed amount of delay. Local runtimes can batch, cache, or process input differently.
Keep descriptions stable
Tool descriptions are part of the input. Avoid changing wording between model runs unless wording itself is the variable under test. A short, precise schema may improve both latency and tool selection, but that is a separate experiment from comparing model weights.
Design a controlled denied-call test
Recovery should be tested with a denial that is deterministic and safe. For example, configure the executor to reject a request for a path outside the benchmark workspace. Do not test by giving an agent access to real credentials, private directories, or destructive commands.
The denial response should be explicit and machine-readable where possible:
{
"ok": false,
"error": {
"type": "permission_denied",
"message": "The requested path is outside the workspace.",
"retryable": false
}
}
Then observe the next model action. A useful recovery rubric is:
- Understands: acknowledges the constraint or changes the target to an allowed path.
- Adapts: chooses a viable alternative, such as listing the workspace or asking for clarification.
- Loops: repeats the denied request without a meaningful change.
- Stops safely: reports that it cannot continue and does not attempt an unsafe workaround.
Record both the latency and the category. A fast repeated denial is not successful recovery; a slower but correct adaptation may be the better operational behavior.
Compare models fairly
A fair model comparison changes as few variables as possible. Freeze the following:
- hardware, power mode, and thermal conditions;
- model file, quantization, context length, and runtime version;
- system prompt, task prompt, tool schemas, and conversation history;
- repository contents and working directory;
- sampling settings and stop conditions;
- measurement clock and event definitions.
If a model needs a different context limit or adapter, do not hide that difference. Present it as a configuration difference and avoid attributing every observed change to the model alone.
Use paired runs
Alternate models instead of running all trials for one model first. For example, run A, B, B, A, then repeat the sequence. This reduces the risk that temperature, background load, or an accidentally warmed cache belongs to only one model.
Separate capability from latency
Evaluate task correctness independently from timing. A model that needs one extra inspection call may have higher time-to-completion but better accuracy. Include tool-call count, files touched, verification status, and final answer quality alongside latency.
Example result format
The following table is a reporting template, not measured data.
| Run | Model | Start | First output | First tool | Recovery | Outcome |
|---|---|---|---|---|---|---|
| 1 | Model A | recorded value | recorded value | recorded value | recorded value | pass/fail |
| 2 | Model B | recorded value | recorded value | recorded value | recorded value | pass/fail |
A concise conclusion should state what was measured and what was not. For example: “With the same fixture and tool inventory, Model A had a lower median time to first tool call in the recorded trials. The test did not measure throughput, long-context quality, or performance on other hardware.”
Failure cases and misleading measurements
Counting launcher time as model latency
If the launcher initializes a runtime, loads a model, discovers tools, and then sends a request, TTFR includes all of those operations. That is valid for an end-user experience measurement, but it is not a pure model-latency measurement. Report both end-to-end TTFR and the interval after request_sent when possible.
Comparing cold and warm runs
A cold run may include disk reads and memory mapping that a warm run avoids. Mixing them produces a misleading average. Label cache state explicitly.
Changing tool descriptions between tests
A shorter schema can change tool selection and reasoning behavior, not just input size. Treat schema reduction as its own experimental variable.
Using different output endpoints
“First token,” “first complete sentence,” and “first parsed tool call” are not interchangeable. Choose one endpoint for each metric and name it in the report.
Ignoring retries
A client may retry timeouts or malformed tool calls automatically. Include retry count and retry delay in the event log. Otherwise, a harness can look like a slow model.
Letting background work run
Indexers, updates, compilation, and browser tabs can affect a local machine. You do not need a perfectly idle system, but you do need to record relevant background activity and keep it comparable across runs.
Verification checklist
Before publishing a result, verify that:
- the raw event log exists for every reported run;
- timestamps use one monotonic clock;
- the first-output and first-tool endpoints are defined;
- tool-schema size was measured from the actual serialized request;
- cold and warm runs are labeled separately;
- the denied-call response was deterministic and safe;
- recovery behavior was classified, not just timed;
- model, runtime, hardware, and configuration details are recorded;
- task correctness was checked independently of latency;
- no credentials, private paths, or personal data appear in logs.
Limitations
This protocol measures the behavior of a complete local agent setup. It cannot isolate every internal operation of a model runtime, operating system, tokenizer, or accelerator. Results can change with driver versions, memory pressure, quantization, context length, filesystem state, and prompt wording.
The protocol also does not establish general intelligence, coding quality, or production safety from a small fixture. It is a way to explain a specific wait and make a narrowly scoped comparison reproducible.
Conclusion
When a local coding agent spends minutes before opening its first file, treat the delay as a pipeline to decompose. Measure launcher and prompt construction separately from model response time; count the tool schema; record the first parsed tool call; and test what happens after a controlled denial. Then compare models under the same harness, task, runtime, and cache conditions.
The most useful result is not a single “fastest model” label. It is an evidence-bounded profile showing where time is spent, whether the agent completes the task, and whether it recovers safely when the environment refuses an action.