[Task][AI Proxy] Make AI retries aware of execution ambiguity, Retry-After and attempt costs
Context and proposal
AiProxyRetryPolicy retries 429/5xx and selected transport failures before output emission. A response-header timeout or connection failure does not prove the provider did not execute or bill the request. Non-streaming retries use exponential delay and streaming retries are immediate; Retry-After and jitter are not currently integrated.
Define configurable replay policy by failure stage, operation and provider idempotency support. Preserve the prohibition on switching after output emission. Respect bounded Retry-After, add capped jittered backoff, and account for all attempts under a shared deadline. Distinguish replayable inference from operations with tools or other side effects without assuming a gateway can infer arbitrary application idempotency.
Acceptance: tests exercise ambiguous execution, 429 hints, retry/fallback limits, cancellation during delay and committed responses. Emit attempt identity and reason for metering; do not claim pre-output retry guarantees exactly-once execution.
Related: #7384, #7931, #7955, #7021. Own retry policy integration, not a second metering implementation.
Reviewed source
Baseline: 127aa7ad9 (2.7.3-SNAPSHOT).
/assign