feat: expose Gemini RetryInfo retry_delay() on VertexApiError and Error #19
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
src/types/error.rs,VertexApiError.detailsis currently typed asOption<Vec<ErrorType>>, whereErrorType(#[serde(tag = "@type")]) only defines three variants (ErrorInfo,Help,BadRequest). When Vertex AI returns a429 RESOURCE_EXHAUSTEDresponse whoseerror.detailsarray includes a{"@type": "type.googleapis.com/google.rpc.RetryInfo", "retryDelay": "37s"}entry (or any othergoogle.rpc.*detail type),serde_json::from_str::<VertexErrorResponse>(&body)fails to deserializeErrorTypeand falls back toError::HttpStatus { status, body }.agent-rig'sError::ProviderTransient { message, retry_after }anddevrel-pr-reviewer'sVertexModel) needError::retry_delay(&self) -> Option<Duration>andVertexApiError::retry_delay(&self) -> Option<Duration>to extract the server-suppliedretryDelayhint, matchingandreban/geologia#25(69e4108).Proposed Changes (porting
andreban/geologia@69e4108)src/types/error.rs:VertexApiError.detailstoOption<Vec<serde_json::Value>>(or add aRetryInfovariant plus an#[serde(other)]fallback onErrorTypeso unknown detail types never breakVertexApiErrordeserialization).pub fn retry_delay(&self) -> Option<std::time::Duration>onVertexApiErrorthat searchesself.detailsfor an entry with@typeequal to"google.rpc.RetryInfo"or ending with"/google.rpc.RetryInfo", reads"retryDelay"(or"retry_delay"), and parses the protobuf duration string ("<secs>s"or"<secs>.<nanos>s").src/error.rs:pub fn retry_delay(&self) -> Option<std::time::Duration>ongemini_rs::error::ErrordelegatingError::VertexError(e) => e.retry_delay()and returningNonefor other variants.andreban/geologia@69e4108covering integer and fractionalretryDelayvalues ("37s","1.5s"), multipledetailsentries, malformed durations, andError::retry_delay()delegation.