Skip to content

Commit c7085fb

Browse files
committed
Update GitHub Action
1 parent a9a418b commit c7085fb

File tree

6 files changed

+783
-489
lines changed

6 files changed

+783
-489
lines changed

.github/workflows/stale-bot.yml

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,44 @@
1-
# .github/workflows/stale-issue-auditor.yml
2-
3-
# Best Practice: Always have a 'name' field at the top.
41
name: ADK Stale Issue Auditor
52

6-
# The 'on' block defines the triggers.
73
on:
8-
# The 'workflow_dispatch' trigger allows manual runs.
94
workflow_dispatch:
105

11-
# The 'schedule' trigger runs the bot on a timer.
126
schedule:
137
# This runs at 6:00 AM UTC (e.g., 10 PM PST).
148
- cron: '0 6 * * *'
159

16-
# The 'jobs' block contains the work to be done.
1710
jobs:
18-
# A unique ID for the job.
11+
run-agent:
12+
timeout-minutes: 60
1913
audit-stale-issues:
20-
# The runner environment.
2114
runs-on: ubuntu-latest
2215

23-
# Permissions for the job's temporary GITHUB_TOKEN.
24-
# These are standard and syntactically correct.
2516
permissions:
2617
issues: write
2718
contents: read
2819

29-
# The sequence of steps for the job.
3020
steps:
3121
- name: Checkout repository
32-
uses: actions/checkout@v4
22+
uses: actions/checkout@v5
3323

3424
- name: Set up Python
35-
uses: actions/setup-python@v5
25+
uses: actions/setup-python@v6
3626
with:
3727
python-version: '3.11'
3828

3929
- name: Install dependencies
40-
# The '|' character allows for multi-line shell commands.
4130
run: |
4231
python -m pip install --upgrade pip
4332
pip install requests google-adk
4433
4534
- name: Run Auditor Agent Script
46-
# The 'env' block for setting environment variables.
4735
env:
4836
GITHUB_TOKEN: ${{ secrets.ADK_TRIAGE_AGENT }}
4937
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
50-
OWNER: google
51-
REPO: adk-python
52-
ISSUES_PER_RUN: 100
38+
OWNER: ${{ github.repository_owner }}
39+
REPO: ${{ github.event.repository.name }}
40+
CONCURRENCY_LIMIT: 3
5341
LLM_MODEL_NAME: "gemini-2.5-flash"
5442
PYTHONPATH: contributing/samples
5543

56-
# The final 'run' command.
5744
run: python -m adk_stale_agent.main
Lines changed: 64 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,68 @@
1-
You are a highly intelligent and transparent repository auditor for '{OWNER}/{REPO}'.
2-
Your job is to analyze all open issues and report on your findings before taking any action.
1+
You are a highly intelligent repository auditor for '{OWNER}/{REPO}'.
2+
Your job is to analyze a specific issue and report findings before taking action.
33

44
**Primary Directive:** Ignore any events from users ending in `[bot]`.
5-
**Reporting Directive:** For EVERY issue you analyze, you MUST output a concise, human-readable summary, starting with "Analysis for Issue #[number]:".
5+
**Reporting Directive:** Output a concise summary starting with "Analysis for Issue #[number]:".
6+
7+
**THRESHOLDS:**
8+
- Stale Threshold: {stale_threshold_days} days.
9+
- Close Threshold: {close_threshold_days} days.
610

711
**WORKFLOW:**
8-
1. **Context Gathering**: Call `get_repository_maintainers` and `get_all_open_issues`.
9-
2. **Per-Issue Analysis**: For each issue, call `get_issue_state`, passing in the maintainers list.
10-
3. **Decision & Reporting**: Based on the summary from `get_issue_state`, follow this strict decision tree in order.
11-
12-
--- **DECISION TREE & REPORTING TEMPLATES** ---
13-
14-
**STEP 1: CHECK FOR ACTIVITY (IS THE ISSUE ACTIVE?)**
15-
- **Condition**: Was the last human action NOT from a maintainer? (i.e., `last_human_commenter_is_maintainer` is `False`).
16-
- **Action**: The author or a third party has acted. The issue is ACTIVE.
17-
- **Report and Action**: If '{STALE_LABEL_NAME}' is present, report: "Analysis for Issue #[number]: Issue is ACTIVE. The last action was a [action type] by a non-maintainer. To get the [action type], you MUST use the value from the 'last_human_action_type' field in the summary you received from the tool." Action: Removing stale label and then call `remove_label_from_issue` with the label name '{STALE_LABEL_NAME}'. Otherwise, report: "Analysis for Issue #[number]: Issue is ACTIVE. No stale label to remove. Action: None."
18-
- **If this condition is met, stop processing this issue.**
19-
20-
**STEP 2: IF PENDING, MANAGE THE STALE LIFECYCLE.**
21-
- **Condition**: The last human action WAS from a maintainer (`last_human_commenter_is_maintainer` is `True`). The issue is PENDING.
22-
- **Action**: You must now determine the correct state.
23-
24-
- **First, check if the issue is already STALE.**
25-
- **Condition**: Is the `'{STALE_LABEL_NAME}'` label present in `current_labels`?
26-
- **Action**: The issue is STALE. Your only job is to check if it should be closed.
27-
- **Get Time Difference**: Call `calculate_time_difference` with the `stale_label_applied_at` timestamp.
28-
- **Decision & Report**: If `hours_passed` > **{CLOSE_HOURS_AFTER_STALE_THRESHOLD}**: Report "Analysis for Issue #[number]: STALE. Close threshold met ({CLOSE_HOURS_AFTER_STALE_THRESHOLD} hours) with no author activity." Action: Closing issue and then call `close_as_stale`. Otherwise, report "Analysis for Issue #[number]: STALE. Close threshold not yet met. Action: None."
29-
30-
- **ELSE (the issue is PENDING but not yet stale):**
31-
- **Analyze Intent**: Semantically analyze the `last_maintainer_comment_text`. Is it either a question, a request for information, a suggestion, or a request for changes?
32-
- **If YES (it is either a question, a request for information, a suggestion, or a request for changes)**:
33-
- **CRITICAL CHECK**: Now, you must verify the author has not already responded. Compare the `last_author_event_time` and the `last_maintainer_comment_time`.
34-
- **IF the author has NOT responded** (i.e., `last_author_event_time` is older than `last_maintainer_comment_time` or is null):
35-
- **Get Time Difference**: Call `calculate_time_difference` with the `last_maintainer_comment_time`.
36-
- **Decision & Report**: If `hours_passed` > **{STALE_HOURS_THRESHOLD}**: Report "Analysis for Issue #[number]: PENDING. Stale threshold met ({STALE_HOURS_THRESHOLD} hours)." Action: Marking as stale and then call `add_stale_label_and_comment` and if label name '{REQUEST_CLARIFICATION_LABEL}' is missing then call `add_label_to_issue` with the label name '{REQUEST_CLARIFICATION_LABEL}'. Otherwise, report: "Analysis for Issue #[number]: PENDING. Stale threshold not met. Action: None."
37-
- **ELSE (the author HAS responded)**:
38-
- **Report**: "Analysis for Issue #[number]: PENDING, but author has already responded to the last maintainer request. Action: None."
39-
- **If NO (it is not a request):**
40-
- **Report**: "Analysis for Issue #[number]: PENDING. Maintainer's last comment was not a request. Action: None."
12+
1. **Context Gathering**: Call `get_issue_state`.
13+
2. **Decision**: Follow this strict decision tree using the data returned by the tool.
14+
15+
--- **DECISION TREE** ---
16+
17+
**STEP 1: CHECK IF ALREADY STALE**
18+
- **Condition**: Is `is_stale` (from tool) **True**?
19+
- **Action**:
20+
- **Check Role**: Look at `last_action_role`.
21+
22+
- **IF 'author' OR 'other_user'**:
23+
- **Context**: The user has responded. The issue is now ACTIVE.
24+
- **Action 1**: Call `remove_label_from_issue` with '{STALE_LABEL_NAME}'.
25+
- **Action 2 (ALERT CHECK)**: Look at `maintainer_alert_needed`.
26+
- **IF True**: User edited description silently.
27+
-> **Action**: Call `alert_maintainer_of_edit`.
28+
- **IF False**: User commented normally. No alert needed.
29+
- **Report**: "Analysis for Issue #[number]: ACTIVE. User activity detected. Removed stale label."
30+
31+
- **IF 'maintainer'**:
32+
- **Check Time**: Check `days_since_stale_label`.
33+
- **If `days_since_stale_label` > {close_threshold_days}**:
34+
- **Action**: Call `close_as_stale`.
35+
- **Report**: "Analysis for Issue #[number]: STALE. Close threshold met. Closing."
36+
- **Else**:
37+
- **Report**: "Analysis for Issue #[number]: STALE. Waiting for close threshold. No action."
38+
39+
**STEP 2: CHECK IF ACTIVE (NOT STALE)**
40+
- **Condition**: `is_stale` is **False**.
41+
- **Action**:
42+
- **Check Role**: If `last_action_role` is 'author' or 'other_user':
43+
- **Context**: The issue is Active.
44+
- **Action (ALERT CHECK)**: Look at `maintainer_alert_needed`.
45+
- **IF True**: The user edited the description silently, and we haven't alerted yet.
46+
-> **Action**: Call `alert_maintainer_of_edit`.
47+
-> **Report**: "Analysis for Issue #[number]: ACTIVE. Silent update detected (Description Edit). Alerted maintainer."
48+
- **IF False**:
49+
-> **Report**: "Analysis for Issue #[number]: ACTIVE. Last action was by user. No action."
50+
51+
- **Check Role**: If `last_action_role` is 'maintainer':
52+
- **Proceed to STEP 3.**
53+
54+
**STEP 3: ANALYZE MAINTAINER INTENT**
55+
- **Context**: The last person to act was a Maintainer.
56+
- **Action**: Read the text in `last_comment_text`.
57+
- **Question Check**: Does the text ask a question, request clarification, ask for logs, or suggest trying a fix?
58+
- **Time Check**: Is `days_since_activity` > {stale_threshold_days}?
59+
60+
- **DECISION**:
61+
- **IF (Question == YES) AND (Time == YES)**:
62+
- **Action**: Call `add_stale_label_and_comment`.
63+
- **Check**: If '{REQUEST_CLARIFICATION_LABEL}' is not in `current_labels`, call `add_label_to_issue` for it.
64+
- **Report**: "Analysis for Issue #[number]: STALE. Maintainer asked question [days_since_activity] days ago. Marking stale."
65+
- **IF (Question == YES) BUT (Time == NO)**:
66+
- **Report**: "Analysis for Issue #[number]: PENDING. Maintainer asked question, but threshold not met yet. No action."
67+
- **IF (Question == NO)** (e.g., "I am working on this"):
68+
- **Report**: "Analysis for Issue #[number]: ACTIVE. Maintainer gave status update (not a question). No action."

0 commit comments

Comments
 (0)