From 11acd16b831ad4d423303029fcdba4b6e4289c5f Mon Sep 17 00:00:00 2001 From: Rohit Yanamadala Date: Mon, 15 Dec 2025 12:22:23 -0800 Subject: [PATCH 1/4] fix: Prevent stale bot from flagging internal maintainer discussions --- .../adk_stale_agent/PROMPT_INSTRUCTION.txt | 15 ++++++++++----- contributing/samples/adk_stale_agent/agent.py | 7 +++++++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/contributing/samples/adk_stale_agent/PROMPT_INSTRUCTION.txt b/contributing/samples/adk_stale_agent/PROMPT_INSTRUCTION.txt index 8f5f585ff6..dc0a650e26 100644 --- a/contributing/samples/adk_stale_agent/PROMPT_INSTRUCTION.txt +++ b/contributing/samples/adk_stale_agent/PROMPT_INSTRUCTION.txt @@ -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, or ask for logs? - **Time Check**: Is `days_since_activity` > {stale_threshold_days}? - **DECISION**: - **IF (Question == YES) AND (Time == YES)**: - **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`. - **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." \ No newline at end of file + - **IF (Question == NO)**: + - **Report**: "Analysis for Issue #[number]: ACTIVE. Maintainer gave status update. No action." \ No newline at end of file diff --git a/contributing/samples/adk_stale_agent/agent.py b/contributing/samples/adk_stale_agent/agent.py index 8769adc193..2535f9cf45 100644 --- a/contributing/samples/adk_stale_agent/agent.py +++ b/contributing/samples/adk_stale_agent/agent.py @@ -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: From ffe05463c7ded55dcafaf1a993082cce46af55f3 Mon Sep 17 00:00:00 2001 From: Rohit Yanamadala Date: Tue, 16 Dec 2025 15:59:50 -0800 Subject: [PATCH 2/4] doc(stale-bot.yml):add copyright for workflow --- .github/workflows/stale-bot.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/stale-bot.yml b/.github/workflows/stale-bot.yml index 6948b56459..f288c0e3b0 100644 --- a/.github/workflows/stale-bot.yml +++ b/.github/workflows/stale-bot.yml @@ -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: From 605d3499784facffc0e0ca3c1fb0547202660f46 Mon Sep 17 00:00:00 2001 From: Rohit Yanamadala Date: Tue, 16 Dec 2025 16:10:56 -0800 Subject: [PATCH 3/4] refactor(PROMPT_INSTRUCTION.txt): update prompt --- contributing/samples/adk_stale_agent/PROMPT_INSTRUCTION.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contributing/samples/adk_stale_agent/PROMPT_INSTRUCTION.txt b/contributing/samples/adk_stale_agent/PROMPT_INSTRUCTION.txt index dc0a650e26..6f2af605a3 100644 --- a/contributing/samples/adk_stale_agent/PROMPT_INSTRUCTION.txt +++ b/contributing/samples/adk_stale_agent/PROMPT_INSTRUCTION.txt @@ -59,13 +59,13 @@ Your job is to analyze a specific issue and report findings before taking action - **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, or ask for logs? + - **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)**: - **Action**: Call `add_stale_label_and_comment`. - - **Check**: If '{REQUEST_CLARIFICATION_LABEL}' is not in `current_labels`, call `add_label_to_issue`. + - **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." From 4df4ef66ee825d1eacb330687c775e2bb284ed59 Mon Sep 17 00:00:00 2001 From: Rohit Yanamadala Date: Wed, 17 Dec 2025 09:42:51 -0800 Subject: [PATCH 4/4] fix: refine prompt logic to prioritize internal discussions --- contributing/samples/adk_stale_agent/PROMPT_INSTRUCTION.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contributing/samples/adk_stale_agent/PROMPT_INSTRUCTION.txt b/contributing/samples/adk_stale_agent/PROMPT_INSTRUCTION.txt index 6f2af605a3..0cb204c9b9 100644 --- a/contributing/samples/adk_stale_agent/PROMPT_INSTRUCTION.txt +++ b/contributing/samples/adk_stale_agent/PROMPT_INSTRUCTION.txt @@ -63,11 +63,11 @@ Your job is to analyze a specific issue and report findings before taking action - **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` 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)**: - - **Report**: "Analysis for Issue #[number]: ACTIVE. Maintainer gave status update. No action." \ No newline at end of file + - **IF (Question == NO) OR (Internal Discussion Check == TRUE):** + - **Report**: "Analysis for Issue #[number]: ACTIVE. Maintainer gave status update or internal discussion detected. No action." \ No newline at end of file