Skip to content

Commit f51b9b7

Browse files
rohityanxuanyang15
authored andcommitted
fix: Prevent stale bot from flagging internal maintainer discussions
Merge google#3938 Co-authored-by: Xuan Yang <xygoogle@google.com> COPYBARA_INTEGRATE_REVIEW=google#3938 from ryanaiagent:fix/stale-bot-logic 605d349 PiperOrigin-RevId: 846450195
1 parent e4ee9d7 commit f51b9b7

3 files changed

Lines changed: 33 additions & 7 deletions

File tree

.github/workflows/stale-bot.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
115
name: ADK Stale Issue Auditor
216

317
on:

contributing/samples/adk_stale_agent/PROMPT_INSTRUCTION.txt

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,24 +45,29 @@ Your job is to analyze a specific issue and report findings before taking action
4545
- **IF True**: The user edited the description silently, and we haven't alerted yet.
4646
-> **Action**: Call `alert_maintainer_of_edit`.
4747
-> **Report**: "Analysis for Issue #[number]: ACTIVE. Silent update detected (Description Edit). Alerted maintainer."
48-
- **IF False**:
48+
- **IF False**:
4949
-> **Report**: "Analysis for Issue #[number]: ACTIVE. Last action was by user. No action."
5050

5151
- **Check Role**: If `last_action_role` is 'maintainer':
5252
- **Proceed to STEP 3.**
5353

5454
**STEP 3: ANALYZE MAINTAINER INTENT**
5555
- **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?
56+
- **Action**: Analyze `last_comment_text` using `maintainers` list and `last_actor_name`.
57+
58+
- **Internal Discussion Check**: Does the comment mention or address any username found in the `maintainers` list (other than the speaker `last_actor_name`)?
59+
- **Verdict**: **ACTIVE** (Internal Team Discussion).
60+
- **Report**: "Analysis for Issue #[number]: ACTIVE. Maintainer is discussing with another maintainer. No action."
61+
62+
- **Question Check**: Does the text ask a question, request clarification, ask for logs, or give suggestions?
5863
- **Time Check**: Is `days_since_activity` > {stale_threshold_days}?
5964

6065
- **DECISION**:
61-
- **IF (Question == YES) AND (Time == YES)**:
66+
- **IF (Question == YES) AND (Time == YES) AND (Internal Discussion Check == FALSE):**
6267
- **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.
68+
- **Check**: If '{REQUEST_CLARIFICATION_LABEL}' is not in `current_labels`, call `add_label_to_issue` with '{REQUEST_CLARIFICATION_LABEL}'.
6469
- **Report**: "Analysis for Issue #[number]: STALE. Maintainer asked question [days_since_activity] days ago. Marking stale."
6570
- **IF (Question == YES) BUT (Time == NO)**:
6671
- **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."
72+
- **IF (Question == NO) OR (Internal Discussion Check == TRUE):**
73+
- **Report**: "Analysis for Issue #[number]: ACTIVE. Maintainer gave status update or internal discussion detected. No action."

contributing/samples/adk_stale_agent/agent.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,11 +318,13 @@ def _replay_history_to_find_state(
318318
- last_activity_time (datetime): Timestamp of the last human action.
319319
- last_action_type (str): The type of the last action (e.g., 'commented').
320320
- last_comment_text (Optional[str]): The text of the last comment.
321+
- last_actor_name (str): The specific username of the last actor.
321322
"""
322323
last_action_role = "author"
323324
last_activity_time = history[0]["time"]
324325
last_action_type = "created"
325326
last_comment_text = None
327+
last_actor_name = issue_author
326328

327329
for event in history:
328330
actor = event["actor"]
@@ -337,6 +339,7 @@ def _replay_history_to_find_state(
337339
last_action_role = role
338340
last_activity_time = event["time"]
339341
last_action_type = etype
342+
last_actor_name = actor
340343

341344
# Only store text if it was a comment (resets on other events like labels/edits)
342345
if etype == "commented":
@@ -349,6 +352,7 @@ def _replay_history_to_find_state(
349352
"last_activity_time": last_activity_time,
350353
"last_action_type": last_action_type,
351354
"last_comment_text": last_comment_text,
355+
"last_actor_name": last_actor_name,
352356
}
353357

354358

@@ -428,6 +432,7 @@ def get_issue_state(item_number: int) -> Dict[str, Any]:
428432
"status": "success",
429433
"last_action_role": state["last_action_role"],
430434
"last_action_type": state["last_action_type"],
435+
"last_actor_name": state["last_actor_name"],
431436
"maintainer_alert_needed": maintainer_alert_needed,
432437
"is_stale": is_stale,
433438
"days_since_activity": days_since_activity,
@@ -436,6 +441,8 @@ def get_issue_state(item_number: int) -> Dict[str, Any]:
436441
"current_labels": labels_list,
437442
"stale_threshold_days": STALE_HOURS_THRESHOLD / 24,
438443
"close_threshold_days": CLOSE_HOURS_AFTER_STALE_THRESHOLD / 24,
444+
"maintainers": maintainers,
445+
"issue_author": issue_author,
439446
}
440447

441448
except RequestException as e:

0 commit comments

Comments
 (0)