Skip to content

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

@skabillium

Description

@skabillium

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

Related issues

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions