Skip to content

fix(codex): omit historical turns when resuming threads - #18

Merged
dviejokfs merged 2 commits into
mainfrom
fix/codex-resume-history
Sep 27, 2026
Merged

dviejokfs merged 2 commits into
mainfrom
fix/codex-resume-history

Conversation

@dviejokfs

Copy link
Copy Markdown
Contributor

Long Codex conversations could not continue because thread/resume returned their historical turns in a single JSON frame, exceeding the SDK's default 2 MiB limit. Request excludeTurns: true for resume and its active-writer fork fallback. Codex retains the saved context; only the response history is omitted. New-thread requests and the frame limit stay unchanged.

Evidence

  • Affected thread: read-only thread/read with includeTurns: true returned 2,889,662 bytes (16 turns); about 2.66 MB was command-execution items.
  • Actual thread/resume with excludeTurns: true on the same thread succeeded: 1,993 bytes, zero returned historical turns. No prompt/model turn sent.
  • cargo test --locked resume_and_writer_conflict_fork_exclude_historical_turns failed before the fix (Null versus true).
  • cargo test --locked --all-features: 312 passed, 1 existing ignored test.
  • cargo clippy --locked --all-targets --all-features -- -D warnings: passed.
  • cargo check --lib --locked: passed.
  • cargo fmt --all and git diff --check: passed.

The generated schema from the installed Codex CLI documents excludeTurns on both resume and fork. An existing handshake regression verifies a metadata-only resume response still starts the next turn.

@greptile-apps

greptile-apps Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

The PR appears safe to merge; the resume optimization is covered by focused tests and the prior documentation discoverability issue is fully addressed.

Findings

  1. P2 Guide Is Not Discoverable ▶

Summary

This PR prevents oversized Codex resume responses by requesting metadata-only responses while preserving the provider’s saved conversation context.

  • Adds excludeTurns: true to resumed threads and the active-writer fork fallback.
  • Keeps new-thread behavior and the existing frame-size limit unchanged.
  • Adds regression coverage for resume, fork, and new-thread request parameters.
  • Documents the behavior in the changelog, README, how-to guide, and documentation portal.
  • The previously reported documentation discoverability issue is fixed by registering the guide in the portal.
Diagram
sequenceDiagram
    participant Client
    participant SDK
    participant Codex

    Client->>SDK: Continue saved session
    SDK->>Codex: thread/resume(threadId, excludeTurns: true)
    alt Resume succeeds
        Codex-->>SDK: Thread metadata without historical turns
    else Active writer conflict
        SDK->>Codex: thread/fork(threadId, excludeTurns: true)
        Codex-->>SDK: Fork metadata without historical turns
    end
    SDK->>Codex: Start next turn
Loading

Reviews (2) · Last reviewed commit: "docs: link the large Codex conversation ..."

@@ -0,0 +1,11 @@
# Resume large Codex conversations

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Guide Is Not Discoverable

The documentation portal uses an explicit page registry, but this new guide is not registered there. As a result, users cannot find it through the portal navigation or search. Add it to site/src/content/docs.ts alongside the other how-to guides.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@dviejokfs
dviejokfs merged commit cf509cb into main Sep 27, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant