Repository navigation
Avoid quadratic scans when confirming delivery of conversation history - #6218
Merged
Merged
Conversation
markstuart-oai
requested review from
a team,
rm-openai and
seratch
as code owners
November 25, 2026 02:44
Codex Review Summary: ✅ CompletedThis 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. |
jbeckwith-oai
approved these changes
Nov 25, 2026
jbeckwith-oai
left a comment
Contributor
There was a problem hiding this comment.
Reviewed delivery tracking, identity matching, fingerprint updates, and rewind/reordered-input coverage. The aligned-object shortcut preserves the existing identity fallback and delivery bookkeeping. No actionable findings. Static review only; no local code or tests run. Hosted CI: 24 successful checks on this commit.
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.
Summary
With 4,096 prior messages and one function call, a complete request through the Responses HTTP client has been taking 593 ms instead of 847 ms in offline tests. At 2,048 messages, elapsed time has been dropping from 334 to 275 ms.
The SDK has been marking conversation items as sent both before the model request and after the response. On the second pass, it has been scanning from the start of the sent list for each item. For a long history in the same order, the work has been growing quadratically.
With this change, the tracker has been checking for the same source object at the same position first. On a mismatch, it has been searching the whole list by identity. Both passes have been updating fingerprints and pending input as before. No cache or change to saved state.
Related work in #6193 on batch delivery. This version has been avoiding a separate index and a batch-size threshold.
Benchmarks
In a separate 18-block replay with a mock HTTP transport, the 4,096-message request has been taking 522 ms on this branch and 731 ms on main (−29.03%, 95% interval −30.79 to −27.18%). With no prior messages, both have been taking about 5.2 ms. The tests have been checking the call, its output, the full returned history and the single item sent on the second request.
Still uncertain — the small SQLite write, at +0.73% [−1.74, +5.53] in the independent repeat. The large write has been measuring +0.58% [−4.00, +2.17]. No changes to the SQLite path.
Regression checks across all 83 comparisons with Codex off. Offline Python SDK workloads on one Linux host with CPython 3.12.16. This change alone against
mainat4e162c79, without network or model latency.Timings and 95% intervals for all 83 comparisons
Test plan and checks
.agents/skills/code-change-verification/scripts/run.sh) including formatting, lint, mypy, Pyright and both pytest phases. 12,865 passed, 30 skipped.The example runner has been treating paths containing
serveras server examples. The first local suite has been reporting eight failures for this reason. In a neutral directory, the same files and file modes have been passing all 54 affected tests and the full verifier.