Skip to main content
Antigravity Manager implements comprehensive self-healing mechanisms that automatically recover from transient failures, ensuring uninterrupted service during rate limits and authentication issues.

Overview

The self-healing system handles:
  • 429 Too Many Requests - Quota exhaustion and rate limiting
  • 401 Unauthorized - Expired tokens and authentication failures
  • 5xx Server Errors - Upstream service disruptions
  • Network Timeouts - Transient connectivity issues

Rate Limit Detection & Recovery

429 Error Handling

When a 429 error occurs, the system:
  1. Parses retry delay from error response
  2. Locks the account until quota resets
  3. Rotates to next account immediately
  4. Retries the request seamlessly

Duration Parsing

Supports Google’s duration format (e.g., 1h16m0.667s):
Example: "1h16m0.667s"4560667 milliseconds

Rate Limit Tracking

Account Lockout

When an account hits rate limits, it’s temporarily locked:

Model-Level Rate Limiting

Rate limits can be applied per-model or per-account:
This enables:
  • Account-level lockout - Block all requests from account
  • Model-level lockout - Block only specific model, allow others

Intelligent Backoff

The system uses exponential backoff with failure count tracking:

Success Reset

Successful requests reset the failure counter:

Token Refresh (401 Recovery)

Automatic Token Renewal

When a 401 error occurs, tokens are automatically refreshed:

Preemptive Refresh

Tokens are refreshed 5 minutes before expiration to avoid mid-request failures.

Automatic Account Rotation

Seamless Failover

When an account fails, the system automatically tries the next available account:

Failure Isolation

The attempted set prevents retry loops:

Auto-Cleanup Background Task

Expired rate limit records are automatically cleaned:
Runs every 15 seconds to prevent memory leaks.

Graceful Shutdown

Background tasks are cleanly terminated on app exit:

Request Flow with Self-Healing

Configuration

Retry Settings

Rate Limit Settings

Monitoring

Rate Limit Status

Check active rate limits via logs:
Example output:

Failure Count Tracking

Best Practices

  1. Use multiple accounts - Enables seamless rotation during rate limits
  2. Enable auto-refresh - Keeps quota data current for accurate lockouts
  3. Monitor failure patterns - Identify problematic accounts or models
  4. Set reasonable retry limits - Avoid overwhelming upstream with retries
  5. Review rate limit logs - Understand quota consumption patterns

Troubleshooting

Issue: Requests fail even with multiple accounts

Cause: All accounts are rate-limited. Solution: Check rate limit status:

Issue: Account stuck in rate-limited state

Cause: Cleanup task not running or reset time not reached. Solution: Force cleanup:

Issue: Token refresh fails repeatedly

Cause: Refresh token may be revoked. Solution: Re-authorize the account via OAuth flow.