Skip to content

🐛 Shared Claude login: N agents refreshing one OAuth grant trips reuse revocation and logs the whole fleet out #18731

Closed

Description

@clubanderson

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 expiresAt without a restart.
  • Never log token contents. changelog.d fragment. Docs: src/docs/troubleshooting.md entry for "OAuth token revoked" on shared logins.

Related: #18445, #18671 (same temp+rename replacement pattern on the Copilot side).

Activity

  1. added
    kind/bugCategorizes issue or PR as related to a bug.
    triage/acceptedIndicates an issue or PR is ready to be actively worked on.
    on Nov 17, 2026
  2. self-assigned this
    on Nov 17, 2026
  3. added
    help wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.
    on Nov 17, 2026
  4. clubanderson commented on Nov 17, 2026

    @clubanderson
    MemberAuthor

    Claimed: an operator-dispatched agent is working on this now. Hive agents, please do not pick it up.

  5. hivecommons-hive commented on Nov 17, 2026

    @hivecommons-hive
    Contributor

    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:

    git rev-parse --short HEAD
    

    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.

  6. added a commit that references this issue on Nov 17, 2026
    8747621
  7. added a commit that references this issue on Nov 17, 2026
    95b1af6
  8. clubanderson commented on Nov 17, 2026

    @clubanderson
    MemberAuthor

    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'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

help wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.kind/bugCategorizes issue or PR as related to a bug.needs-shatriage/acceptedIndicates an issue or PR is ready to be actively worked on.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions