Skip to content

dev-lead: in-place gh pr checkout clobbers the agent's own prompt/script files on older PR branches #448

Closed

Description

@don-petry

Summary

The dev-lead agent fails on review/CI intents whenever it operates on a PR branch that predates one of the agent's own prompt or script files. The agent's prompt templates (prompts/dev-lead/*.md) and scripts (scripts/*) live in the same repository it operates on. When a review/CI intent runs, the agent does an in-place gh pr checkout, which switches the working tree to the PR branch. If that branch was cut before a given prompt was added, the file vanishes mid-run and the script aborts.

Observed failure

Run: https://github.com/petry-projects/.github-private/actions/runs/27077585464/job/79917480705

Switched to a new branch 'fix/gemini-fallback-quota'
scripts/dev-lead-fix-reviews.sh: line 51: prompts/dev-lead/on-mention.md: No such file or directory
scripts/engine.sh: line 296: /tmp/dev-lead-on-mention-prompt-2522.md: No such file or directory
##[error]Process completed with exit code 1.

git ls-tree origin/fix/gemini-fallback-quota -- prompts/dev-lead/on-mention.md returns nothing, confirming the file is absent on the PR branch.

Root cause

gh pr checkout mutates the working tree in place. Because the agent's own assets live in that same tree, any PR branch older than a referenced prompt/script breaks the run. This is a self-referential checkout hazard, most acute when .github-private operates on its own PRs. It affects every script that checks out a PR branch in place:

  • scripts/dev-lead-fix-reviews.sh (intents: fix-reviews, on-mention, fix-bot-comment, review-changes)
  • scripts/dev-lead-fix-ci.sh (intent: fix-ci)

Fix

Check out the PR branch in an isolated git worktree instead of switching the agent's working tree in place. The agent checkout (and its prompts/, scripts/) stays on the agent ref; the engine runs inside the worktree against the PR branch; prompt templates are read via an absolute PROMPTS_DIR resolved before entering the worktree. The worktree is removed on exit.

This eliminates the entire class of "agent assets disappear when checking out an old PR branch" failures.

Activity

  1. 10 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugBug reports

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions