fix: Prevent stale bot from flagging internal maintainer discussions

Merge https://github.com/google/adk-python/pull/3938

Co-authored-by: Xuan Yang <xygoogle@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3938 from ryanaiagent:fix/stale-bot-logic 605d3499784facffc0e0ca3c1fb0547202660f46
PiperOrigin-RevId: 846450195
This commit is contained in:
Rohit Yanamadala
2025-12-18 16:04:21 -08:00
committed by Copybara-Service
parent e4ee9d7c46
commit f51b9b70b2
3 changed files with 33 additions and 7 deletions
+14
View File
@@ -1,3 +1,17 @@
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: ADK Stale Issue Auditor
on:
@@ -53,16 +53,21 @@ Your job is to analyze a specific issue and report findings before taking action
**STEP 3: ANALYZE MAINTAINER INTENT**
- **Context**: The last person to act was a Maintainer.
- **Action**: Read the text in `last_comment_text`.
- **Question Check**: Does the text ask a question, request clarification, ask for logs, or suggest trying a fix?
- **Action**: Analyze `last_comment_text` using `maintainers` list and `last_actor_name`.
- **Internal Discussion Check**: Does the comment mention or address any username found in the `maintainers` list (other than the speaker `last_actor_name`)?
- **Verdict**: **ACTIVE** (Internal Team Discussion).
- **Report**: "Analysis for Issue #[number]: ACTIVE. Maintainer is discussing with another maintainer. No action."
- **Question Check**: Does the text ask a question, request clarification, ask for logs, or give suggestions?
- **Time Check**: Is `days_since_activity` > {stale_threshold_days}?
- **DECISION**:
- **IF (Question == YES) AND (Time == YES)**:
- **IF (Question == YES) AND (Time == YES) AND (Internal Discussion Check == FALSE):**
- **Action**: Call `add_stale_label_and_comment`.
- **Check**: If '{REQUEST_CLARIFICATION_LABEL}' is not in `current_labels`, call `add_label_to_issue` for it.
- **Check**: If '{REQUEST_CLARIFICATION_LABEL}' is not in `current_labels`, call `add_label_to_issue` with '{REQUEST_CLARIFICATION_LABEL}'.
- **Report**: "Analysis for Issue #[number]: STALE. Maintainer asked question [days_since_activity] days ago. Marking stale."
- **IF (Question == YES) BUT (Time == NO)**:
- **Report**: "Analysis for Issue #[number]: PENDING. Maintainer asked question, but threshold not met yet. No action."
- **IF (Question == NO)** (e.g., "I am working on this"):
- **Report**: "Analysis for Issue #[number]: ACTIVE. Maintainer gave status update (not a question). No action."
- **IF (Question == NO) OR (Internal Discussion Check == TRUE):**
- **Report**: "Analysis for Issue #[number]: ACTIVE. Maintainer gave status update or internal discussion detected. No action."
@@ -318,11 +318,13 @@ def _replay_history_to_find_state(
- last_activity_time (datetime): Timestamp of the last human action.
- last_action_type (str): The type of the last action (e.g., 'commented').
- last_comment_text (Optional[str]): The text of the last comment.
- last_actor_name (str): The specific username of the last actor.
"""
last_action_role = "author"
last_activity_time = history[0]["time"]
last_action_type = "created"
last_comment_text = None
last_actor_name = issue_author
for event in history:
actor = event["actor"]
@@ -337,6 +339,7 @@ def _replay_history_to_find_state(
last_action_role = role
last_activity_time = event["time"]
last_action_type = etype
last_actor_name = actor
# Only store text if it was a comment (resets on other events like labels/edits)
if etype == "commented":
@@ -349,6 +352,7 @@ def _replay_history_to_find_state(
"last_activity_time": last_activity_time,
"last_action_type": last_action_type,
"last_comment_text": last_comment_text,
"last_actor_name": last_actor_name,
}
@@ -428,6 +432,7 @@ def get_issue_state(item_number: int) -> Dict[str, Any]:
"status": "success",
"last_action_role": state["last_action_role"],
"last_action_type": state["last_action_type"],
"last_actor_name": state["last_actor_name"],
"maintainer_alert_needed": maintainer_alert_needed,
"is_stale": is_stale,
"days_since_activity": days_since_activity,
@@ -436,6 +441,8 @@ def get_issue_state(item_number: int) -> Dict[str, Any]:
"current_labels": labels_list,
"stale_threshold_days": STALE_HOURS_THRESHOLD / 24,
"close_threshold_days": CLOSE_HOURS_AFTER_STALE_THRESHOLD / 24,
"maintainers": maintainers,
"issue_author": issue_author,
}
except RequestException as e: