[bug] 24h max-lifetime ceiling kills the rotation helper under a live owner; long-running TUI session is stranded on a dead port
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/goalsession (> 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
codexchild - nothing was listening on the helper's port any more (
connection refused) - the
codexchild 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)
- Skip the ceiling while the owner verdict is
OWNER_ALIVEwith a verified start time; keep it forOWNER_DEAD/OWNER_UNKNOWN, where the leak risk actually lives. - Or have the launcher re-spawn the helper on the same port when it exits under a live owner, so the running
codexchild reconnects by itself. - At minimum, document
CODEX_MULTI_AUTH_APP_ROTATION_MAX_LIFETIME_MS=0for 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.