Skip to content

feat(anthropic): multi-account support (ANTHROPIC_TOKEN_<NAME> / anthropic-profiles) - #154

Open
Itstommy10 wants to merge 1 commit into
onllm-dev:mainfrom
Itstommy10:feature/anthropic-multi-account
Open

Itstommy10 wants to merge 1 commit into
onllm-dev:mainfrom
Itstommy10:feature/anthropic-multi-account

Conversation

@Itstommy10

Copy link
Copy Markdown

Summary

Adds multi-account support for the Anthropic (Claude) provider, modeled on the existing Codex/MiniMax multi-account support.

  • The primary account (ANTHROPIC_TOKEN or auto-detected Claude Code credentials) is unchanged and stored as account_id = 0; all existing data stays with it.
  • Extra accounts: ANTHROPIC_TOKEN_<NAME> (+ optional ANTHROPIC_REFRESH_TOKEN_<NAME>) seeds <data dir>/anthropic-profiles/<name>.json, or drop a Claude Code .credentials.json there directly. Docker friendly (/data volume).
  • Each account gets its own provider_accounts row, client, tracker and agent. Snapshots and reset cycles are stored per account (account_id column, migration with default 0).
  • OAuth refresh/rotation per account: rotated tokens are written only to that account's profile file, so one-time-use refresh tokens are never shared. The env seed is fingerprinted, so restarts keep rotated tokens and changing the env value re-seeds.
  • Statusline bridge, Claude Code detection and sessions stay on the primary (local) account.
  • Web: ?account=<id> on current/history/cycles, GET /api/anthropic/accounts, anthropicAccounts in the all-providers payload, per-account Telemetry/Dashboard toggles in Settings > Providers (anthropic:<id>), per-account cards on the Anthropic tab and in the All view.
  • Docs: docs/ANTHROPIC_ACCOUNTS.md, README env table.

Not in this PR

Insights, cycle overview, menubar, logging history and metrics remain primary-account only. Accounts are loaded at startup (restart to apply). At most 20 extra accounts.

Test plan

  • New tests: store account isolation, profile seeding/rotation/re-seed, profile loading, per-account credentials writer, agent stores under its account, web current/both/history/accounts endpoints, per-account toggle
  • go vet ./... and go test -race ./... (4754 passed, 0 failed)
  • docker build
  • Manual check with two real Claude accounts

@codecov

codecov Bot commented Oct 21, 2026

Copy link
Copy Markdown

@Itstommy10

Copy link
Copy Markdown
Author

The only failing check is Test (Windows) → TestDaemonChildRun_DefaultPassword, which fails in TempDir RemoveAll cleanup: ... The directory is not empty after the test body passed. This looks like the known Windows file-handle race in the daemon subprocess tests (e.g. TestDaemonChildRun_DebugModeAllProvidersWithCopilot failed the same way on fix/menubar-never-blank-cursor-codex-resets). Could you re-run the job? Happy to adjust if it turns out to be related.

Track several Claude accounts at once. The primary account (ANTHROPIC_TOKEN
or auto-detected Claude Code credentials) is unchanged and stored as
account_id 0. Extra accounts come from ANTHROPIC_TOKEN_<NAME> (+ optional
ANTHROPIC_REFRESH_TOKEN_<NAME>) env vars, which seed
<data dir>/anthropic-profiles/<name>.json, or from Claude Code style
credential files dropped into that directory.

- store: account_id column on anthropic_snapshots/anthropic_reset_cycles
  (default 0), *ForAccount query variants, legacy functions keep working
- tracker/agent: per-account tracker and agent; rotated OAuth tokens are
  written only to that account's profile file (one-time-use refresh
  tokens are never shared); statusline and Claude Code guard stay on the
  primary account
- provider_accounts rows per extra account, soft-deleted when removed
- web: ?account= on current/history/cycles, /api/anthropic/accounts,
  anthropicAccounts in the all-providers payload, per-account
  telemetry/dashboard toggles (anthropic:<id>)
- docs: docs/ANTHROPIC_ACCOUNTS.md, README env table

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Itstommy10
Itstommy10 force-pushed the feature/anthropic-multi-account branch from 0c63a44 to 2e1ab14 Compare October 22, 2026 13:13
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