Skip to content

Commit ad8fe27

Browse files
Copilotpelikhan
andauthored
Add pull_request.opened event support to ai-moderator (#16230)
* Initial plan * Add pull_request.opened support to ai-moderator Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> * Set cancel-in-progress: false for ai-moderator Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> * Allow ai-moderator to run on fork PRs Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> Co-authored-by: Peli de Halleux <pelikhan@users.noreply.github.com>
1 parent 21134e0 commit ad8fe27

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

.github/workflows/ai-moderator.lock.yml

Lines changed: 8 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/ai-moderator.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,17 @@ on:
88
issue_comment:
99
types: [created]
1010
lock-for-agent: true
11+
pull_request:
12+
types: [opened]
13+
forks: "*"
1114
skip-roles: [admin, maintainer, write, triage]
1215
skip-bots: [github-actions, copilot]
1316
rate-limit:
1417
max: 5
1518
window: 60
19+
concurrency:
20+
group: "gh-aw-${{ github.workflow }}-${{ github.event.issue.number || github.event.pull_request.number }}"
21+
cancel-in-progress: false
1622
engine: codex
1723
tools:
1824
github:
@@ -40,6 +46,7 @@ You are an AI-powered moderation system that automatically detects spam, link sp
4046

4147
1. Use the GitHub MCP server tools to fetch the original context (see github context), unsanitized content directly from GitHub API
4248
2. Do NOT use the pre-sanitized text from the activation job - fetch fresh content to analyze the original user input
49+
3. **For Pull Requests**: Use `pull_request_read` with method `get_diff` to fetch the PR diff and analyze the changes for spam patterns
4350

4451
## Detection Tasks
4552

@@ -106,6 +113,17 @@ Based on your analysis:
106113
- Also add appropriate labels to the parent issue as described above
107114
- If the comment appears legitimate and on-topic, add the `ai-inspected` label to the parent issue
108115

116+
3. **For Pull Requests** (when pull request number is present):
117+
- Fetch the PR diff using `pull_request_read` with method `get_diff`
118+
- Analyze the diff for spam patterns:
119+
- Large amounts of promotional content or links in code comments
120+
- Suspicious file additions (e.g., cryptocurrency miners, malware)
121+
- Mass link injection across multiple files
122+
- AI-generated code comments with promotional content
123+
- If spam, link spam, or suspicious patterns are detected:
124+
- Use the `add-labels` safe output to add appropriate labels (`spam`, `link-spam`, `ai-generated`)
125+
- **If no warnings or issues are found** and the PR appears legitimate, use the `add-labels` safe output to add the `ai-inspected` label
126+
109127
## Important Guidelines
110128

111129
- Be conservative with detections to avoid false positives

0 commit comments

Comments
 (0)