Skip to content

Commit 3ec7ae3

Browse files
ryanaiagentxuanyang15
authored andcommitted
fix: ignore adk-bot administrative actions in stale agent
Merge #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 <xygoogle@google.com> COPYBARA_INTEGRATE_REVIEW=#4041 from ryanaiagent:fix/stale-bot-logic f1500a9 PiperOrigin-RevId: 852365962
1 parent 6b7386b commit 3ec7ae3

File tree

1 file changed

+5
-3
lines changed
  • contributing/samples/adk_stale_agent

1 file changed

+5
-3
lines changed

contributing/samples/adk_stale_agent/agent.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
BOT_ALERT_SIGNATURE = (
5050
"**Notification:** The author has updated the issue description"
5151
)
52+
BOT_NAME = "adk-bot"
5253

5354
# --- Global Cache ---
5455
_MAINTAINERS_CACHE: Optional[List[str]] = None
@@ -246,8 +247,9 @@ def _build_history_timeline(
246247
if BOT_ALERT_SIGNATURE in c_body:
247248
if last_bot_alert_time is None or c_time > last_bot_alert_time:
248249
last_bot_alert_time = c_time
250+
continue
249251

250-
if actor and not actor.endswith("[bot]"):
252+
if actor and not actor.endswith("[bot]") and actor != BOT_NAME:
251253
# Use edit time if available, otherwise creation time
252254
e_time = c.get("lastEditedAt")
253255
actual_time = dateutil.parser.isoparse(e_time) if e_time else c_time
@@ -263,7 +265,7 @@ def _build_history_timeline(
263265
if not e:
264266
continue
265267
actor = e.get("editor", {}).get("login")
266-
if actor and not actor.endswith("[bot]"):
268+
if actor and not actor.endswith("[bot]") and actor != BOT_NAME:
267269
history.append({
268270
"type": "edited_description",
269271
"actor": actor,
@@ -285,7 +287,7 @@ def _build_history_timeline(
285287
label_events.append(time_val)
286288
continue
287289

288-
if actor and not actor.endswith("[bot]"):
290+
if actor and not actor.endswith("[bot]") and actor != BOT_NAME:
289291
pretty_type = (
290292
"renamed_title" if etype == "RenamedTitleEvent" else "reopened"
291293
)

0 commit comments

Comments
 (0)