Skip to content

AO session branch namespace blocks child PR branches #308

@neversettle17-101

Description

@neversettle17-101

Bug

AO tells worker sessions to create PR branches under their session branch namespace, for example ao/agent-orchestrator-7/fix-terminal-clipboard-305, but the session root branch itself is created as ao/agent-orchestrator-7. Git stores branch refs path-like, so an existing refs/heads/ao/agent-orchestrator-7 prevents creating refs/heads/ao/agent-orchestrator-7/<topic>.

Observed in session agent-orchestrator-7: the agent attempted:

git checkout -b ao/agent-orchestrator-7/fix-terminal-clipboard-305

Git failed with:

fatal: cannot lock ref 'refs/heads/ao/agent-orchestrator-7/fix-terminal-clipboard-305': 'refs/heads/ao/agent-orchestrator-7' exists; cannot create 'refs/heads/ao/agent-orchestrator-7/fix-terminal-clipboard-305'

The agent then fell back to fix-terminal-clipboard-305, opened PR #306 from that branch, and AO did not attach PR facts to the session because the SCM observer only attributes PRs whose source branch equals the stored session branch or has it as a / child prefix.

Analyzed against: local main checkout on 2026-06-18
Confidence: High

Reproduction

  1. Spawn a worker session whose default branch is ao/<session-id>.
  2. From that worktree, try to create ao/<session-id>/<topic>.
  3. Git rejects the child branch because refs/heads/ao/<session-id> already exists.
  4. If the agent creates a fallback branch outside the namespace and opens a PR, AO's observer does not attribute the PR to the session.

Root Cause

  • Worker branch defaults to ao/<session-id> in backend/internal/session_manager/manager.go.
  • Worker instructions ask agents to use <session-branch>/<topic> for additional PRs.
  • Git cannot have both refs/heads/ao/<session-id> and refs/heads/ao/<session-id>/<topic>.
  • PR discovery in backend/internal/observe/scm/observer.go relies on exact or slash-child source branch matching, so fallback branches outside the namespace remain untracked.

Fix

The fix helps by making AO's branch convention valid in Git and matching AO's PR discovery logic.

Before:

session branch: ao/agent-orchestrator-7
expected child PR branch: ao/agent-orchestrator-7/fix-terminal-clipboard-305

Git rejects that because refs/heads/ao/agent-orchestrator-7 already exists, so it cannot also create refs/heads/ao/agent-orchestrator-7/fix-terminal-clipboard-305.

After:

session branch: ao/agent-orchestrator-7/root
sibling PR branch: ao/agent-orchestrator-7/fix-terminal-clipboard-305

Now Git can store both branches:

refs/heads/ao/agent-orchestrator-7/root
refs/heads/ao/agent-orchestrator-7/fix-terminal-clipboard-305

AO also treats the parent namespace ao/agent-orchestrator-7 as owned by the session, so GitHub PR heads under that namespace are attributed back to agent-orchestrator-7.

Impact

  • Worker sessions can create PRs successfully but AO may not discover or display them.
  • Summary/activity tabs drift because PR facts are never inserted into SQLite.
  • Agents following AO's own prompt hit a Git ref layout error.

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions