Repository navigation
fix(agent): read long Codex sessions in pages - #416
Merged
Merged
Conversation
The session picker failed with "Codex app-server frame exceeds the limit" and took the whole Codex connection down. Codex answered with full histories and whole pasted prompts as list previews, which pass Red's frame limit for long sessions (one real thread is 303 MiB). - Page history with thread/turns/list: previews read the newest turns, continuations and resumes stop at the transcript's own limits, and a full page that is too large is retried as message summaries. Older app-servers fall back to thread/read. - Skip an oversized frame without buffering it and fail only the request it answers, recovering its id from the opening bytes. - Retry an oversized session-list page at half the size, and list only the 200 most recent sessions so the plugin stays within its instruction budget. - A truncated history only replays annotations into an empty record. - Clear the header's "restoring…" once the thread is back.
Contributor
Author
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a4d52d53b7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Summaries drop the tool calls that carry annotations, so a resume that downgraded a page could replace saved annotations with a partial set.
This was referenced Oct 23, 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 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.
Opening the Agent session picker (
Alt-s,:AgentSessions) failed with "Could not load sessions: Codex app-server failed: Codex app-server frame exceeds the limit", and the Codex connection went down with it. Red asked Codex for whole conversations in single responses, and real sessions are far bigger than Red's 1 MiB frame limit: five recent threads read back at 3 to 303 MiB, mostly tool output. Older threads also keep their whole first prompt as the list preview, so one 100-thread page of the session list reached 9 MiB. Any frame over the limit was treated as fatal, so one large response stopped everything.Fixing that exposed a second failure: with the All scope loaded (about 2,300 sessions), rendering the picker used up the Agent plugin's instruction budget, and Red quarantined the plugin.
What changed
History is read in pages (
src/codex/history.rs, new). Previews, continuations and resumes usethread/turns/list, newest first, instead ofthread/readwithincludeTurnsor a fullthread/resume:excludeTurns: trueand reads full turns, so annotations still replay from tool calls. If a full page is too large, it is retried as summaries. An app-server that ignoresexcludeTurnsstill sends turns in the resume response, and those are used as before.thread/turns/list, previews and continuations fall back tothread/read.An oversized frame fails only its own request. The reader skips the rest of the line without buffering it, and recovers the frame's id from its opening bytes (app-server responses start with
{"id":). The request it answers then gets an error. An oversized server request is refused so Codex doesn't wait for an answer, and an oversized notification is logged and dropped. The frame limit rises from 1 MiB to 8 MiB, matching plugin RPC.The session list stays bounded.
morewhen older ones were left out; the picker says to search for those. This also means Red no longer fetches every page (about 20 MiB in the All scope) before showing anything.Annotations from partial history. A history marked
historyTruncatedlacks earlier annotations, so its replay only fills an empty record and never replaces annotations Red saved.Header. The pane header's "restoring…" now clears when a restore finishes. Before, it stayed until the next turn ended.
How to Test
Alt-s. The Red scope list should load.Alt-stwice more to reach the All scope. The list should load and end with "Showing the 200 most recent · type to search older sessions".:plugin-statusshould still show the agent plugin as active.Alt-p. The preview should show its latest exchange.Targeted tests:
cargo test --test codex_app_server: paged previews and continuations, an oversized preview that fails alone, thethread/readfallback, halving an oversized list page, the 200-session cap, and resume both through paging (with an oversized full page retried as summaries) and from an app-server that ignoresexcludeTurns.cargo test --lib oversized_frames_are_skipped_and_keep_their_request_idcargo test --lib truncated_history_only_replays_annotations_into_an_empty_record