Skip to content

2-minute idle release (#41174) makes the first turn after a pause take 20-60s for long-context Codex sessions #42123

Backlog

Description

@zhedream

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/desktop

Steps to reproduce

  1. Use a long-context Codex thread (for example ~320K cached tokens, gpt-6.2-sol).
  2. Complete a turn normally.
  3. Wait more than 2 minutes without sending another message (for example ~6.5 minutes).
  4. Send the next message.
  5. Observe the UI showing "Resuming Codex session", and a much higher time-to-first-token than when sending within 2 minutes.
PixPin_2026-11-24_19-57-34

Expected behavior

The idle-release timeout should be configurable (in settings, or per provider), or native-resume providers should keep a longer default (for example 30 minutes), or the session should stay warm while the user is typing in the input box / the thread is visible. At minimum, the resume cost for long-context Codex sessions should be assessed more accurately than the roughly 1-second estimate.

Actual behavior

Starting in 0.1.12-nightly.20261123.5138 (#41174, merged 2026-11-23), providers that use native resume (Codex / Claude / Cursor / OpenCode) are released after 2 minutes of idle. The next turn then shows "Resuming Codex session" and the first token is very slow.

The PR estimated the restart cost at about 1 second. Measured on a long-context Codex thread (~320K cached tokens, gpt-6.2-sol):

  • Consecutive messages: TTFT 1.7–2.3s.
  • After a ~6.5 minute pause (18:50:59 → 18:57:27): TTFT ≈24s, while cached tokens were still 326K. This is not a cache miss; it is cold-start of app-server + thread/resume overhead.
  • Earlier observations: 44–67s.

Writing a detailed prompt often takes more than 2 minutes, so almost every carefully written prompt hits this delay.

Related: #41474, #41490, and #41700 are side effects of the same change. #41928 only added the hint copy.

Impact

Major degradation or frequent failure

Version or commit

0.1.12-nightly.20261123.5165

Environment

Windows desktop, Codex provider

Logs or stack traces

Screenshots, recordings, or supporting files

No response

Workaround

Sending the next message within 2 minutes avoids the delay, but that is impractical when writing a detailed prompt, which often takes longer than 2 minutes.

Activity

  1. added
    bug
    needs-triage
    on Nov 24, 2026
  2. barakcoh-gong commented on Nov 25, 2026

    @barakcoh-gong

    Hit this too, on 0.1.12-nightly.20261125.5222, with Claude.

    My setup makes the cost easier to see than usual. T3 runs Claude inside a Docker container through a small wrapper, and the container only lives as long as that wrapper does. So when the 2-minute idle release kicks in, the whole container is removed. If I reply within 2 minutes, I get the same container and the same claude process back. If I take longer (it was 90+ minutes for me), a brand-new container starts with --resume. That's well beyond the "about a second" estimate in #41174.

    I get why the default is short: idle sessions do hold memory. I'd just like a way to tune it. layerWithOptions already takes idleTimeoutMs, so reading something like T3CODE_PROVIDER_IDLE_TIMEOUT_MINUTES in the default layer would be around 15 lines. Keeping the thread I currently have open warm for longer would also work for me.

    Happy to put up a PR if that's something you'd take.

  3. zhedream commented on Nov 25, 2026

    @zhedream
    Author

    Update from my side: I started a fresh thread and the very long first-token delay seems to be gone. I'm not sure whether it was related to context length. That old thread had been auto-compacted many times, and today it started timing out completely (stream disconnected before completion), to the point where I couldn't continue the conversation at all, so I switched to a new thread.

    The cold-start cost is still there, though. The difference is very noticeable:

    • If I send the next message within 2 minutes, the reply comes back quickly with almost no work time.
    • After the idle release (a cold start), I wait anywhere from 3 to 10 seconds before the first token.

    I have fast mode enabled, but it doesn't make up for the cold-start overhead. The experience just isn't smooth anymore.

    +1 to @barakcoh-gong's suggestion. A configurable idle timeout (env var or setting), or keeping the currently open thread warm longer, would solve this for me.

  4. ElliotDrel commented on Nov 25, 2026

    @ElliotDrel
    Contributor

    Note

    🤖 Claude Opus 5.5 (Claude Code, via T3 Code triage) responding on behalf of Elliot

    Same on Claude, Windows desktop, 0.1.12-nightly.20261124.5204. Still present in v0.1.13-nightly.20261125.5245: DEFAULT_IDLE_TIMEOUT_MS is still 2 * 60 * 1000.

    From the provider event log for one ordinary Claude thread over about 3 hours today:

    • 83 sends started the Claude CLI 19 times. Each query.close came exactly 120s after the previous turn's result, and the next send did a fresh query.open with SessionStart:resume.
    • query.open to Claude's system/init usually took 0.2–1s, which matches the PR's estimate. Once it took 9.4s.
    • The bigger problem is perception. Together with [Bug]: "Starting {provider}" shows after every message, even when the provider is already running #42621, "Starting Claude" now shows on every send, so the thread feels like it restarts on every message even when it doesn't.

    +1 to making the idle timeout configurable (a setting, or an env var read in the default layer, since idleTimeoutMs is already plumbed through layerWithOptions). Writing a careful prompt regularly takes longer than 2 minutes, so the release hits the turns where you'd least want extra latency.

  5. nielsmaerten commented on Nov 25, 2026

    @nielsmaerten

    Same with Claude on Linux desktop, on the v0.1.12 release (beta AppImage, Fedora 44, Claude Code 2.1.332). main still has DEFAULT_IDLE_TIMEOUT_MS = 2 * 60 * 1000.

    Until the app updated to 0.1.12 today, a follow-up in a thread went straight to Thinking. Now any send after a pause of more than 2 minutes shows "Starting Claude" and then "Connecting to Claude".

    From server.trace.ndjson, 20 minutes of ordinary use today:

    • ProviderSessionManager.releaseIfStillIdle ran 6 times in 13 minutes across my open threads.
    • Every send after a release ran ClaudeAdapterV2.openSession and started a new claude --resume process.
    Session opened (CET) Process start and resume "Connecting to Claude" shown
    17:45:08 3.7 s 0.9 s
    17:48:44 1.8 s 2.0 s
    17:54:28 1.8 s 1.7 s
    18:01:02 5.6 s 28.0 s

    The second column is the time from openSession to the connecting phase, so it is the cost the idle release adds. It is 2 to 6 seconds here, not the "about a second" estimated in #41174.

    The third column is the wait for the first API response. That wait is model latency and existed before, but it is now labelled as a connection step on every send after a pause. In the 28-second case the provider event log has no events at all during the wait. It reads as a connection problem when it is not one.

    +1 to a configurable idle timeout, or to keeping the visible thread's session alive for longer.


    Written by Claude Fable 5.2 (Claude Code, via t3 triage) and reviewed by the reporter before posting.

  6. justcarlson commented on Nov 25, 2026

    @justcarlson

    Note

    🤖 Gemini 4 Neon responding on behalf of justcarlson

    Seeing the same cold-start friction on v0.1.12-nightly.20261123.5151 across Linux and macOS hosts with Claude and Codex: DEFAULT_IDLE_TIMEOUT_MS (2 min) forces a cold CLI respawn after short reading/review pauses.

    Suggestion (judgment, not tested): derive the idle timeout in ProviderSessionManager.idleTimeoutFor from the existing BackgroundActivity profile rather than keeping a fixed 2-minute constant or adding a separate setting:

  7. Dominik-O22 commented on Nov 25, 2026

    @Dominik-O22

    Note

    🤖 Claude Opus 5.5 (Claude Code, via T3 Code triage) responding on behalf of the reporter

    Same with Claude on Linux desktop (Omarchy), 0.1.13-nightly.20261125.5258, Claude Code 2.1.332. Before #41174 a follow-up went straight to Thinking. Now any send after a pause of more than 2 minutes shows "Connecting to Claude Code" for several seconds.

    Timings

    From server.trace.ndjson and the provider event log over about 3 hours in one long-running thread:

    Time to first token
    Warm send, same thread ~1.6 s (turn start 40 to 130 ms)
    Send after idle release, same thread 7.3 to 9.0 s (5 cold starts: 7.6, 9.0, 7.3, 7.7, 8.4 s)
    Cold start on a brand-new thread ~1.1 to 1.2 s

    Every ProviderSessionManager.releaseIfStillIdle fired exactly 120 s after the previous turn ended.

    Why the cold start can take far longer than 1 second

    Most of the delay comes from resuming a large transcript in a fresh CLI process. It is not a prompt cache miss. Cold turns read about 123k cached tokens and write about 150, the same as warm turns.

    The slow thread's Claude transcript (~/.claude/projects/.../<session>.jsonl) is 152 MB. About 118 MB of it is 224 screenshots, stored as base64 images in tool results. I reproduced the cold start outside T3 with claude -p --resume <session> --fork-session --debug-file ... and got 7.2 s to the first token:

    • +0 to 1.9 s: the CLI loads the transcript before sending anything.
    • +1.9 s: [API REQUEST] /v1/messages is logged.
    • +2.0 to 5.2 s: the CLI logs nothing for 3.2 s, so the process looks busy locally with the image-heavy request.
    • +6.5 s: Stream started - received first chunk.

    A fresh claude -p with no history gets its first token in about 1.1 s. Neither the claude.ai MCP connectors nor CLI boot (~50 ms) contributes: the connectors connect asynchronously and never block the first request.

    So the restart cost grows with transcript size, and screenshot-heavy threads are the worst case. That explains the spread in this issue, from about 1 s on short threads to 20 s or more on long ones. The "about a second" estimate in #41174 only holds for short threads.

    +1 to a longer or configurable timeout, or one tied to the background activity profile. A 10 to 30 minute default for native-resume providers would cover the common case of writing a careful prompt or reading a long reply.

  8. TuanNancy commented on Nov 26, 2026

    @TuanNancy
    Contributor

    I can confirm on main that the 2-minute idle timeout is wired only for native-resume providers (DEFAULT_IDLE_TIMEOUT_MS in ProviderSessionManager.ts) and that layer() has no settings/config override. Is the 2-minute release a hard memory trade-off from #41174, or would you accept a longer default for native-resume providers and/or a configurable timeout? I don't want to undo #41174 without your call.

  9. Grant07 commented on Nov 26, 2026

    @Grant07

    Same with Claude on Linux desktop (AppImage, CachyOS), 0.1.13-nightly.20261125.5258, Claude Code 2.1.332, claude-fable-5-2.

    From the provider event log for one long thread today, 23 of 34 sends came after an idle release. Each query.close came 120 s after the previous result. Time from prompt.offer to the first message_start:

    Send Cached tokens read Time to first response
    Warm (process reused) any 1.0–1.7 s
    After idle release ~68k 1.4 s
    After idle release 111k–138k 21–31 s
    After idle release 167k–234k 29–35 s
    After idle release 290k–297k 68–74 s
    • query.open to system/init was 0.1–0.2 s every time, so process start is not the cost.
    • It is not a cache miss: cold sends read the full cached prefix and wrote under 5k new tokens, the same as warm sends.
    • The whole wait sits between status: requesting and message_start, with no events in between. The UI shows "Connecting to Claude" for all of it.
    • The session transcript is 36 MB.

    A send within 2 minutes on the same 290k context takes about 1.5 s; one after 2 minutes takes over a minute. +1 to a longer or configurable timeout for native-resume providers.


    Written by Claude Fable 5.2 (Claude Code, via t3 triage) and reviewed by the reporter before posting.

  10. xe-leon commented on Nov 27, 2026

    @xe-leon

    Note

    Written by Claude (Claude Code, via T3 Code) at my request, from data collected on my machine.

    Same with Claude on macOS desktop, T3 Code 0.1.12 (beta), macOS 26.7.1, Claude Code 2.1.332. Any send after a pause of more than 2 minutes shows "Starting Claude" for 6–8 s, then "Connecting to Claude", before anything else happens.

    Timeline from one thread

    From logs/provider/events.<thread>.log and server.trace.ndjson:

    • 11:52:35.333Z: result for the turn (end_turn).
    • 11:54:35.409Z: ProviderSessionManager.releaseIfStillIdle fires.
    • 11:54:35.412Z: query.close, 120.08 s after the result, with no user action in between.
    • Next send: a new claude process is spawned with --resume=<session>, then query.open with "resume".

    The three sends before that, all within 2 minutes of each other, reused the same process and started immediately.

    Why the restart is far more than ~1 s here

    A respawn reruns everything the CLI does at startup, so its cost depends on the user's Claude Code setup and not only on T3:

    • SessionStart hooks run again on every resume. In this setup they add about 2.4 s, and a single plugin hook that shells out to gcloud accounts for 1.5 s of that.
    • Every user-scope MCP server reconnects. There were 16 stdio servers here, several of them going through an authenticating proxy, plus the claude.ai connectors and 14 plugins.
    • It costs functionality as well as latency. On the first turn after a release, most MCP servers are still "connecting", so their tools are missing when the model starts the turn and only show up partway through it.

    I trimmed the setup, which cut the claude.ai connectors from ~50 to 4, but the floor is still several seconds. Since a carefully written follow-up regularly takes more than 2 minutes, nearly every such follow-up pays this cost.

    Ask

    Any of these would fix it for us:

    • A longer default for native-resume providers. The 30 min used for non-native-resume providers would do, as would the ~10 min "balanced" profile suggested above.
    • Keep the session warm while the thread is open or focused, or while the composer has a draft.
    • Make the timeout configurable.
  11. nappeheimer commented on Nov 28, 2026

    @nappeheimer

    Same on Claude and OpenCode (v0.1.13, Linux, NFS home, HTTP proxy, 8 vCPU):

    • DEFAULT_IDLE_TIMEOUT_MS = 2 * 60 * 1000 (ProviderSessionManager.ts) applies to every driver with supportsNativeResume: true, including Claude and OpenCode.
    • Claude: after release, the next turn re-spawns the CLI, re-registers the t3-code MCP server and resumes history. We saw 20-60s of "Starting Claude" / "Starting Claude MCP servers", with orchestration.dispatchCommand held for more than 15s.
    • OpenCode: releasing the last session also lets OPENCODE_SERVER_IDLE_TTL (30s) stop the shared opencode serve. A cold opencode run measured 6.2s (4.8s CPU) before any model call. Every delegated task after a pause pays it again.

    Workaround: patching the bundled constant to 1 hour (12e4 to 36e5) made follow-up turns immediate for both drivers.

    Request: make the idle release configurable (setting or env var such as T3CODE_PROVIDER_IDLE_TIMEOUT_MS), or keep sessions warm while their thread is open in a client.

  12. ahrsn commented on Nov 29, 2026

    @ahrsn

    Seeing this with Claude too, not only long-context Codex sessions. On 0.1.14-nightly.20261128.5413 (macOS, M1 Pro), over 75 minutes with a handful of threads in use:

    ProviderSessionManager.releaseIfStillIdle  44 releases
    ProviderTurnStartService.start             n=63  p50=799ms  p90=5194ms  max=8304ms
    ClaudeAgentSdkQueryRunner.open             n=17  p50=2750ms p90=6864ms  max=7450ms
    

    Earlier in the evening, single turn starts reached 9.7–10.2 s, almost all of it in ProviderInstallationGate.execute → ClaudeAgentSdkQueryRunner.open (6.5–7.5 s), plus discoverClaudeSkills at 0.6–2.6 s. Coming back to any thread after a short break costs this, so agents feel slow even on a machine with spare CPU and memory. A configurable idle timeout, or keeping the most recently used sessions warm, would help.

  13. hrncz commented on Nov 30, 2026

    @hrncz

    Same with Claude on macOS desktop, T3 Code 0.1.13 (beta). From the server trace over 30 minutes of normal use:

    • Every send after more than 2 idle minutes reopens the Claude query: ClaudeAgentSdkQueryRunner.open took 5.3 to 7.5 s (15 cold opens). Before perf(server): idle agent sessions free their memory after 2 minutes #41174 these threads stayed warm for 30 minutes.
    • Checked on main (452355a): production wires ProviderSessionManager.layer = layerWithOptions() with no options, so idleTimeoutMs cannot be set from settings, env, or t3.json. Only the test harness passes it.

    Request: expose idleTimeoutMs as a setting (global or per provider), so users who trade memory for latency can choose a longer window.

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

    bugneeds-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions