codex-multi-auth icon indicating copy to clipboard operation
codex-multi-auth copied to clipboard

[bug] 24h max-lifetime ceiling kills the rotation helper under a live owner; long-running TUI session is stranded on a dead port

Open highnext opened this issue 2 weeks ago • 0 comments

Summary

The 24h max-lifetime ceiling on the runtime rotation app helper fires even when the helper's owner is alive (identity verified) and the helper is actively serving traffic. The helper exits, nothing replaces it, and the Codex TUI session that was launched against it is stranded on a dead local port until the user quits and resumes.

Environment

  • codex-multi-auth 2.26.1 (helper was started under 2.26.0), macOS (Apple Silicon)
  • Launched with codex-multi-auth-codex resume <thread-id>; a long-running /goal session (> 24h wall clock)

What happened

Helper status file right after the stall:

state         = max-lifetime
lastError     = terminated
startedAt  -> updatedAt = 86,400,604 ms   (24h + 0.6s)
totalRequests = 10454   upstreamRequests = 9912   rotations = 13
lastAccountUpdatedAt = 23s before exit   (traffic was flowing)

At that moment:

  • the wrapper process (the helper's owner) was alive, and so was its codex child
  • nothing was listening on the helper's port any more (connection refused)
  • the codex child keeps the old address in its arguments (model_providers.codex-multi-auth-runtime-proxy.base_url=http://127.0.0.1:<port>), so it cannot find a new helper

The TUI then shows, indefinitely:

Reconnecting... waiting for network
  Connection failed: error sending request

The network is fine; the goal makes no progress and the queued user message is never delivered. The only recovery is quit + codex resume <thread-id>, which also drops any background terminal the session was running.

Why

In scripts/codex.js the status tick checks the ceiling unconditionally:

} else if (maxLifetimeMs > 0 && currentTime - startedAt >= maxLifetimeMs) {
    // The ceiling is deliberately unconditional on activity: it exists
    // for exactly the case where activity accounting is wrong.
    exitAfterCleanup("max-lifetime", 0);
}

I understand the intent (#663: helpers leaking without bound when idle accounting is wrong). But the same tick already has a strong signal that this helper is not a leak: isOwnerAlive() returned OWNER_ALIVE with the start-time identity check, i.e. not the PID-reuse case the ceiling was added for.

Suggestions (any one would fix it)

  1. Skip the ceiling while the owner verdict is OWNER_ALIVE with a verified start time; keep it for OWNER_DEAD / OWNER_UNKNOWN, where the leak risk actually lives.
  2. Or have the launcher re-spawn the helper on the same port when it exits under a live owner, so the running codex child reconnects by itself.
  3. At minimum, document CODEX_MULTI_AUTH_APP_ROTATION_MAX_LIFETIME_MS=0 for long-running sessions and surface the upcoming expiry in the launcher output.

Workaround

export CODEX_MULTI_AUTH_APP_ROTATION_MAX_LIFETIME_MS=0 before launching (confirmed the new helper receives it). This removes the backstop entirely, which is why a conditional ceiling (suggestion 1) would be preferable.

highnext avatar Nov 17 '26 10:11 highnext