You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: implement exponential backoff and rate limiting for AI API calls
Major improvements to API reliability and performance:
## Rate Limiting & Retry Logic
- Add RetryHandler module with exponential backoff algorithm
- Implement configurable retry parameters (max_retries, base_delay, max_delay)
- Add 10% jitter to prevent thundering herd problems
- Support Retry-After header extraction for rate limit compliance
- Handle different HTTP error codes appropriately (429, 5xx vs 4xx)
## Memory Management Improvements
- Replace magic numbers with named constants (LARGE_DIFF_THRESHOLD, etc.)
- Convert all diff processing from split('\n') to StringIO streaming
- Add proper resource cleanup with ensure blocks
- Prevent memory spikes on large diffs with consistent streaming approach
## API Provider Enhancements
- HTTPClient: Smart retry logic for rate limits and server errors
- DustProvider: Exponential backoff for conversation polling
- AnthropicProvider: Benefits from HTTPClient retry improvements
- Comprehensive error logging with retry attempt visibility
## Testing & Documentation
- Update test expectations for new retry behavior
- Mock sleep calls to maintain fast test execution (0.15s for 50 tests)
- Rename documentation file to AI_TEST_RUNNER.md for consistency
- Update all references to use proper 'AI Test Runner' naming
## Performance Benefits
- Graceful handling of temporary API failures
- Reduced failure rates through intelligent backoff
- Optimal retry timing (1s → 2s → 4s → 8s → 16s, capped at 30s)
- Fast recovery for transient issues
All 50 tests pass. No breaking changes to existing functionality.
Copy file name to clipboardExpand all lines: doc/AI_TEST_RUNNER.md
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,11 @@
1
-
# 🤖 Smart Test Runner
1
+
# 🤖 AI Test Runner
2
2
3
3
An AI-powered GitHub Action that intelligently selects and runs only the tests relevant to your code changes, reducing CI time while maintaining comprehensive coverage.
4
4
5
5
## Features
6
6
7
7
-**🧠 AI-Powered Analysis**: Uses Claude 3 Sonnet to analyze code changes and understand test dependencies
8
-
-**🎯 Smart Test Selection**: Identifies both direct and indirect tests that may be affected by changes
8
+
-**🎯 AI Test Selection**: Identifies both direct and indirect tests that may be affected by changes
9
9
-**⚡ Performance Optimization**: Runs only relevant tests instead of the entire test suite
10
10
-**📊 Detailed Reporting**: Provides comprehensive analysis of why tests were selected
11
11
-**🔄 Fallback Safety**: Falls back to running all tests if AI analysis fails
@@ -42,7 +42,7 @@ Set repository variables:
42
42
43
43
### 3. The Workflow is Ready!
44
44
45
-
The smart test runner is already configured in `.github/workflows/smart_tests.yml` and will automatically:
45
+
The AI test runner is already configured in `.github/workflows/smart_tests.yml` and will automatically:
46
46
47
47
- Trigger on pushes to `main` and `develop` branches
48
48
- Trigger on pull requests to `main` and `develop` branches
@@ -51,7 +51,7 @@ The smart test runner is already configured in `.github/workflows/smart_tests.ym
51
51
52
52
## Manual Usage
53
53
54
-
You can also run the smart test selector locally:
54
+
You can also run the AI test selector locally:
55
55
56
56
```bash
57
57
# Set required environment variables
@@ -112,7 +112,7 @@ The AI considers multiple factors when selecting tests:
112
112
113
113
## Output Files
114
114
115
-
The smart test runner generates several output files:
115
+
The AI test runner generates several output files:
116
116
117
117
### `tmp/selected_tests.txt`
118
118
Simple list of selected test files (one per line) used by the GitHub workflow.
@@ -206,7 +206,7 @@ Enable debug logging by setting the log level:
206
206
207
207
```ruby
208
208
logger =Logger.new($stdout, level:Logger::DEBUG)
209
-
runner =SmartTestRunner.new(config, logger)
209
+
runner =AITestRunner.new(config, logger)
210
210
```
211
211
212
212
## Contributing
@@ -250,13 +250,13 @@ The system automatically falls back to a built-in prompt if the external file is
250
250
## Architecture
251
251
252
252
```
253
-
SmartTestRunner
254
-
├── SmartTestConfig # Configuration management
253
+
AITestRunner
254
+
├── AITestConfig # Configuration management
255
255
├── GitChangeAnalyzer # Git diff analysis and parsing
256
256
├── TestDiscoveryService # Test file discovery and mapping
257
257
├── AITestSelector # AI-powered test selection
258
258
│ └── ai_test_selection_prompt.md # External AI prompt template
0 commit comments