In-depth practical guides

Measure useful AI-agent latency

Time complete tasks, retain failures and separate apparent speed from accepted results.

Updated :

Testing workstation and stop button. Illustrative scene.

AI-generated illustration

When does the result become usable?

The first fragment, generation completion and human acceptance are different events. Define useful start and end points, then record completed trial durations. Keep failures and timeouts separate so the report is not limited to successful trials.

  1. Define boundaries

    Specify request sent, first content, tools completed, output ready or review finished. Use a duration-appropriate clock. Do not subtract clocks on different machines without known synchronisation.

  2. Fix the scenario

    Keep input, instructions, version, permissions and cache state. Separate first and repeated calls. Record external-tool time rather than attributing everything to the model.

  3. Retain failed trials

    Record durations, attempts, retries and timeouts. Publish count and distribution, not just the best result. An abandoned task remains visible even without a completion duration.

  4. Compare accepted quality

    Apply the same acceptance criterion. Count corrections and review time. Fast invalid output is not useful time saved; state human effort.

  5. Document the summary rule

    The 95th percentile is the value at the rounded-up rank of 0.95 × completed-task count. For an even count the median averages the two middle values. No duration is imputed to failures. Duration statistics cover completed tasks only. Percentiles from small samples are fragile; these numbers guarantee neither future latency nor output quality.

Reading workshop

Eight durations do not describe ten requests

Separate the distribution of completed tasks from the outcome of all requests. These invented figures are teaching data, not a benchmark.

Fictional data and records for learning: none of these results comes from a live service query.

A fast median with two timeouts

Ten independent requests use the same measurement boundaries. Eight tasks finish in 2, 3, 4, 5, 6, 7, 8 and 40 seconds. Two others exceed a 30-second limit and are stopped. “Completed” does not yet mean “accepted after a quality check”.

If the table exceeds the screen, scroll horizontally; arrow keys work when the region is focused.

A fast median with two timeouts
MetricPopulationCalculationPermitted reading
Completion share10 requests8 / 10 = 80%Keep both timeouts in the outcome report.
Median8 completed durations(5 + 6) / 2 = 5.5 sThe middle of completed durations does not describe timeouts.
Nearest-rank P958 sorted completed durationsrank = ceil(0.95 × 8) = 8; value = 40 sNo interpolation; fragile with only eight durations.
Timeouts2 requests stopped at 30 s2 / 10 = 20%Their completion times are unknown, not 0 or 30 s.

Summarise durations without hiding unfinished trials

One duration per line in seconds, from 0 to 86400, at most four decimal places; decimal point or comma. Blank lines ignored. Up to 200 durations and 10000 unfinished trials; at least one trial in total.

Results for the supplied values

Completed trials
8
Unfinished trials
2
Share of completed trials (%)
80.00
Median of completed durations (s)
5.50
95th percentile of completed durations (s)
40.00
Rank selected for the 95th percentile
8

Sort durations; take the average of the two central values for an even sample. For the 95th percentile, rank = ceiling of 0.95 × completed count, starting at 1. No duration is imputed to unfinished trials. Without completed durations, median and percentile remain undefined.

Calculation on your values, without automatic timing. Completed does not mean accepted: record quality separately. A small sample does not guarantee future latency; percentile methods can differ.

Which report preserves useful information without inventing a duration?

Open each proposition to compare its diagnosis. More checks may still be needed.

Median 5.5 s, so all ten requests are fast

The median covers only eight completed tasks. It describes neither the interruptions nor output quality.

8/10 completed; median 5.5 s and P95 40 s for those eight durations

Yes. Add both 30-second timeouts and the measurement boundaries. Assess the share of accepted results separately.

Add two values of 30 s to the completed durations

Here 30 s is a stopping limit, not an observed completion time. Imputation changes the population and the meaning of the statistic.

Fictional measurement record

Requests: 10; completed tasks: 8
Completed durations (s): 2, 3, 4, 5, 6, 7, 8, 40
Timeouts: 2; limit: 30 s
Median: 5.5 s; nearest-rank P95: 40 s
Clock: monotonic; shared origin for both boundaries
Quality acceptance: assessed separately

The P95 rule selects the observation at the rank rounded up from 0.95 × n. For even n, the median averages the middle two values. No successful duration is imputed to failures.

Documentation of the rules, separate from fictional examples

Compare other situations and exercises

A two-second response

Fictional example: first text at 2 s, tools done at 12 s, acceptance at 90 s. Publish separate stages instead of a two-second completed-task claim.

Timeouts excluded from the mean

Illustrative trial: 9 successes and 1 timeout. Successful durations alone do not describe all ten requests. Publish success rate and exclusions.

A quick retry hides a long wait

Fictional case: the first attempt times out after 30 seconds; a second produces an accepted result in 8 seconds, with no delay between attempts. The journey took 38 seconds. Reporting only the successful 8 seconds hides the retry cost. Keep a common request identifier across attempts and record waiting, execution and validation separately. Compare journeys governed by the same retry rule.

From observation to decision

Nine successful tasks and one timeout to retain

Ten tasks start with a 30 s limit. Nine accepted results take the sorted durations 1, 2, 2, 3, 3, 4, 5, 8 and 20 s; the last task times out without acceptance. All durations use the same measurement boundaries.

Fictional learning case: counts and dates illustrate the method and do not describe a real assignment.

The mean does not show the slow case

Scale from 0 to 25 seconds. Nine successes only; one timeout remains outside these durations.

  • Median3 s
  • Mean5.33 s
  • 95th percentile · rounded-up rank20 s
Case reading grid
ObservationUseful checkNext action
Nine successful tasksSum: 48 s; mean: 48 / 9 ≈ 5.33 s.State that this mean excludes the timeout.
Successful-task medianThe fifth sorted value is 3 s.Describe the centre without hiding the 20 s result.
Successful-task 95th percentileRounded-up rank of 0.95 × 9: 9; value: 20 s.State the rank convention and very small count.
One timeout at 30 s9 successes in 10 attempts, or 90%.Retain the stopping time as a trial observation, not a success duration.
Your decision — Can the timeout be replaced by 30 s in the mean?

Explained answer

Elapsed time before stopping can be described if the measure and denominator are explicitly renamed. It does not give time needed to succeed. Do not combine time to stopping and time to accepted output under a success-time label.

Reading convention: rounded-up-rank percentile, corresponding to type 1 in this case. Durations are fictional. R — Sample Quantiles, type 1

Worked exercise

A fast median with two failures

Fictional example: the values and documents teach the method and do not describe a real organisation.

The six requests are comparable. Success requires a validated result; timeouts provide none.

If the table exceeds the screen, scroll horizontally; arrow keys work when the region is focused.

Starting information
ItemDuration in secondsOutcome
12Success
24Success
36Success
48Success
530Timeout
630Timeout

Your checks

  1. Calculate successful-run median and mean.
  2. Report success across all requests.
  3. Keep timeouts separate from completed durations.
Read the answer

Answer and decision

Successful mean and median are 5 seconds. Success is 4/6, about 66.67%. This conditional duration does not describe six successful tasks. Report both 30-second timeouts; do not recast them as slow successes to manufacture a completion mean.

If the case changes

If a retry succeeds, count initial requests and attempts separately and state the total time experienced by the requester.

Record to retain

Keep start, validated end or timeout, attempt count and exclusion rule.

Record to retain

  • Timing boundaries and units
  • Versions, input and cache state
  • Durations, failures and retries
  • Quality criterion and human time

Official references

Related protocols

Checks before reaching a conclusion

  • Are boundaries identical?
  • Is cache state recorded?
  • Are failures visible?
  • Is quality judged consistently?

Stage timings linked to quality, failures and acceptance effort.

Frequently asked questions

Should first content be timed?

Yes for perceived responsiveness. Also retain task completion and acceptance to distinguish first display from useful output.

Are two means enough?

They hide variation and failures. Include trial count, conditions, median or distribution and accepted-result rate. State calculation rules.

Should cached and uncached trials be combined?

Report them separately when caching changes execution conditions. State what was reused, which steps actually ran and the expected result. An already available answer and a fully computed task do not describe the same journey.

TOOLS / REGISTERS

Information to record

Local timing depends on task, load, network and tools. Percentiles from few trials are fragile. Controlled trials are not general availability promises.

  • Access date and time zone
  • Exact URL
  • Task / journey step
  • Version / revision
  • Start and end events
  • Stage durations and unit
  • Failures, timeouts and retries
  • Repetitions and dependence between observations
  • Acceptance criterion
  • Limit / uncertainty
  • Decision / next action
  • Review owner
  • Next review

DOCUMENTED REFERENCE

Retry-After: respect the response without inventing a universal quota

Separate call duration from requested retry delay. RFCs 6585 and 9110 define status and Retry-After, not one quota for every service. Numeric examples below are HTTP documentation examples, not observations of a queried site.

t = 0Retry-After: 120+120 s
Retry-After: respect the response without inventing a universal quota
ReferenceValue or formWhat it identifies
429Too Many RequestsToo many requests in a period. Retry-After may be included, not required; status alone does not disclose window size.
503Service UnavailableService unavailable, for example temporary overload or maintenance. A possible retry guarantees neither restoration time nor success.
Retry-After: 120120 sRFC 9110 example: wait 120 seconds after receipt, or two minutes. Not milliseconds or a quota of 120 calls.
Retry-AfterHTTP-dateThe other form is an HTTP date: a deadline rather than duration. Retain reception time and consider clock reliability.
delay-secondsNon-negative integerDelay form is a non-negative decimal integer. Negative values, fractions or appended units do not match the grammar.
ScopeService-specific limitThe service defines counting and client identification; a limit may concern a resource, account or servers. Status 429 alone does not establish scope.

Implication for the record

Keep status, original header, receipt and attempts. Use bounded retries, separating execution, waiting and collection success. Elapsed time is not automatically computation latency.

Does absent Retry-After allow unlimited immediate retries?

No. It supplies no deadline in this field. Follow service rules and bounded retry policy without inventing a server-mandated delay.

Primary documentation

Documentation consulted on .

DOCUMENTED REFERENCE

Quantiles: record the algorithm before comparing software

R documents nine sample-quantile algorithms, with type 7 as default. The NIST 90-value example interpolates at (n + 1)p. Identical files can therefore produce different quartiles without transcription errors.

Quantiles: record the algorithm before comparing software
ReferenceValue or formWhat it identifies
R quantile9 algorithmsType numbers name conventions, not quality ranks. Retain software, version, method and missing-value policy.
Type 1Inverse empirical CDFInverse empirical CDF, a discontinuous rule selecting an observed value. At 0.5 with even n it can differ from the usual two-centre median.
Type 6h = (n + 1)pTheoretical one-based position, interpolating adjacent observations and using endpoints outside rank bounds.
Type 7h = 1 + (n − 1)pAlternative one-based interpolation position, R quantile() default in consulted documentation, not every spreadsheet’s default.
EndpointsQ(0) = min · Q(1) = maxProbabilities zero and one return sample extremes here, not predictions of future population extremes.
Example Q1429.75 (type 6) · 436.25 (type 7)For all 90 values NIST gives lower quartile 429.75; the type 7 calculation performed here gives 436.25. Retain method labels.

Implication for the record

Ties, small samples and boundary probabilities expose conventions. This reader implements three documented rules and offered probabilities, not all R numerical options or R execution. Round only for display.

Do differing quartiles prove a false file?

No. Compare observations, ordering, missingness and quantile definition first. Equal data with differing conventions create a methodological difference to disclose.

Primary documentation

Documentation consulted on .

DOCUMENTED REFERENCE

Measure duration without mixing clocks

A date locates an event; a monotonic clock measures an interval. The High Resolution Time Working Draft of 1 September 2026 distinguishes these uses and execution contexts’ own origins.

Measure duration without mixing clocks
ReferenceValue or formWhat it identifies
performance.now()relative · monotonicperformance.now() returns time relative to the context origin on a monotonic clock. Time a task within that context by subtracting two readings of the same clock.
Date.now()wall clockDate.now() describes wall time. System clock corrections can change this reference; differences do not have the same monotonic duration contract.
timeOrigincontext origintimeOrigin locates the context origin, such as window navigation or worker creation. Relative values from different contexts need not share the same zero.
DURATIONsame clockDefine start, finish and failure handling before measuring. Correct timing does not fix a sample excluding timeouts or stopping at the first token instead of the useful result.
PRECISIONcoarsenedExposed precision may be reduced for security. Equal readings do not prove zero cost; many decimals guarantee neither accuracy nor comparability.
CROSS-CONTEXTorigin + relative timeAdding the matching origin can translate times between compatible communicating contexts. It does not synchronize two machines or remove distributed network delays.

Implication for the record

The cited rules belong to a dated draft. Retain API, context and protocol; do not directly subtract browser relative time and server date.

Is it possible to compare worker and window times?

Yes when each time is translated to a compatible reference with its own timeOrigin. Simply subtracting performance.now() from distinct contexts can mislead.

Primary documentation

Documentation consulted on .