feat(agent): resume codex cloud threads natively on restarts#3216
Conversation
prepareNativeResume was Claude-only, so every codex cloud resume started a fresh thread and injected the prior conversation as a hidden markdown blob, dropping reasoning context, compaction state, and cache continuity. Now, when the thread's rollout file survived in CODEX_HOME (snapshot/warm sandbox restart), the server resumes the thread via the adapter's native thread/resume path. Cold restores keep the summary fallback (rollouts hold encrypted reasoning that cannot be rebuilt from logs), and a failed native resume now falls back to a fresh session instead of failing the run. Generated-By: PostHog Code Task-Id: 958c74c2-c281-438d-b112-f74dab2d1e48
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
|
- drop the no-op .toString() on readdir entries (string[] in this form) - parameterise the identical-setup thread-state and codex fallback tests with it.each per repo convention Generated-By: PostHog Code Task-Id: 958c74c2-c281-438d-b112-f74dab2d1e48
Problem
The Codex adapter already supports native resume (
thread/resumevia ACPresumeSession), but the cloud agent-server never used it —prepareNativeResumehard-returnednullfor anything non-Claude. Every Codex cloud resume therefore started a fresh thread and injected the prior conversation as a hidden Markdown blob, losing reasoning context, compaction state, structured tool history, and prompt-cache continuity.Change
prepareNativeResumenow handles Codex: it finds the prior session id from the run log (for Codex the ACP sessionId is the codex thread id) and checks whether the thread's rollout file still exists underCODEX_HOME/sessions/via the newhasCodexThreadStatehelper. If so, the server callsresumeSessionand the codex app-server restores the full thread natively — reasoning items, compaction state and all — with the continuation prompt riding the resumed thread.resumeSessionfails at boot (e.g. a corrupt rollout), the server logs a warning and falls back to a fresh session with the summary resume instead of failing the run. Applies to Claude too, which previously had no fallback there.Testing
@posthog/agentsuite: 1093 passed; remaining failures are pre-existing onmainand sandbox-environment artifacts (ambientGH_TOKEN, chmod no-op as root).tsc --noEmitand Biome clean.Follow-up (not in this PR)
CODEX_HOMEstate.