Repository navigation
Resuming a long-lived session fails with 401 "OAuth access token has expired" and login: does not fix it; new sessions work #3669
Replies: 3 comments
|
Linking #3575, which reports the same root cause with a revoked token instead of an expired one: a long-lived worker keeps using its in-memory token after One point to add to my report: this isn't only a problem when resuming an idle session. On 0.10.1 it stopped a session that was actively running a multi-hour task. #3393 makes |
|
Follow-up with a root cause, found with prime-agent and checked against the v0.10.1 source. Line numbers are at the Cause: a running daemon session resolves its request key once, when the session is built ( What I'm running locally: a patched v0.10.1 build that does two things:
A review of that patch found two refresh bugs that already exist in v0.10.1 and that the patch would have hit more often:
The patch fixes both: it holds the flight plus a per-provider lock file through the save, and the save only goes through if the stored credential hasn't changed. Tests cover rotation before a turn, expiry in a running session, revoked tokens, and two processes sharing one Result so far: a session whose worker sat idle for about 22 hours refreshed its token and continued without a 401. Before I moved that session to the patched build, it got I'm not a vouched contributor, so I haven't opened a PR. I'm happy to share the patch as a diff or gist if it's useful. |
Uh oh!
There was an error while loading. Please reload this page.
Version: prime-agent 0.10.0 (
0.10.0-darwin-arm64-e418bdf6…), macOS arm64, Anthropic OAuth loginRelated: #3617 reports the same failure (auto-closed, reporter not vouched). Posting here per the README's bug-report route, with an independent reproduction.
Symptom
Resuming a session that had been held by a worker process for ~3 days returned:
Running
logincompleted successfully and rewrote~/.prime/agent/auth.json(mtime updated, newexpires~8 h out), but resuming the same session produced the identical error. Starting a new session at the same time worked normally.What I observed
prime-agent workerprocesses had been running since the session was last active (3 days). The resumed session attached to one of those old workers.prime-agent worker, which authenticated fine.Expected
After
loginsucceeds, resuming any session should use the new credentials. At minimum, the error message should not tell the user to re-authenticate when re-authenticating has no effect on the process that is failing.Hypothesis
Workers hold their own in-memory copy of the access/refresh pair loaded at worker start. If refresh tokens are rotated on use, then once any process (another worker, or
login) refreshes and rewritesauth.json, every other long-lived worker's cached refresh token is revoked. When that worker's access token expires, its refresh fails and it reports the 401. Nothing re-readsauth.jsonin a running worker, sologincan't repair it.I couldn't verify this from source (the binary is compiled), but #3617's observation 4 — a refresh in one session immediately producing
401: OAuth access token has been revokedin older workers — is what this predicts.Suggested fixes (any one would do)
auth.jsonand retry once before surfacing the error.--resumespawn a fresh worker when the existing worker's credentials are stale, or at least say in the error "restart the worker" rather than "re-authenticate".Workaround
All reactions