@@ -478,7 +478,7 @@ func (e *AntigravityExecutor) Execute(ctx context.Context, auth *cliproxyauth.Au
478478 return resp , statusErr {code : http .StatusNotImplemented , msg : "/responses/compact not supported" }
479479 }
480480 baseModel := thinking .ParseSuffix (req .Model ).ModelName
481- if inCooldown , remaining := antigravityIsInShortCooldown (auth , baseModel , time .Now ()); inCooldown {
481+ if inCooldown , remaining := antigravityIsInShortCooldown (auth , baseModel , time .Now ()); inCooldown && ! antigravityShouldBypassShortCooldown ( ctx , e . cfg ) {
482482 log .Debugf ("antigravity executor: auth %s in short cooldown for model %s (%s remaining), returning 429 to switch auth" , auth .ID , baseModel , remaining )
483483 d := remaining
484484 return resp , statusErr {code : http .StatusTooManyRequests , msg : fmt .Sprintf ("auth in short cooldown, %s remaining" , remaining ), retryAfter : & d }
@@ -680,7 +680,7 @@ attemptLoop:
680680// executeClaudeNonStream performs a claude non-streaming request to the Antigravity API.
681681func (e * AntigravityExecutor ) executeClaudeNonStream (ctx context.Context , auth * cliproxyauth.Auth , req cliproxyexecutor.Request , opts cliproxyexecutor.Options ) (resp cliproxyexecutor.Response , err error ) {
682682 baseModel := thinking .ParseSuffix (req .Model ).ModelName
683- if inCooldown , remaining := antigravityIsInShortCooldown (auth , baseModel , time .Now ()); inCooldown {
683+ if inCooldown , remaining := antigravityIsInShortCooldown (auth , baseModel , time .Now ()); inCooldown && ! antigravityShouldBypassShortCooldown ( ctx , e . cfg ) {
684684 log .Debugf ("antigravity executor: auth %s in short cooldown for model %s (%s remaining), returning 429 to switch auth" , auth .ID , baseModel , remaining )
685685 d := remaining
686686 return resp , statusErr {code : http .StatusTooManyRequests , msg : fmt .Sprintf ("auth in short cooldown, %s remaining" , remaining ), retryAfter : & d }
@@ -1139,7 +1139,7 @@ func (e *AntigravityExecutor) ExecuteStream(ctx context.Context, auth *cliproxya
11391139 baseModel := thinking .ParseSuffix (req .Model ).ModelName
11401140
11411141 ctx = context .WithValue (ctx , "alt" , "" )
1142- if inCooldown , remaining := antigravityIsInShortCooldown (auth , baseModel , time .Now ()); inCooldown {
1142+ if inCooldown , remaining := antigravityIsInShortCooldown (auth , baseModel , time .Now ()); inCooldown && ! antigravityShouldBypassShortCooldown ( ctx , e . cfg ) {
11431143 log .Debugf ("antigravity executor: auth %s in short cooldown for model %s (%s remaining), returning 429 to switch auth" , auth .ID , baseModel , remaining )
11441144 d := remaining
11451145 return nil , statusErr {code : http .StatusTooManyRequests , msg : fmt .Sprintf ("auth in short cooldown, %s remaining" , remaining ), retryAfter : & d }
@@ -1763,16 +1763,29 @@ func (e *AntigravityExecutor) updateAntigravityCreditsBalance(ctx context.Contex
17631763 return
17641764 }
17651765
1766- loadReqBody := `{"metadata":{"ideType":"ANTIGRAVITY","platform":"PLATFORM_UNSPECIFIED","pluginType":"GEMINI"}}`
1767- endpointURL := "https://cloudcode-pa.googleapis.com/v1internal:loadCodeAssist"
1768- httpReq , errReq := http .NewRequestWithContext (ctx , http .MethodPost , endpointURL , strings .NewReader (loadReqBody ))
1766+ userAgent := resolveLoadCodeAssistUserAgent (auth )
1767+ loadReqBody , errMarshal := json .Marshal (map [string ]any {
1768+ "metadata" : map [string ]string {
1769+ "ide_type" : "ANTIGRAVITY" ,
1770+ "ide_version" : misc .AntigravityVersionFromUserAgent (userAgent ),
1771+ "ide_name" : "antigravity" ,
1772+ },
1773+ })
1774+ if errMarshal != nil {
1775+ log .Debugf ("antigravity executor: marshal loadCodeAssist request error: %v" , errMarshal )
1776+ return
1777+ }
1778+ baseURL := buildBaseURL (auth )
1779+ endpointURL := strings .TrimSuffix (baseURL , "/" ) + "/v1internal:loadCodeAssist"
1780+ httpReq , errReq := http .NewRequestWithContext (ctx , http .MethodPost , endpointURL , bytes .NewReader (loadReqBody ))
17691781 if errReq != nil {
17701782 log .Debugf ("antigravity executor: create loadCodeAssist request error: %v" , errReq )
17711783 return
17721784 }
17731785 httpReq .Header .Set ("Authorization" , "Bearer " + token )
17741786 httpReq .Header .Set ("Content-Type" , "application/json" )
1775- httpReq .Header .Set ("User-Agent" , "google-api-nodejs-client/9.15.1" )
1787+ httpReq .Header .Set ("User-Agent" , userAgent )
1788+ httpReq .Header .Set ("X-Goog-Api-Client" , misc .AntigravityGoogAPIClientUA )
17761789
17771790 httpClient := newAntigravityHTTPClient (ctx , e .cfg , auth , 0 )
17781791 httpResp , errDo := httpClient .Do (httpReq )
@@ -2070,19 +2083,28 @@ func resolveHost(base string) string {
20702083}
20712084
20722085func resolveUserAgent (auth * cliproxyauth.Auth ) string {
2086+ return misc .AntigravityRequestUserAgent (antigravityConfiguredUserAgent (auth ))
2087+ }
2088+
2089+ func resolveLoadCodeAssistUserAgent (auth * cliproxyauth.Auth ) string {
2090+ return misc .AntigravityLoadCodeAssistUserAgent (antigravityConfiguredUserAgent (auth ))
2091+ }
2092+
2093+ func antigravityConfiguredUserAgent (auth * cliproxyauth.Auth ) string {
2094+ raw := ""
20732095 if auth != nil {
20742096 if auth .Attributes != nil {
20752097 if ua := strings .TrimSpace (auth .Attributes ["user_agent" ]); ua != "" {
2076- return ua
2098+ raw = ua
20772099 }
20782100 }
2079- if auth .Metadata != nil {
2101+ if raw == "" && auth .Metadata != nil {
20802102 if ua , ok := auth .Metadata ["user_agent" ].(string ); ok && strings .TrimSpace (ua ) != "" {
2081- return strings .TrimSpace (ua )
2103+ raw = strings .TrimSpace (ua )
20822104 }
20832105 }
20842106 }
2085- return misc . AntigravityUserAgent ()
2107+ return raw
20862108}
20872109
20882110func antigravityRetryAttempts (auth * cliproxyauth.Auth , cfg * config.Config ) int {
@@ -2141,6 +2163,10 @@ func antigravityShouldRetrySoftRateLimit(statusCode int, body []byte) bool {
21412163 return decideAntigravity429 (body ).kind == antigravity429DecisionSoftRetry
21422164}
21432165
2166+ func antigravityShouldBypassShortCooldown (ctx context.Context , cfg * config.Config ) bool {
2167+ return cliproxyauth .AntigravityCreditsRequested (ctx ) && antigravityCreditsRetryEnabled (cfg )
2168+ }
2169+
21442170func antigravitySoftRateLimitDelay (attempt int ) time.Duration {
21452171 if attempt < 0 {
21462172 attempt = 0
0 commit comments