Repository navigation
Description
What happens
When the Claude OAuth token happens to be due for a refresh at the moment backpass starts, the run fails in about 15 seconds before analysing anything:
· analyzing 54 transcript(s) with claude (claude-sonnet-5) effort=medium at jobs=4
error pinned analysis agent claude (claude-sonnet-5) failed unexpectedly (acpx claude session prompt failed (exit 1): [acpx] error: RUNTIME QUEUE_RUNTIME_PROMPT_FAILED Internal error: Failed to refresh OAuth token: another Claude Code process is refreshing it or exited mid-refresh. This is usually transient; retry in a minute, and if it persists close other Claude Code processes or sign in again)
check the claude/acpx failure above and retry; or pin a different harness: backpass --analysis-agent <agent>
Nothing else was using Claude Code on the machine at that hour. The same command had passed on the three previous nights, when the token was still valid at start time.
Minimal way to see it
- Sign in to Claude Code in a dedicated config dir and let the access token get close to expiry, or wait for a night where it expires right before the run.
- Run
backpass --scope userwith the default--jobs 4and the analysis agent pinned to claude. - All four parallel analysis sessions fail with the message above. A
.oauth_refresh.lockdirectory is left behind in that config dir ($CLAUDE_CONFIG_DIR/.oauth_refresh.lock), empty, with no live process owning it, and the credentials file has not been rewritten.
Observed timing (one run, 2026-10-02, local time)
- 03:50:01 backpass starts.
- 03:50:02.97 the
.oauth_refresh.lockdirectory is created. Its mtime stays at 03:50:03.00, so it was never touched again. - 03:50:03.30 to 03:50:03.36 the four analysis sessions are created in acpx.
- 03:50:06.9 to 03:50:07.1 the four Claude agent processes start.
- 03:50:16.1 to 03:50:16.5 all four close with the refresh error, three times each in their stream logs.
- 03:50:16 backpass exits 1.
The lock's own rules, read from the Claude binary the adapter ships: it is considered stale after 60 s, and its owner touches it every 5 s while alive (stale:60000,update:5000). The lock was created and never updated, so whatever owned it was gone within 5 s. The sessions gave up after roughly 9 s, well before the 60 s takeover.
Likely cause (inferred, not observed directly)
backpass opens every analysis call with a separate, short-lived acpx claude sessions new process before the prompt itself (src/acpx.js, the run([... "sessions", "new", "--name", sessionName]) call; same code on current main). With --jobs 4 four of these run at once. If the token is due, the first helper to start begins the refresh and takes the lock, then exits as soon as the session is registered, before the refresh completes. The lock is left with no owner, the credentials file is never rewritten, and the four real sessions that follow all see "another process is refreshing it or exited mid-refresh" until they give up.
The timing fits: the lock appears 0.33 s before the first session record, after backpass started, and no other Claude process ran in that config dir between 03:49 and 03:51. I could not log the helper's own exit, so I cannot prove which process held the lock.
Suggested fix
Before fanning out, do one Claude call alone and wait for it to finish, so that a due refresh runs to completion in a single process. A prompt-less probe would do, as long as the process lives through the refresh rather than exiting right after sessions new returns. Retrying after a minute, as the message suggests, would start the same short-lived helpers and could abandon the lock again.
The workaround I use: one small Claude call under the same config dir just before backpass, which rewrites the credentials and clears the lock. With that in place the next run passed on all 54 transcripts.
Versions
- backpass 0.1.29
- acpx 0.18.0
- @agentclientprotocol/claude-agent-acp 0.76.0
- node v22.22.0
- Linux
I ran backpass nightly for a week up to 2026-10-05 and once more on 2026-10-07. It is not in regular use here at the moment, so this is offered in case it helps rather than as something I am blocked on.
Activity
kunchenguid commentedon Oct 9, 2026
Speaking as Kun's firstmate: triaged.
Thank you, @ignaciomella, for such a careful write-up, with the lock timing and the workaround included. That's exactly what makes this traceable.
What I checked on main
0268201:analyzeTranscripts(src/analyze.js) sends pending transcripts throughpool(pending, config.jobs, ...). Each worker callsopenSessioninsrc/acpx.js, which runs its own short-livedacpx <agent> sessions new --name ...process before the prompt. No single Claude call runs to completion before the fan-out. So with--jobs 4, foursessions newhelpers can start at once, as you described. The pre-runprobeSession(sessions newthenclose) is also short-lived, and for Claude the auth gate before it isclaude auth status, so neither one keeps a process alive through a token refresh. I couldn't reproduce the expired-token timing here, so your read that a helper exits while holding.oauth_refresh.lockis still a plausible cause, not a confirmed one. The code path that allows it is on main, and no open PR touches it.Leaving this as ready-for-pr. A fix should be checked against the real lock behavior (an expired or near-expiry token with
--jobsabove 1), not only a mock. It also shouldn't be a blind retry loop, since a retry would start the same short-lived helpers again. Your suggestion, one Claude call that lives through any refresh before fanning out, fits.VISION per-rule:
contract-class: restore (the default run with the Claude analysis agent is supposed to analyze; dying at startup when a token is due is the regression to fix, and serializing the first call doesn't change what a run produces).
fix: run first Claude analysis call alone before fan-out (kunchenguid…
chore: sync upstream main into fork (#2)