fix(team-lead): seed GENIE_AGENT_NAME from leader, not cwd basename#1434
Conversation
See preceding attempt commit message for full context. Re-commit after biome auto-format fixed knip.json. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request updates buildTeamLeadCommand to ensure that the GENIE_AGENT_NAME environment variable matches the --agent-name flag, preventing self-loop messaging issues caused by identity mismatches. It removes the dependency on the current working directory's basename for the agent name and adds regression tests to verify this behavior. Additionally, src/lib/design-tokens.ts is added to the knip ignore list. I have no feedback to provide.
…urface (#1436) Followup to #1434. The original commit replaced the function's header comment with a 9-line forensic explanation of the echo bug; that wide rewrite created merge conflicts on every parallel branch that only kept the original 1-line comment (feat/channel-envelope- inbox, wish/invincible-genie, fix/1296-1298-team-lead-role-vs- identity were all blocked). Shrunk the new comment to 5 lines and dropped the inline 6-line basename-history comment — they were narrative, not load-bearing. Issue ref (#1434) is enough breadcrumb for anyone who wants the detail; PR description carries the full root cause analysis. Behavior unchanged. 19/19 tests still pass. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…1434) See preceding attempt commit message for full context. Re-commit after biome auto-format fixed knip.json. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…urface (#1436) Followup to #1434. The original commit replaced the function's header comment with a 9-line forensic explanation of the echo bug; that wide rewrite created merge conflicts on every parallel branch that only kept the original 1-line comment (feat/channel-envelope- inbox, wish/invincible-genie, fix/1296-1298-team-lead-role-vs- identity were all blocked). Shrunk the new comment to 5 lines and dropped the inline 6-line basename-history comment — they were narrative, not load-bearing. Issue ref (#1434) is enough breadcrumb for anyone who wants the detail; PR description carries the full root cause analysis. Behavior unchanged. 19/19 tests still pass. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Summary
Closes the `genie send` echo loop surfaced during dog-food. Every `genie send 'msg' --to ` from the felipe team-lead echoed the message back to the operator's own conversation as `<teammate-message teammate_id="workspace" ...>`.
Root cause: `buildTeamLeadCommand` seeded `GENIE_AGENT_NAME` from `basename(process.cwd())` while `--agent-name` came from the leader name. When cwd basename ≠ leader (e.g. cwd=`/home/genie/workspace` → `workspace`, leader=`felipe`), genie CLI labeled `from=workspace`, the existing `from === to` self-loop guards (msg.ts:555, protocol-router.ts:500) saw `'workspace' !== 'felipe'`, the message landed in `~/.claude/teams/felipe/inboxes/felipe.json`, and the operator's own CC instance polled it back as a teammate-message.
Changes
Reproduction
Direct trace from the felipe team-lead while diagnosing:
After the fix, env-side and flag-side identities agree, the existing `from === to` guards fire correctly, and the echo disappears.
Validation
Defense-in-depth follow-up (not in this PR)
Trace report suggested a second guard in `bridgeToNativeInbox` that reads parent CC's `--agent-name` from `/proc//cmdline` and bails if recipient matches, even when `from` disagrees. Worth tracking but not strictly needed once env/flag identities align — leaving for a follow-up so this PR stays cirurgical.
Note on PR #1433
Earlier branch (`fix/team-lead-genie-agent-name-mismatch`) accumulated unrelated commits from a stale base + a hook fix that landed independently as #939e8a8b. Closed and re-cut clean from `origin/dev` here.
🤖 Generated with Claude Code