diff --git a/.github/scripts/close_low_quality_prs.py b/.github/scripts/close_low_quality_prs.py index a05636d5376..66c6d03a467 100644 --- a/.github/scripts/close_low_quality_prs.py +++ b/.github/scripts/close_low_quality_prs.py @@ -41,8 +41,19 @@ import json import re import subprocess import sys +from pathlib import Path from typing import Iterable +# Share the auto-close marker with the sibling Agent Shin script instead of +# duplicating the literal — the reconsider provenance check +# (`was_auto_closed_by_agent_shin`) keys off this exact phrase, so a drift +# between the two files would silently break reconsider for Greptile-closed +# PRs without any test catching it. +_SCRIPTS_DIR = Path(__file__).resolve().parent +if str(_SCRIPTS_DIR) not in sys.path: + sys.path.insert(0, str(_SCRIPTS_DIR)) +from triage_with_llm import AGENT_SHIN_AUTO_CLOSE_MARKER # noqa: E402 + # Greptile's GitHub App appears as `greptile-apps[bot]` in REST API comments # and `greptile-apps` in `gh pr view --json` output. Accept either form. GREPTILE_BOT_LOGINS = frozenset({"greptile-apps", "greptile-apps[bot]"}) @@ -245,7 +256,7 @@ def close_pr( return comment_body = ( - "👋 Hi, thanks for the PR! I'm **Agent Shin**, the automated triage " + f"👋 Hi, thanks for the PR! {AGENT_SHIN_AUTO_CLOSE_MARKER}, the automated triage " "bot for this repository. Closing as part of automated PR triage.\n\n" f"Greptile's most recent review scored this PR **{score}/5**, below " f"our merge bar of **{threshold}/5**.\n\n" diff --git a/.github/workflows/triage_reconsider.yml b/.github/workflows/triage_reconsider.yml index 69ba73d224d..7d2ed01eb41 100644 --- a/.github/workflows/triage_reconsider.yml +++ b/.github/workflows/triage_reconsider.yml @@ -32,9 +32,16 @@ permissions: jobs: reconsider: + # Reconsider only makes sense on a CLOSED PR/issue — its job is to + # re-evaluate and (on pass) reopen. Gating the job here means a + # stray `@agent-shin reconsider` on an open PR/issue exits before + # checkout/Python/pip ever runs, instead of spinning up the runner + # to be a no-op. The triage script itself still re-checks state + # (`skip-not-closed`) as defense in depth. if: | github.repository == 'BerriAI/litellm' && contains(github.event.comment.body, '@agent-shin reconsider') + && github.event.issue.state == 'closed' runs-on: ubuntu-latest steps: - name: Authorize commenter