fix(triage): greptile — share auto-close marker + gate reconsider job on closed state

Address the two remaining concerns from Greptile's summary:

1. close_low_quality_prs.py duplicated the 'I'm **Agent Shin**' literal
   from triage_with_llm.AGENT_SHIN_AUTO_CLOSE_MARKER. The reconsider
   provenance check keys off that exact phrase, so silently drifting the
   two strings would break reconsider for Greptile-closed PRs without any
   test catching it. Import the marker from the sibling module instead.

2. triage_reconsider.yml fired on any '@agent-shin reconsider' comment
   regardless of whether the PR/issue was open or closed. Gating the job
   on github.event.issue.state == 'closed' skips runner provisioning for
   stray comments on open items; the triage script still re-checks state
   (skip-not-closed) as defense in depth.
This commit is contained in:
mateo-berri 2026-05-19 07:05:44 +00:00
parent c5d5968e90
commit 684d8bb908
No known key found for this signature in database
2 changed files with 19 additions and 1 deletions

View file

@ -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"

View file

@ -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