Skip to content

Runs stall when the OAuth session expires mid-run #83

Closed

Description

@braboj

Round 5c stalls whenever the OAuth session expires mid-run. A trial is then blocked, and the run waits until someone runs /login.

What happened

Trial Started Outcome
hybrid-1 2026-10-29 15:28 blocked, re-ran after a /login
reference-4 2026-10-29 23:41 blocked, still waiting the next morning

Both failed with the same error:

Failed to authenticate: OAuth session expired and could not be refreshed

The gap between them is about 8 hours. That looks like a session that lasts 8 hours and is never renewed.

Why it matters

  • Each block loses the time until someone notices, 7+ hours overnight.
  • About 69 h of the run remain, so it will stall several more times.

What the harness does today

  • refresh_credentials hard-links the account's credentials file into the scratch home before every trial and every probe.
  • After a block, wait_for_generator probes every 30 min. Each probe re-links the file and makes one cheap call.

Questions to answer

  • Does the CLI save a refreshed token by replacing the file? That would break the hard link and leave the home with an old file.
  • Does another client of the account, such as an interactive session, rotate the refresh token, so the trial's CLI holds a revoked one?
  • Can a trial's CLI refresh the token itself from the scratch home, or does only the interactive client do it?
  • Would a long-lived token, such as claude setup-token, remove the need to log in during a run?

Done when

  • A run longer than the session's lifetime finishes without a /login.
  • Or, if that can't be done, the block is surfaced at once (for example with a notification) and not found the next morning.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DpT5xPB8YTAMW2Msp4aPTX

Activity

  1. braboj commented on Oct 30, 2026

    @braboj
    ContributorAuthor

    Likely cause: a refresh breaks the hard link

    Both blocks hit the first trial started after the access token expired.

    Token expired Trial running then Next trial Failed after
    ~15:2x, 10-29 inline-1 hybrid-1 seconds
    ~23:2x, 10-29 inline-3 reference-4 3 s

    What the files show:

    • The access token lasts 8 h. The refresh token lasts until 2026-11-27, so a refresh should succeed.
    • The home's file and the account's are one hard link (same inode, link count 2) until a refresh.

    The suspected sequence:

    trial CLI refreshes ─► writes a new file (rename) ─► link broken
                           home: new tokens   account: old, rotated-out tokens
    next trial ─► refresh_credentials removes home's file, re-links account's
               ─► CLI refreshes with the rotated-out token ─► rejected
    

    Check at 15:10 today

    • The home's file has link count 1 and expires later than the account's.

    Fix

    • refresh_credentials keeps whichever of the two files expires later, writes it over the account's file in place, then links.
    • A self-test check: a home file replaced by a newer one is not discarded.

    For this run, a watcher outside the harness copies a newer home file back over the account's file.

  2. braboj commented on Oct 30, 2026

    @braboj
    ContributorAuthor

    Check at 15:23, 2026-10-30: no trial blocked since the #84 restart, but the 15:10 expiry was not crossed by the fix alone.

    Time Event
    15:05 hybrid-6 refreshed in the scratch home (expires 23:05), breaking the link
    15:10 owner's session forced to /login: the account's refresh token had been rotated out (account now expires 23:10)
    ~15:19 hybrid-6 completed, scorable
    15:20 end-of-trial pass kept the account's later 23:10 login, re-linked; reference-6 started on it
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions