Avoid rereading rollout history during cold resume - #27031
Merged
Conversation
zanieb
reviewed
Jun 8, 2026
zanie-oai
marked this pull request as ready for review
June 8, 2026 20:12
charliemarsh-oai
approved these changes
Jun 9, 2026
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
StoredThreadloaded while probing for a running threadProblem
thread/resumefirst reads the persisted thread with history while checking whether the thread isalready running. When no running process exists, cold resume currently falls through to
resume_thread_from_rollout, which reads and parses the same history again.That duplicate work grows with rollout size and remains on the synchronous resume path even when
the caller requests
excludeTurns.Background
The duplicate read was introduced by #24528, which fixed resume overrides for idle cached
threads. To support resumes specified by rollout path,
resume_running_threadbegan loading thestored thread with history so it could resolve the canonical thread ID and determine whether a
cached
CodexThreadwas already loaded.That history is needed when the loaded-thread path handles the request. On a cold miss, however,
the function's boolean result could only report that no loaded thread handled the request. It
discarded the history-bearing
StoredThread, and the normal cold-resume path immediately loadedand parsed the same rollout again.
This change preserves the idle cached-thread behavior from #24528 while allowing the cold-resume
path to reuse the probe result.
Performance
I benchmarked real retained rollouts using isolated
CODEX_HOMEdirectories, explicit rolloutpaths, debug builds of the commit and its exact parent, and alternating parent/patch order. The
table below uses
thread/resumewithexcludeTurns: true; response payload sizes were identical.The absolute saving increases with thread size, as expected when removing one complete JSONL
history read and parse. Total resume time is also content-dependent, so the relationship is not
perfectly linear.
I also tested full-history resume with
excludeTurns: false. The response payload wasbyte-identical between variants, and the same size-dependent improvement remained visible:
Validation
just test -p codex-app-server cold_thread_resume_reuses_non_local_history_probejust fix -p codex-app-server -p codex-thread-storejust fmt