This is a migrated reference document from the original Anvio source repo. Content is preserved as-is; canonical documentation lives in the sections above in the sidebar.
Original path: docs/adr/0009-runtime-oauth-authentication.md
Anvio supports multiple runtime providers (local, claude-code, cursor, codex, future antigravity) in addition to direct model providers (anthropic, openai, …).
Today, Claude is accessed primarily via @anthropic-ai/sdk and ANTHROPIC_API_KEY. External runtimes (claude-code, cursor, codex, antigravity) were stubs. Product direction requires:
Vendor-native runtimes authenticate through the official app/CLI OAuth or session (Pro/Max subscription), not Anvio-managed API keys.
local runtime continues to use API keys / credential pools for direct provider access and fallback.
Vendor-native parity shipped for Cursor (ACP + app session), OpenAI Codex CLI, and Google Antigravity CLI — see "(implemented)" sections below.
Anthropic policy note: third-party products must not host claude.ai login UI or resell subscription rate limits. Anvio therefore delegates login to the official Claude Code CLI (claude setup-token) and only stores the resulting token locally (encrypted connection broker).
Interactive CLI cache (SDK fallback when neither is set and user already ran claude login)
Never pass ANTHROPIC_API_KEY into the Agent SDK subprocess env when OAuth mode is active — API key shadows OAuth and bills API credits instead of subscription quota.
User onboarding:
anvio setup-token --claude # wraps official `claude setup-token`anvio setup-token --cursor # wraps official `agent login`anvio setup-token --codex # wraps official `codex login`anvio setup-token --list # show supported vendors
# Multi-user OAuth on one workspaceexport ANVIO_CONNECTION_ENCRYPTION_KEY=your-secretanvio setup-token --claude --user aliceanvio setup-token --codex --user bob
Agent-to-agent collaboration uses orchestration (delegate_task, supervisor pattern, mixture_of_agents, workflows) — not a shared chat thread by default.
Run login on a machine with a browser, then ship encrypted broker state to the server.
# On laptop / bastion (has browser)export ANVIO_CONNECTION_ENCRYPTION_KEY="${ANVIO_CONNECTION_ENCRYPTION_KEY}"anvio setup-token --claude --user aliceanvio setup-token --codex --user bob# Copy to server (includes workspace/connections/_state/*.json)rsync -av ./workspace/connections/ user@server:/opt/anvio/workspace/connections/
docker-compose worker/gateway snippet:
services: worker: environment: ANVIO_WORKSPACE: /workspace ANVIO_CONNECTION_ENCRYPTION_KEY: ${ANVIO_CONNECTION_ENCRYPTION_KEY} # Optional global fallback when broker miss: # CLAUDE_CODE_OAUTH_TOKEN: ${CLAUDE_CODE_OAUTH_TOKEN} volumes: - ./workspace:/workspace # Do NOT bake tokens into the image layer
Map channel userId to broker entries provisioned offline:
User
setup-token
Agent example
alice
--claude --user alice
architect (claude-code)
bob
--codex --user bob
coder (codex)
Sessions must use matching userId (auth plugin or defaultUserId override per channel). Each user gets isolated OAuth from broker; same agent definition can serve both if runtime resolves per user token.