-
Notifications
You must be signed in to change notification settings - Fork 512
Description
Description
When an agent is spawned via ao spawn, ao creates a worktree with a branch name like feat/issue-2 and stores it in session metadata. However, coding agents (Codex, Claude Code) often rename the branch before pushing (e.g. feat/2, feat/1-followup-after-acceptance).
The detectPR method in scm-github searches by --head session.branch, which uses the original branch name from metadata. Since the PR was opened on the renamed branch, the lookup returns nothing. This means:
- Session status never transitions from
workingtopr_open - No webhook notifications fire for PR events
- CI status, review state, and merge detection all break
Reproduction
ao spawn project 2(creates branchfeat/issue-2)- Agent renames branch to
feat/2and pushes - Agent opens PR from
feat/2 ao statusshows PR=--, CI=--, status=working indefinitely- No webhook events fire
Suggested Fix
Option A (recommended): On each lifecycle poll, re-detect the actual branch from the git worktree (git -C <worktree> branch --show-current) and update session metadata if it changed.
Option B: Lock the branch name so agents can't rename it (less robust, agents may still force-push to new branches).
Impact
All webhook-driven automation (notifications, CI self-healing, review routing) is silently broken when agents rename branches. This is the default behavior for Codex agents.
Workaround
Manually patch session metadata files in ~/.agent-orchestrator/*/sessions/ to match actual branch names.