Retry policy¶
Provider error classes and the retry policy built on them.
One classifier is shared by the gateway (GatewayConfig.retry_policy) and by
the launchers’ direct-mode relay, so both decide the same way. Classification
uses the HTTP status, the structured error.type/error.code fields and a
small set of message patterns seen from real providers. It never changes what
the client receives; it only decides whether the same request is sent again.
- protoverta.error_classes.error_detail(body)[source]¶
Return
(type_or_code, message)from any common provider error shape.
- protoverta.error_classes.classify(status, body=None, *, transport=False, stream_before_output=False)[source]¶
Classify one failed attempt.
transportmarks a connection failure (no HTTP answer);stream_before_outputmarks a stream that failed or ended before producing any output.- Parameters:
- Return type:
Literal[‘rate_limit’, ‘overloaded’, ‘server’, ‘network’, ‘stream_interrupted’, ‘backend_mismatch’, ‘auth’, ‘billing’, ‘model_not_found’, ‘context_length’, ‘content_policy’, ‘invalid_request’, ‘unknown’]
- class protoverta.error_classes.RetryPolicy(enabled=True, max_retries=10, delay_seconds=60.0, jitter=0.2, max_total_seconds=1800.0, retry_classes=frozenset({'backend_mismatch', 'network', 'overloaded', 'rate_limit', 'server', 'stream_interrupted', 'unknown'}), skip_status=frozenset({}), give_up_window_seconds=30.0, random=<built-in method random of Random object>)[source]¶
Bases:
objectHow long to keep resending one request whose provider attempt failed.
Attempts wait
delay_seconds(±jitteras a fraction, at least the provider’sRetry-After) and stop aftermax_retriesretries ormax_total_secondsof waiting.skip_statuskeeps older configs working: those statuses are never retried whatever their class.- Parameters:
enabled (bool)
max_retries (int)
delay_seconds (float)
jitter (float)
max_total_seconds (float)
retry_classes (frozenset[Literal['rate_limit', 'overloaded', 'server', 'network', 'stream_interrupted', 'backend_mismatch', 'auth', 'billing', 'model_not_found', 'context_length', 'content_policy', 'invalid_request', 'unknown']])
give_up_window_seconds (float)