From 3ec7ae3b8d532ed4b60786201a78e980dfc56cf3 Mon Sep 17 00:00:00 2001 From: Rohit Yanamadala Date: Mon, 5 Jan 2026 10:45:18 -0800 Subject: [PATCH] fix: ignore adk-bot administrative actions in stale agent Merge https://github.com/google/adk-python/pull/4041 ## Description This PR fixes false positive stale labels in the `adk_stale_agent`. Previously, the agent was incorrectly identifying the issue as "stale" because it treated `adk-bot` (acting via PAT) as a human maintainer. Since the username lacks the `[bot]` suffix, administrative alerts (e.g., "Notification: The author has updated...") were counted as maintainer activity, inadvertently triggering the stale logic immediately after an author's edit. ## Changes Made - **Hardcoded Bot Exclusion:** Added `BOT_NAME = "adk-bot"` and updated history parsing loops (comments, edits, timeline) to explicitly ignore this actor. - **Bot Alert Skip:** Added logic to `continue` (skip) processing the bot's specific "Notification" comment so it is not recorded as the last activity on the timeline. Co-authored-by: Xuan Yang COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/4041 from ryanaiagent:fix/stale-bot-logic f1500a94cb8c9d5090e9b1ef29690506120f7749 PiperOrigin-RevId: 852365962 --- contributing/samples/adk_stale_agent/agent.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/contributing/samples/adk_stale_agent/agent.py b/contributing/samples/adk_stale_agent/agent.py index 2535f9cf..e9fbe49b 100644 --- a/contributing/samples/adk_stale_agent/agent.py +++ b/contributing/samples/adk_stale_agent/agent.py @@ -49,6 +49,7 @@ logger = logging.getLogger("google_adk." + __name__) BOT_ALERT_SIGNATURE = ( "**Notification:** The author has updated the issue description" ) +BOT_NAME = "adk-bot" # --- Global Cache --- _MAINTAINERS_CACHE: Optional[List[str]] = None @@ -246,8 +247,9 @@ def _build_history_timeline( if BOT_ALERT_SIGNATURE in c_body: if last_bot_alert_time is None or c_time > last_bot_alert_time: last_bot_alert_time = c_time + continue - if actor and not actor.endswith("[bot]"): + if actor and not actor.endswith("[bot]") and actor != BOT_NAME: # Use edit time if available, otherwise creation time e_time = c.get("lastEditedAt") actual_time = dateutil.parser.isoparse(e_time) if e_time else c_time @@ -263,7 +265,7 @@ def _build_history_timeline( if not e: continue actor = e.get("editor", {}).get("login") - if actor and not actor.endswith("[bot]"): + if actor and not actor.endswith("[bot]") and actor != BOT_NAME: history.append({ "type": "edited_description", "actor": actor, @@ -285,7 +287,7 @@ def _build_history_timeline( label_events.append(time_val) continue - if actor and not actor.endswith("[bot]"): + if actor and not actor.endswith("[bot]") and actor != BOT_NAME: pretty_type = ( "renamed_title" if etype == "RenamedTitleEvent" else "reopened" )