Error Handling & Retry Logic
Antigravity Manager implements intelligent error handling and automatic retry mechanisms to provide a seamless experience even when upstream APIs encounter issues.Error Classification
Location:src-tauri/src/error.rs and src-tauri/src/proxy/mappers/error_classifier.rs
Error Types
HTTP Status Classification
| Status Code | Category | Retry Strategy | Example |
|---|---|---|---|
| 401 | Auth expired | Auto-refresh token → retry | Invalid grant |
| 403 | Forbidden | Mark account → switch | Validation blocked |
| 404 | Not found | Short retry → rotate | Model not available |
| 429 | Rate limit | Exponential backoff → rotate | Too many requests |
| 500-503 | Server error | Retry with backoff | Overloaded |
| 4xx | Client error | No retry | Invalid request |
Error Classifier
Automatic Retry Logic
Location: Throughout proxy handlers429 Rate Limit Handling
When a429 Too Many Requests is received:
-
Immediate account rotation:
-
Smart cooldown:
-
Quota refresh:
401 Token Expiry
When a401 Unauthorized is received:
-
Silent token refresh:
- Automatic re-enablement: When token refresh succeeds, account is automatically re-enabled.
403 Validation Block
When a403 Forbidden is received:
-
Account marking:
-
Immediate rotation:
- UI notification: Account details page shows validation link for user action.
404 Model Not Found
Specific to Google Cloud Code API phased rollouts:500/503 Server Errors
Exponential backoff for temporary server issues:- Retry 1: 100ms
- Retry 2: 200ms
- Retry 3: 400ms
Account Rotation Strategy
Location:src-tauri/src/proxy/token_manager.rs
Smart Account Selection
Quota Score Calculation
Cooldown Management
Self-Healing Features
Location: Changelog references in README.mdAutomatic Quota Refresh
Background task refreshes quota every N minutes:Project ID Recovery
When project ID is missing or invalid:Thinking Signature Recovery
When thinking blocks fail due to missing signatures:- Tool history exists (from previous turns)
- Retry attempt is detected
- Signature validation fails
Account Index Auto-Repair
If account index becomes corrupted:- Index file is missing
- Index contains invalid entries
- Account count mismatch detected
Quota Protection
Prevents requests when quota is exhausted:Error Recovery Modes
Permissive Mode
For first-time thinking requests (no history):Strict Mode
For tool calls with thinking:Adaptive Mode
Dynamically adjusts based on context:Monitoring & Logging
All errors are logged with context:- UI logs page (
/api/logs) - System logs (stored in data directory)
- Debug console (if enabled)
Best Practices
- Add multiple accounts for seamless rotation
- Enable auto-refresh to keep quota status current
- Monitor logs for recurring errors
- Respond to 403s by following validation links
- Keep tokens fresh by using accounts regularly
See Also
- Request Mapping - Protocol conversion
- Response Mapping - Response transformation
- Streaming - Real-time error handling