Skip to content

Parallel sessions new helpers can abandon Claude's OAuth refresh lock, and the whole run dies in 15 s #203

Closed

Description

@ignaciomella

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

  1. 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.
  2. Run backpass --scope user with the default --jobs 4 and the analysis agent pinned to claude.
  3. All four parallel analysis sessions fail with the message above. A .oauth_refresh.lock directory 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.lock directory 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

  1. kunchenguid commented on Oct 9, 2026

    @kunchenguid
    Owner

    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 through pool(pending, config.jobs, ...). Each worker calls openSession in src/acpx.js, which runs its own short-lived acpx <agent> sessions new --name ... process before the prompt. No single Claude call runs to completion before the fan-out. So with --jobs 4, four sessions new helpers can start at once, as you described. The pre-run probeSession (sessions new then close) is also short-lived, and for Claude the auth gate before it is claude 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.lock is 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 --jobs above 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:

    • Purpose / owns the backward pass: aligns (reliability of the analysis stage).
    • Evidence is the only currency: n/a (no evidence-path change).
    • The human owns the weights: n/a.
    • Nothing the model says is taken on faith: n/a.
    • The budget is the constraint: aligns (one serialized warm-up costs little next to a run that dies before analyzing).
    • It reads what you already have and owns nothing: aligns (still the harness the user authenticated; no key of our own).
    • Failure is loud and named: aligns. The error is named today. The fix must not turn it into a quieter degraded path.
    • Scope: aligns (model invocation stays behind the one acpx module).
    • Resist lines: none triggered, provided the fix is a real fix and not a silent retry.

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

  2. added
    ready-for-pr
    bug
    on Oct 9, 2026
  3. added a commit that references this issue on Oct 23, 2026
    3882b86
  4. added a commit that references this issue on Oct 26, 2026
    b546d7d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugready-for-pr

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions