Summary
agmsg_resolve_project resolves any path to its enclosing git repository root, so every subdirectory of one repo collapses to a single agmsg project. As a result you cannot run two independent agmsg agents in different subdirectories of the same git repo — they all share one project key, one identity set, and one run-dir namespace.
Repro
# Inside the ag-dev-agent repo, with an agent already registered for it:
mkdir ag-dev-agent/codex-test
cd ag-dev-agent/codex-test
join.sh agmsg codex-test codex "$(pwd)"
whoami.sh "$(pwd)" codex
# => multiple=true agents=<parent-agent>,codex-test teams=agmsg
# project=/.../ag-dev-agent <-- NOT /.../ag-dev-agent/codex-test
git rev-parse --show-toplevel from the subdir returns the parent repo, and cd-ing in makes no difference — resolution is git-root based, not cwd based.
Root cause
Resolution order in scripts/lib/resolve-project.sh is marker → ancestor (git toplevel) → pwd. The ancestor step walks up to the git toplevel, so a subdir is always rewritten to the repo root before lookup. Two subdir registrations therefore resolve to the same project.
Why it exists / trade-off
The ancestor step is deliberate: it lets a session started anywhere inside a repo (a subdir, a worktree) still find that project's registration (#92 / #110). That convenience is good for the common "one agent per repo" case, but it has an unintended side effect: intentional per-subdir independence is impossible.
There is a partial escape hatch — AGMSG_RESOLVE_PROJECT=0 forces the raw pwd — but it is not wired through the SessionStart hook / monitor path, and for it to work every command (join, send, whoami, delivery, the bridge) would have to agree on the raw path, so it isn't usable for an independent subdir agent out of the box. Today the only real workaround is git init <subdir> so the subdir becomes its own git root.
Proposed fix
Prefer an exact-path registration when one exists, before walking up to the git root. i.e. resolution order becomes:
marker → exact pwd if it is already a registered project → ancestor (git toplevel) → pwd
- Preserves the "start from anywhere in the repo" convenience when the subdir is not independently registered (falls through to the ancestor as today).
- Lets an explicitly-joined subdir stay its own project (respects intent).
- Backward compatible: repos with a single root registration behave exactly as before.
Impact
Surfaced while setting up an isolated codex-test agent under the ag-dev-agent repo for Codex monitor (#41) validation — the subdir collapsed onto the repo's existing (dead) agent, producing an ambiguous multiple=true identity that the SessionStart/bridge path can't auto-resolve.
Summary
agmsg_resolve_projectresolves any path to its enclosing git repository root, so every subdirectory of one repo collapses to a single agmsg project. As a result you cannot run two independent agmsg agents in different subdirectories of the same git repo — they all share one project key, one identity set, and one run-dir namespace.Repro
git rev-parse --show-toplevelfrom the subdir returns the parent repo, andcd-ing in makes no difference — resolution is git-root based, not cwd based.Root cause
Resolution order in
scripts/lib/resolve-project.shis marker → ancestor (git toplevel) → pwd. The ancestor step walks up to the git toplevel, so a subdir is always rewritten to the repo root before lookup. Two subdir registrations therefore resolve to the same project.Why it exists / trade-off
The ancestor step is deliberate: it lets a session started anywhere inside a repo (a subdir, a worktree) still find that project's registration (#92 / #110). That convenience is good for the common "one agent per repo" case, but it has an unintended side effect: intentional per-subdir independence is impossible.
There is a partial escape hatch —
AGMSG_RESOLVE_PROJECT=0forces the raw pwd — but it is not wired through the SessionStart hook / monitor path, and for it to work every command (join,send,whoami,delivery, the bridge) would have to agree on the raw path, so it isn't usable for an independent subdir agent out of the box. Today the only real workaround isgit init <subdir>so the subdir becomes its own git root.Proposed fix
Prefer an exact-path registration when one exists, before walking up to the git root. i.e. resolution order becomes:
Impact
Surfaced while setting up an isolated
codex-testagent under theag-dev-agentrepo for Codex monitor (#41) validation — the subdir collapsed onto the repo's existing (dead) agent, producing an ambiguousmultiple=trueidentity that the SessionStart/bridge path can't auto-resolve.