Skip to documentation
Documentation navigation

Documentation navigation

Documentation / guides

Attempt metadata

Interpret retry establishment counts without treating them as token attempts.

developer

Response.Attempts reports how many attempts produced the response when a retrying decorator counts them. It is deliberately a small integer with explicit zero semantics.

Contract

type Response struct {
	// ...
	Attempts int
}
ValueMeaning
0Serving client does not count attempts
1First attempt succeeded
>1Retries were needed before success
response, err := client.Invoke(ctx, request)
if err != nil {
	return err
}
switch {
case response.Attempts == 0:
	// Do not infer retry behavior.
case response.Attempts == 1:
	// First attempt succeeded.
default:
	metrics.RetryCount("inference", response.Attempts-1)
}

Streaming exposes the same concept as stream.StreamResult.Attempts, where it counts establishment attempts before the stream opened. It is not a count of chunks, tool calls, or provider token generations.

Proof

Related: Terminal stream results, Responses.

← back to documentation