Skip to content

Code agent dispatch should warn when issue already has open agent PRs #6852

Description

@fullsend-ai-retro

What happened

On issue #3, the code agent created PR #4 (approved, open). When /fs-code was invoked again, the dispatch routing log showed the skip-if-open-PRs check (Skipping code dispatch — issue has open PR(s)), but the dispatch proceeded anyway — likely because the /fs-code command overrides the skip guard. The code agent then created PR #5 with the same fix, leaving two duplicate open approved PRs for the same issue.

The dispatch route log shows: COMMENT_BODY: /fs-code Close PR #4 and send the same changes to openshift/console repo against main branch. The open-PR guard was bypassed because the user explicitly invoked /fs-code.

What could go better

When a /fs-code invocation is dispatched on an issue that already has open agent-authored PRs, the code agent (or its pre-flight script) should include context about the existing PRs in the agent's prompt. This would let the agent decide whether to update the existing PR, close it, or create a new one — rather than always creating a new PR alongside the existing one.

Confidence: Medium — the user explicitly re-invoked /fs-code with a different intent (close old PR, push to different repo), so the guard bypass was correct. But the agent lacked context about the existing PR and created a duplicate. This is related to but distinct from fullsend-ai/fullsend#1969, which covers re-creation after close-without-merge. Here, the first PR was never closed.

Uncertainty: Whether the fix belongs in the dispatch routing (passing existing PR context to the agent) or in the agent definition (instructing the agent to check for existing PRs).

Proposed change

When the code agent dispatch detects existing open agent-authored PRs for the same issue (the check that currently gates auto-dispatch), pass the PR numbers and branch names as environment variables to the agent run. For example:

EXISTING_AGENT_PRS=4
EXISTING_AGENT_BRANCHES=agent/3-helm-tab-visible-empty-repos

The code agent's harness or agent definition should then include instructions to:

  1. Check if the existing PR already contains the needed fix.
  2. If creating a new branch, consider whether the existing PR should be superseded (and note this in the new PR body).
  3. Avoid creating a duplicate PR with identical changes.

This change would live in the dispatch routing logic (fullsend-ai/fullsend reusable workflow) and the code agent definition (fullsend-ai/agents).

Validation criteria

On the next /fs-code re-invocation for an issue with existing open agent PRs: (1) The agent receives context about existing PRs. (2) The agent either updates the existing PR or explicitly supersedes it in the new PR body (e.g., 'Supersedes #4'). (3) No two identical-diff PRs are left open simultaneously. Measure over the next 10 re-dispatch events across enrolled repos.


Generated by retro agent from openshift-helm/console-fullsend#5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions