Skip to content
Source
Sign inSign up
pingdotgg/t3code

[Bug]: Hardcoded 30-minute idle session reaper + 2-second force-kill causes context loss across all providers on desktop #2980

Closedskabillium(GitHub profile, opens in a new tab) opened this issue 1 comment

Summary

After a break of ~30–60 minutes, conversations lose all provider-side context. The UI still shows the full history, but the agent behaves like a fresh session and it doesn't remember prior turns, plans, or tool-call state.

Root Cause

This is caused by two hardcoded defaults in the server:

  1. ProviderSessionReaper.ts kills idle sessions after exactly 30 minutes (DEFAULT_INACTIVITY_THRESHOLD_MS = 30 * 60 * 1000). This is an architecture-level behavior that affects all providers (Codex, OpenCode, Claude, Cursor).

  2. CodexSessionRuntime.ts gives the Codex app-server process only 2 seconds (CODEX_APP_SERVER_FORCE_KILL_AFTER = "2 seconds") to shut down before SIGKILL. Codex often needs more time to flush its SQLite state DB to disk. When the process is hard-killed mid-flush, the thread file is corrupted or incomplete, so thread/resume fails and silently falls back to a brand-new thread/start.

Why it affects all providers

  • Codex: thread/resume fails because the state DB was not flushed → falls back to thread/start → context is lost.
  • OpenCode (ACP): The ACP session ID is not persisted after the reaper kills the session, so T3 calls session/new instead of session/resume on reconnect. See #2838 for detailed analysis.
  • Claude: Similar to OpenCode — the resume cursor can point to a dead CLI session if the process was killed before the first turn was persisted (see #2336).
  • #2378 — "t3code should resume same conversation after idle timeout ?" (OpenCode)
  • #2838 — "OpenCode (ACP) provider creates new session instead of resuming after app/system restart"
  • #2720 — "Codex provider drains plan credits while T3 Code is idle in background" (reaper not killing properly due to stuck activeTurnId)
  • #2188 — "Chat splits into a new session after a pause" (Codex, closed)
  • #2140 — "Loss of context when the app is restarted" (Codex, closed)
  • #2336 — "Thread becomes permanently unusable if claudeAgent CLI session is killed before writing its first turn"

Proposed fix

  1. Make the idle threshold configurable per environment: 3 hours for desktop (where process lifetime is cheap), 30 minutes for web/shared environments.
  2. Bump the force-kill grace period for Codex: from 2 seconds to 15 seconds, so the app-server has time to flush its state DB.
  3. For ACP providers: persist the ACP session ID in resumeCursor so session/resume can be used on reconnect.

Environment

  • Desktop app (macOS, Windows, Linux)
  • All providers: Codex, OpenCode, Claude, Cursor
  1. I tried to reproduce this on the current build and could not.

    Commit e0661db2c8 (origin/main). Ran T3CODE_DEV_SEED=0 vp run dev (fresh database, web client in the preview browser) with the real Codex CLI 0.173.0 app-server and model GPT-6-Astra Medium. (1) In a new Codex thread I sent: 'Remember this secret word: PELICAN-7342. Reply only with "OK".' The first turn stalled for about 6 minutes while Codex reconnected to the backend, so it did not count as idle. A steer during it answered PELICAN-7342 and the turn completed at 10:06. (2) I left the thread idle. About 2 minutes later the server sent thread/unsubscribe to Codex, and the app-server runs with thread_unload_delay_secs=0, so the native thread was unloaded. I then sent 'spell the secret word backwards'. The provider log showed thread/resume (not thread/start) and the agent answered '2437-NACILEP'. (3) I stopped the whole dev server, which killed the Codex app-server process, restarted it on the same database, and asked for 'the last four digits of the secret word, plus one'. The log again showed thread/resume, and the agent answered '7343'. Provider context survived both the idle unload and a hard kill of the app-server. The files the report names (ProviderSessionReaper.ts with its 30-minute DEFAULT_INACTIVITY_THRESHOLD_MS, CodexSessionRuntime.ts) no longer exist on main. Idle release now lives in apps/server/src/orchestration-v2/ProviderSessionManager.ts: 2 minutes for providers with native resume (Codex, Claude, OpenCode, Cursor) and 30 minutes for providers without it. In CodexAdapterV2 a failed thread/resume becomes a ProviderAdapterResumeThreadError, not a silent fallback to thread/start. I did not test Claude or OpenCode turns: first-party Claude OAuth is not available on this VM, and the report's OpenCode claim refers to the old ACP path. OpenCode now has a native driver that declares supportsNativeResume: true.

    Closing as not planned. If it still happens for you, reply with the exact steps and the version you are on and it will be looked at again.

  2. juliusmarminge closed this

Sign in to join this conversation.