Skip to content

herd spawn / agent start: default --account to the caller's cswap account (RT-237) - #367

Merged
m4ttheweric merged 3 commits into
mainfrom
rt-237-herd-spawn-account
Sep 22, 2026
Merged

m4ttheweric merged 3 commits into
mainfrom
rt-237-herd-spawn-account

Conversation

@m4ttheweric

Copy link
Copy Markdown
Collaborator

Problem

A shepherd running under cswap run N has CLAUDE_CONFIG_DIR pointing at that account's session profile. rt herd spawn (and rt agent start) with no --account sent nothing to the daemon, which launched a bare claude on the global default profile. When the default profile is a different account, every worker silently ran as that account.

Fix

  • callerCswapAccount (lib/cswap.ts): when CLAUDE_CONFIG_DIR is set, runs cswap list --json in the caller's env and returns the active account's email.
  • rt herd spawn fills a missing --account from it.
  • rt agent start does the same for claude launches only; codex (by flag or agent.provider) is untouched since it rejects --account.
  • Default-profile callers are unchanged (no cswap call, no account passed), so agent.claude.account still applies there.
  • Explicit --account always wins.

Verification

  • New unit tests in lib/__tests__/cswap.test.ts, lib/__tests__/herd-cli.test.ts, commands/__tests__/agent.test.ts.
  • e2e/tests/herd.test.ts and e2e/tests/agent.test.ts green.
  • Against real cswap with account 1's session dir set, resolves to account 1 while the global default is account 4.

🤖 Generated with Claude Code

m4ttheweric and others added 2 commits September 22, 2026 13:45
A shepherd under cswap run sets CLAUDE_CONFIG_DIR, but the daemon launches a
bare claude that falls back to the global default profile, so workers could
land on a different account. The CLI now resolves the caller's active account
and passes it when --account is omitted.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Same gap as herd spawn: a cswap run caller's plain agent start landed on the
global default profile. Codex launches, by flag or agent.provider, are left
alone since codex rejects --account.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 45 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 80 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 0ce0cfb0-4079-4cd5-9c6d-328577fa3c46

📥 Commits

Reviewing files that changed from the base of the PR and between 8577a1c and 6a7acea.

📒 Files selected for processing (9)
  • commands/__tests__/agent.test.ts
  • commands/agent.ts
  • commands/herd.ts
  • lib/__tests__/cswap.test.ts
  • lib/__tests__/herd-cli.test.ts
  • lib/command-tree-def.ts
  • lib/cswap.ts
  • website/docs/reference/agent.mdx
  • website/docs/reference/herd/spawn.mdx

Comment @coderabbitai help to get the list of available commands.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@m4ttheweric
m4ttheweric merged commit c80bc51 into main Sep 22, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant