fix: skip code agent when human PR already exists for issue#473
fix: skip code agent when human PR already exists for issue#473fullsend-ai-coder[bot] wants to merge 1 commit into
Conversation
The pre-code script now checks for existing open PRs linked to the target issue before the sandbox is created. If a human-authored PR is found (not from the fullsend bot), the script applies a "pr-open" label and posts a comment linking the existing PR(s), then exits cleanly — preventing the code agent from creating a duplicate competing PR. The check is best-effort: it only runs when GH_TOKEN is available and can be overridden with CODE_FORCE=true (set when a user comments `/code --force` on the issue). Bot-authored PRs are filtered out so the agent can still update its own previous work. Uses gh's built-in --jq flag for filtering, avoiding a standalone jq dependency. Note: go-test and go-vet could not run (Go not available in sandbox). post-triage-test.sh has pre-existing failures (jq not available in sandbox). pre-code-test.sh passed. Manual verification of Go tests is required. Closes #460
Site previewPreview: https://0ee55c09-site.fullsend-ai.workers.dev Commit: |
There was a problem hiding this comment.
Review: #473
Head SHA: 2858f68
Timestamp: 2026-04-27T21:00:00Z
Outcome: request-changes
Summary
The PR adds a pre-code check to detect existing human PRs before the code agent runs, along with comprehensive tests. The intent aligns well with issue #460. However, the core feature does not work as implemented: the script exits 0 when human PRs are found, but both invocation paths (GHA workflow steps and the harness CLI) interpret exit 0 as "proceed" — the code agent will still run and may create a duplicate PR. Additionally, the GH_TOKEN environment variable the script requires is not set in the workflow step where pre-code.sh runs, so the check is always skipped in production.
Findings
Critical
- [Correctness]
internal/scaffold/fullsend-repo/scripts/pre-code.sh:113— Script exits 0 when existing human PRs are found, but this does not prevent the code agent from running. In the GHA workflow (code.yml), exit 0 from the "Validate inputs" step causes subsequent steps (including "Run code agent") to proceed. In the harness CLI (run.go:174-186), exit 0 from the pre-script likewise continues to sandbox creation and agent execution. The PR description claims "exits cleanly — preventing the code agent from creating a duplicate competing PR" but this is incorrect — the core feature is non-functional.
Remediation: The script needs a mechanism to signal "skip" to the caller. Options: (1) exit with a non-zero code and addcontinue-on-error: trueto the workflow step plus a conditionalif:on subsequent steps checking the step outcome; (2) write a step output (via$GITHUB_OUTPUT) and gate the agent step withif: steps.validate.outputs.skip != 'true'; (3) in the harness path, define a convention (e.g., exit code 78 or a sentinel file) thatrun.gochecks to skip agent execution without treating it as a failure.
High
- [Correctness]
internal/scaffold/fullsend-repo/.github/workflows/code.yml:96-101— The "Validate inputs" step does not setGH_TOKENin itsenvblock. The script checks${GH_TOKEN:-}and exits early with "GH_TOKEN not set — skipping existing-PR check" when it is empty. In GitHub Actions,GITHUB_TOKENis available butGH_TOKENis not (they are different variables). TheghCLI accepts both, but the explicit bash check forGH_TOKENmeans the PR-detection feature is dead code in the production workflow.
Remediation: Either addGH_TOKEN: ${{ steps.sandbox-token.outputs.token }}(or${{ github.token }}) to the step's env block, or change the script to check forGITHUB_TOKENas a fallback (e.g.,${GH_TOKEN:-${GITHUB_TOKEN:-}}).
Medium
- [Correctness]
internal/scaffold/fullsend-repo/scripts/pre-code.sh:82— The search query--search "${ISSUE_NUMBER} in:body,title"performs text matching, so low issue numbers (e.g., #1, #4) will match any PR that coincidentally contains that digit in its title or body. This could cause false positives that incorrectly block the code agent (once the exit-code issue is fixed).
Remediation: Consider a more targeted search strategy, such as searching forCloses #N,Fixes #N, orResolves #Npatterns, or using the GitHub timeline/events API to find PRs actually linked to the issue.
Low
-
[Style/conventions]
Makefile:28— The help text forscript-teststill reads "Run shell script tests (post-triage, validate-output-schema)" and does not mention the newly addedpre-code-test.sh.
Remediation: Update the help echo to include pre-code. -
[Correctness]
internal/scaffold/fullsend-repo/scripts/pre-code-test.sh:195-199— The "bot-pr-does-not-block" test passes emptypr_list_outputrather than providing bot-authored PR data and verifying the--jqfilter excludes it. The test validates the "no results" path but does not exercise the actual bot-filtering logic. Since the--jqfilter runs insideghand the mock replacesgh, this filter is untested.
Remediation: Consider an integration-level note or a separate test that validates the jq expression against sample JSON.
Footer
Outcome: request-changes
This review applies to SHA 2858f6857163de8bfff4503bd99f540a17013843. Any push to the PR head clears this review and requires a new evaluation.
|
/fix Rebase onto main and resolve conflicts. Fix critical issue number substring matching false positives by replacing |
Replace the bash pre-code.sh script with a Go CLI command that runs in the workflow before sandbox creation. This addresses the review findings on PR #473: - Fix skip semantics: write skip=true to GITHUB_OUTPUT and gate all downstream workflow steps with if: steps.gate.outputs.skip != 'true' - Fix dead GH_TOKEN: pass push-token to the gate step env - Fix search false positives: use timeline API instead of text search - Add cross-validation between ISSUE_NUMBER/REPO_FULL_NAME/GITHUB_ISSUE_URL - Add bot-login regex validation against injection Extend forge.Client with ListIssueTimeline, AddIssueComment, EnsureLabel, and AddIssueLabels. Implement on both LiveClient (GitHub API) and FakeClient (test double). Closes #460 Signed-off-by: Wayne Sun <gsun@redhat.com>
|
/fix |
1 similar comment
|
/fix |
The pre-code script now checks for existing open PRs linked to the target issue before the sandbox is created. If a human-authored PR is found (not from the fullsend bot), the script applies a "pr-open" label and posts a comment linking the existing PR(s), then exits cleanly — preventing the code agent from creating a duplicate competing PR.
The check is best-effort: it only runs when GH_TOKEN is available and can be overridden with CODE_FORCE=true (set when a user comments
/code --forceon the issue). Bot-authored PRs are filtered out so the agent can still update its own previous work.Uses gh's built-in --jq flag for filtering, avoiding a standalone jq dependency.
Note: go-test and go-vet could not run (Go not available in sandbox). post-triage-test.sh has pre-existing failures (jq not available in sandbox). pre-code-test.sh passed. Manual verification of Go tests is required.
Closes #460
Changed files
Makefileinternal/scaffold/fullsend-repo/scripts/pre-code-test.shinternal/scaffold/fullsend-repo/scripts/pre-code.shCloses #460
Post-script verification
agent/460-skip-duplicate-human-pr)de54df26a206ba6edb543a5cfd22bed59dffa7b9..HEAD)Created by fullsend code agent