From 4a3eb4364f266b082e5d6bb549b5993f0493dbae Mon Sep 17 00:00:00 2001 From: John Collier Date: Fri, 21 Aug 2026 15:38:32 -0400 Subject: [PATCH] fix(grillme): pin each turn to the triggering PR Turn 2 on #7 listed open PRs after PR_NUMBER was unset in the sandbox Bash tool, then grilled #9. Inline comments 422'd (wrong files) and landed as an issue comment that claimed Turn 1. - Resolve the target from GITHUB_ISSUE_URL; never gh pr list to pick - Count existing threads before calling it turn 1 - Drop chain-of-thought before the Grillme heading - Surface a warning when GitHub rejects inline comment paths Co-authored-by: Cursor --- .fullsend/custom/agents/grillme.md | 38 +++++++++++++++++++----- .fullsend/custom/scripts/post-grillme.sh | 14 ++++++++- 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/.fullsend/custom/agents/grillme.md b/.fullsend/custom/agents/grillme.md index 84086fc..ebcc4d8 100644 --- a/.fullsend/custom/agents/grillme.md +++ b/.fullsend/custom/agents/grillme.md @@ -29,16 +29,31 @@ files. A deterministic post-script posts your output as a PR review. | Source | How to read it | |--------|----------------| -| PR / issue number | `PR_NUMBER` or `ISSUE_NUMBER` | +| Triggering PR | `GITHUB_ISSUE_URL` (always set). Number is the last path segment. | +| PR / issue number | `PR_NUMBER` or `ISSUE_NUMBER` if set; otherwise parse `GITHUB_ISSUE_URL` | | Repo | `REPO_FULL_NAME` | | Answer text after `/fs-grillme` | `HUMAN_INSTRUCTION` (may be empty on the first turn) | -| Prior grill turns | Review threads whose first comment contains `` | -| Change under review | PR diff, title/body, and relevant files in the workspace | +| Prior grill turns | Review threads on **that same PR** whose first comment contains `` | +| Change under review | `gh pr diff ` / `gh pr view ` of **that PR**, plus files in the workspace | | Run URL | `RUN_URL` (include in footer context only if useful) | +**Resolve the target PR first, before any other `gh` call:** + +```bash +# .env.d may not be sourced into Bash tool shells — derive every time. +PR="${PR_NUMBER:-${ISSUE_NUMBER:-}}" +if [[ ! "${PR}" =~ ^[0-9]+$ ]]; then + PR="$(basename "${GITHUB_ISSUE_URL:-}")" +fi +echo "Grilling PR ${PR} (${GITHUB_ISSUE_URL:-unset})" +``` + +That number is the PR that triggered this run. **Do not** `gh pr list` to pick a target. **Do not** grill a different open PR, even if it looks more recently updated. + If `HUMAN_INSTRUCTION` is `none`, empty, or unset, treat this as a **new or continuing turn without a new answer** — usually the opening questions, or the -next turn after reviewing replies on existing threads. +next turn after reviewing replies on existing threads. An empty instruction is +**not** a reason to switch PRs. ## Session lifecycle @@ -58,10 +73,11 @@ diff lines. Engineers reply directly to each inline comment, then trigger ## Procedure -1. **Orient.** Identify the PR, read its title/body, and understand what - changed (`gh pr diff`, `gh pr view`, key files in the workspace). If - `openspec/` is in the diff, treat those artifacts as first-class decision - surfaces alongside the code. +1. **Orient.** Resolve the triggering PR number as above. Then + `gh pr diff "$PR"` / `gh pr view "$PR"` and read the relevant files. + If `openspec/` is in **this** PR's diff, treat those artifacts as + first-class decision surfaces. Count existing grillme threads on this + PR: if any exist, this is **not** turn 1. 2. **Load review threads.** Query the PR's review threads to find your prior grillme comments. Split `REPO_FULL_NAME` into owner/repo, then run: @@ -123,6 +139,10 @@ Your final assistant message has two parts: The text before the JSON block becomes the PR review body. The post-script adds the `` marker and footer. +**Your final message must start with the heading below.** Do not include +chain-of-thought, tool narration, or "let me analyze" preamble. The +post-script posts this text; anything before the heading is dropped. + **First turn:** ```markdown @@ -235,6 +255,8 @@ All three fields are optional. Omit any that have no entries. findings. Stay on decisions, intent, and architectural alignment. - Do not call `gh pr review`, `gh pr comment`, or `gh issue comment` — the post-script owns GitHub writes. +- **Do not grill a different PR** than the one in `GITHUB_ISSUE_URL`. + `gh pr list` is not how you choose a target. - Do not ask about facts you can verify from the PR or filesystem. - If the PR is empty or the change is unclear, ask one clarifying question about intent/scope. diff --git a/.fullsend/custom/scripts/post-grillme.sh b/.fullsend/custom/scripts/post-grillme.sh index 39d7e37..e63ad58 100755 --- a/.fullsend/custom/scripts/post-grillme.sh +++ b/.fullsend/custom/scripts/post-grillme.sh @@ -28,6 +28,7 @@ if [[ -z "${_TOKEN}" ]]; then fi echo "::add-mask::${_TOKEN}" export GH_TOKEN="${_TOKEN}" +RUN_URL="${RUN_URL:-${STATUS_RUN_URL:-}}" # ---------- Derive ISSUE_NUMBER ---------- # The pre-script writes to GITHUB_ENV, but the harness runner executes @@ -115,6 +116,14 @@ if printf '%s' "${SUMMARY}" | grep -qE '```json:grillme'; then MARKDOWN_BODY=$(printf '%s' "${MARKDOWN_BODY}" | sed -e 's/[[:space:]]*$//') fi +# Drop chain-of-thought preamble. The review body starts at the Grillme heading. +if printf '%s' "${MARKDOWN_BODY}" | grep -qE '^#{1,3}[[:space:]]+.*Grillme'; then + MARKDOWN_BODY=$(printf '%s' "${MARKDOWN_BODY}" | awk ' + /^#{1,3}[[:space:]]+.*Grillme/ { keep=1 } + keep { print } + ') +fi + # ---------- Determine footer ---------- is_session_complete=false @@ -161,7 +170,10 @@ if [[ "${has_new_comments}" == "true" ]]; then echo "PR review posted with ${comment_count} inline comment(s)" else echo "WARNING: Failed to post PR review with inline comments — falling back to issue comment" - printf '%s' "${REVIEW_BODY}" | gh issue comment "${ISSUE_NUMBER}" --repo "${REPO_FULL_NAME}" --body-file - + FALLBACK="${REVIEW_BODY} + +⚠️ Inline comments were not pinned — GitHub rejected the paths/lines (they may not be in this PR's diff)." + printf '%s' "${FALLBACK}" | gh issue comment "${ISSUE_NUMBER}" --repo "${REPO_FULL_NAME}" --body-file - fi else printf '%s' "${REVIEW_BODY}" | gh issue comment "${ISSUE_NUMBER}" --repo "${REPO_FULL_NAME}" --body-file -