Documentation / guides
Attempt metadata
Interpret retry establishment counts without treating them as token attempts.
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
}
| Value | Meaning |
|---|---|
0 | Serving client does not count attempts |
1 | First attempt succeeded |
>1 | Retries 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
- Source:
inference/client.go,inference/stream/result.go - Tests:
inference/stream/stream_test.go,inference/retry/invoke_test.go
Related: Terminal stream results, Responses.