Repository navigation
Description
Problem
On a per-UID hive, every Claude agent's CLI shares one OAuth grant through the /data/home/.claude/.credentials.json symlink. Claude Code refreshes the token itself, and Anthropic's refresh tokens rotate on use. When the access token nears expiry, N CLIs refresh within seconds of each other against one grant: the first rotates it, the rest present the now-dead refresh token, and the auth server treats the reuse as a stolen token and revokes the whole grant, including the fresh one. The CLI then reports OAuth token revoked · Please run /login (revoked, not expired), and no agent holds a token the bridge could promote.
Seen on hive's hive, 2026-11-17 (UTC): shared file expiresAt 14:16:23. 14:12-14:15: claude credential bridge: a private credential file had replaced the shared-login symlink; re-bridged for all eight Claude agents (adjudicator-3, -4, dedupe, reviewer, reviewer-2, adjudicator, scanner, adjudicator-2), every one kept: "shared" (no private copy was usable). 14:25: watchdog: agent credential failure ... reason=CredentialMissing; headroom probe claude usage HTTP 401. Three token-triggered restarts per agent, then giving up ... restarts_24h=3 window_max=3. The whole Claude fleet was down until an operator re-login.
src/crux/agent/claude_credential_bridge.go documents the hazard in its header ("the shared file now holds a dead refresh token... every other agent fails its own refresh") but only repairs after a refresh; it cannot prevent the race, and with reuse revocation there is nothing to promote.
Expected
One refresher per hive. The hive refreshes the shared Claude grant itself, ahead of expiry (e.g. at 75% of the access token's lifetime), writes the result atomically to the shared file, and the CLIs never need to refresh. If a CLI still refreshes first (race), the bridge promotes it as today. The Copilot backend already has a single durable-file refresh path (see the copilot token store); mirror that design.
If a central refresh is not possible with Claude Code's OAuth client, the fallback is to serialize: a file lock the bridge takes so only one agent's CLI refreshes at a time, with the others paused for the few seconds it takes, then re-linked to the promoted result.
Acceptance
- Test: N agents with one shared grant at expiry → exactly one refresh request, all N read the new token, no revocation.
- Test: the hive refreshes before expiry on its own timer and the CLIs observe the new
expiresAtwithout a restart. - Never log token contents. changelog.d fragment. Docs:
src/docs/troubleshooting.mdentry for "OAuth token revoked" on shared logins.
Related: #18445, #18671 (same temp+rename replacement pattern on the Copilot side).
Activity
clubanderson commentedon Nov 17, 2026
Claimed: an operator-dispatched agent is working on this now. Hive agents, please do not pick it up.
hivecommons-hive commentedon Nov 17, 2026
Thanks for filing this issue! To help us reproduce and investigate, could you please include the commit SHA of the build you're running?
You can find it by running:
Or check the bottom of the console UI for the version string.
This issue will be on hold until a SHA is provided. Simply add a comment with the SHA and the label will be automatically removed.
🐛 claude: hive refreshes the shared OAuth grant itself ahead of expiry
🐛 claude: hive refreshes the shared OAuth grant itself ahead of expiry
clubanderson commentedon Nov 17, 2026
Fixed in #18736 (merged as 96704d8). The hive now refreshes the shared Claude grant itself, once, when the access token has a quarter of its lifetime left, and writes it atomically to the shared file, so the CLIs never refresh it concurrently. The bridge's promote-on-race path is kept, and a rejected grant is reported once with the dashboard sign-in as the recovery. Troubleshooting entry: 'Every Claude agent says OAuth token revoked at once'.