fix(codex): auto-unarchive archived sessions before retry - #1088
Open
patleeman wants to merge 2 commits into
Open
fix(codex): auto-unarchive archived sessions before retry#1088patleeman wants to merge 2 commits into
patleeman wants to merge 2 commits into
Conversation
patleeman
marked this pull request as ready for review
August 6, 2026 21:49
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why this is needed
bb reaps idle thread-scoped Codex processes after 30 minutes and later resumes them by provider thread ID. The persisted Codex session can also be archived independently, for example when its thread is archived in Codex Desktop. If bb later sends
thread/resume,turn/start, orturn/steerfor that provider thread, Codex rejects the request, and bb surfaces the failure, leaving the user to unarchive the session manually before trying again.What changed
The runtime now recognizes Codex's archived-session error, sends
thread/unarchivefor the recorded provider thread, and retries the original request once. Recovery is limited to Codex and to that specific error, so other providers and other failures keep their existing behavior.The recovery uses the existing command path for resume, turn start, and steer, including resume during thread reconfiguration. Turn-start bookkeeping still rolls back correctly if either the initial request or the retry fails.
Persisted Codex threads now start with
ephemeral: false. This lets Codex materialize the rollout on disk so bb can resume it after reaping the provider process. The obsoletepersistExtendedHistoryfield is no longer sent on start or resume.Validation
The regression test reuses the existing fake provider and makes it return the archived-session error until bb sends
thread/unarchive. This covers the recovery path without adding a separate test process or harness.pnpm exec turbo run test --filter=@bb/agent-runtime— 811 tests passedpnpm exec turbo run test --filter=@bb/host-daemon— 479 tests passedpnpm exec turbo run typecheck --filter=@bb/agent-runtime --filter=@bb/host-daemon— passedgit diff --check— passedLive verification
I also ran the source dev app from this branch with the real Codex CLI. I created a disposable thread, confirmed the initial Codex response, and archived only its underlying provider session with
codex archive. I then restarted the dev host daemon to recreate the provider process and sent a normal follow-up throughpnpm bb:dev thread tell --mode auto.The follow-up completed successfully and returned
BB_LIVE_RESTARTED_RECOVERY_OK. The Codex rollout record moved from its archived-session store back into the active session store, confirming that bb unarchived the provider session before retrying.This remains a draft for maintainer review.