Skip to content

Commit 12f257a

Browse files
committed
feat: add rate limiting and inline comments configuration
- Add AI_REVIEW_RATE_LIMIT_MINUTES env var (defaults to 1 minute) - Add AI_ENABLE_INLINE_COMMENTS env var (defaults to true) - Update recent review check to use configurable rate limit - Update documentation with new configuration options These environment variables enable fine-grained control over review frequency and inline comment behavior.
1 parent b3d18a7 commit 12f257a

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

.github/workflows/ai-pr-review.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ jobs:
7272
- name: Check for recent AI review
7373
id: check_recent_review
7474
uses: actions/github-script@v7
75+
env:
76+
RATE_LIMIT_MINUTES: ${{ vars.AI_REVIEW_RATE_LIMIT_MINUTES || '1' }}
7577
with:
7678
github-token: ${{ github.token }}
7779
script: |
@@ -82,16 +84,18 @@ jobs:
8284
per_page: 100
8385
});
8486
85-
// Check if there's a recent AI review (within last 5 minutes)
86-
const fiveMinutesAgo = new Date(Date.now() - 5 * 60 * 1000);
87+
// Check if there's a recent AI review (within rate limit window)
88+
const rateLimitMinutes = parseInt(process.env.RATE_LIMIT_MINUTES) || 1;
89+
const rateLimitMs = rateLimitMinutes * 60 * 1000;
90+
const rateLimitAgo = new Date(Date.now() - rateLimitMs);
8791
const recentAIReview = comments.data.find(comment =>
8892
comment.user.login === 'github-actions[bot]' &&
8993
comment.body.includes('🤖 AI Review') &&
90-
new Date(comment.created_at) > fiveMinutesAgo
94+
new Date(comment.created_at) > rateLimitAgo
9195
);
9296
9397
if (recentAIReview) {
94-
console.log('Recent AI review found, skipping to prevent spam');
98+
console.log(`Recent AI review found within ${rateLimitMinutes} minute(s), skipping to prevent spam`);
9599
core.setOutput('skip', 'true');
96100
} else {
97101
core.setOutput('skip', 'false');
@@ -172,6 +176,9 @@ jobs:
172176
if: (steps.check_tests.outputs.result == 'true' || github.event_name != 'pull_request') && steps.check_recent_review.outputs.skip != 'true'
173177
id: ai_review
174178
uses: stillrivercode/stillriver-ai-workflows@v1
179+
env:
180+
AI_REVIEW_RATE_LIMIT_MINUTES: ${{ vars.AI_REVIEW_RATE_LIMIT_MINUTES || '1' }}
181+
AI_ENABLE_INLINE_COMMENTS: ${{ vars.AI_ENABLE_INLINE_COMMENTS || 'true' }}
175182
with:
176183
github_token: ${{ github.token }}
177184
openrouter_api_key: ${{ secrets.OPENROUTER_API_KEY }}

docs/stillriver-ai-workflows-integration.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ The action is configured with the following inputs:
3838

3939
```yaml
4040
- uses: stillrivercode/stillriver-ai-workflows@v1
41+
env:
42+
AI_REVIEW_RATE_LIMIT_MINUTES: ${{ vars.AI_REVIEW_RATE_LIMIT_MINUTES || '1' }}
43+
AI_ENABLE_INLINE_COMMENTS: ${{ vars.AI_ENABLE_INLINE_COMMENTS || 'true' }}
4144
with:
4245
github_token: ${{ github.token }}
4346
openrouter_api_key: ${{ secrets.OPENROUTER_API_KEY }}
@@ -57,6 +60,8 @@ The action is configured with the following inputs:
5760
## Optional Variables
5861

5962
- `AI_MODEL`: The AI model to use (defaults to `anthropic/claude-sonnet-4`)
63+
- `AI_REVIEW_RATE_LIMIT_MINUTES`: Rate limit window for reviews (defaults to `1` minute)
64+
- `AI_ENABLE_INLINE_COMMENTS`: Enable GitHub's native inline suggestions (defaults to `true`)
6065

6166
## Workflow Behavior
6267

@@ -81,6 +86,8 @@ The action is configured with the following inputs:
8186
- Simplified error handling to use action outputs
8287
- Maintained all existing workflow triggers and conditions
8388
- Preserved custom comment formatting and label logic
89+
- Updated rate limit check to use configurable `AI_REVIEW_RATE_LIMIT_MINUTES`
90+
- Added support for inline comments via `AI_ENABLE_INLINE_COMMENTS`
8491

8592
## Future Enhancements
8693

0 commit comments

Comments
 (0)