Repository navigation
Conversation
Contributor
[Medium impact] The PR appears safe to merge; no new blocking issues were found. SummaryThe Claude collector now asks the installed CLI to renew a lapsed access token before checking usage limits.
Tests were reviewed but not run.
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
isc
force-pushed
the
agent-usage-claude-refresh
branch
from
November 8, 2026 08:40
412d07a to
df59f2e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Omarchy offers the Claude desktop app in Install > AI (#10755), but for anyone who uses Claude Code only through it, the agents panel's Claude limits stay paused for good. This is the bug #12470 reports, in the one setup where using Claude Code never clears it.
The Claude collector reads the access token the Claude Code CLI keeps in
.credentials.json. That token lives about eight hours, and only the CLI renews it, when it runs. #14049 made a lapsed access token with a live refresh token read "Limits paused" rather than "Sign-in expired" (#8092, #12470), but the panel still waits for someone to start the CLI.The desktop app never starts it: the app keeps a sign-in of its own, so
~/.claude/.credentials.jsonis never renewed. On one such machine (Omarchy quattro, omarchy-dev 4.0.0.r7294.gb72863a) the access token had lapsed since October 18. Until #14040 the panel kept showing that day'sclaude-limits.json, zeroed by the weekly reset; since #14040 keys the cache by account, it has nothing left to show.When the access token has lapsed and the refresh token still holds, the collector now runs
claude auth statusin the home it is reading, reads the credentials again, and probes as usual if they now hold a live token. Otherwise the "Limits paused" behaviour stays exactly as it is.auth statusasks the model nothing, so it costs no quota. This is the "refresh instead of reporting" option from #12470, with the CLI doing the refresh:.credentials.jsonand does not implement the OAuth exchange: the refresh token changes with every use, so a second refresher would race the CLI for it (the sharp edge Agents panel reports SIGN-IN EXPIRED when only the 8-hour access token lapsed #12470 describes), and it would be acting as Claude Code's OAuth client.--force(pressing refresh) skips the wait. Runs take turns under a lock beside the stamp, and one that waited on another finds the token renewed and runs nothing, so two collectors at once never race each other for the refresh token. It never runs when the refresh token has lapsed or there is no token.collectors.pyasfind_installed_command(), so both collectors share it.CLAUDE_CONFIG_DIRset for any home but~/.claude, whose profile is~/.claude.json), with a 20-second timeout, and without theCLAUDECODE,CLAUDE_CODE_*orANTHROPIC_*it would inherit: inside a Claude Code session, or with an Anthropic key, token or base URL, the CLI takes that credential and never touches the file.CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1keeps telemetry and update checks out of a run nobody asked for.Minimum version: 2.1.301. The collector asks
claude --versionfirst and leaves older CLIs alone. A comment on #12470 found thatauth statuson 2.1.278 did not refresh at all (doctordid, and adoctorloop once wiped both tokens), and the 2.1.301 changelog reads: "Fixed sign-in refresh timeouts and unexpected sign-outs after a short command such asclaude auth statusorclaude plugin listexited in the middle of a token refresh". Below 2.1.301 the run does nothing or risks signing the home out, which is worse than paused limits. Omarchy installsclaudethrough mise withauto_update = "4h", so nearly every machine is past it.On the desktop-app machine above, with Claude Code 2.1.310,
env -i HOME=$HOME PATH=$PATH claude auth statusmovedexpiresAteight hours ahead without any inference, andomarchy agent usage-update --limits-only claudethen brought back the real limits (session 63%, weekly 11%).Tests:
agent-usage-claude-limits-test.shputs a stand-inclaudeon an otherwise bare PATH and checks that a CLI that renews the token unpauses the limits, probed with the new token; that one renewing nothing leaves them paused; that the CLI runs once per half hour per sign-in, and again on--force; that two collectors started at once run it once; that a CLI older than 2.1.301 is only asked its version; that a lapsed refresh token runs nothing and reads "Sign-in expired"; that the CLI's environment carries noCLAUDECODE,CLAUDE_CODE_ENTRYPOINT,ANTHROPIC_BASE_URLor, for~/.claude,CLAUDE_CONFIG_DIR; and that a registered account's home is refreshed in place. The new checks fail onquattro. The Claude and Codex collector tests,agent-usage-accounts,-partition,-sharedand-updatepass../test/allran on a Linux box that isn't an Omarchy desktop (no Hyprland, lua or ImageMagick): the same 50 of 452 shell test files and the same CLI checks fail with and without this change.No visible change: the agents panel draws nothing new; Claude's limits come back live instead of staying paused.
🤖 Generated with Claude Code