Skip to content

linearize history output normalization#28309

Merged
jif-oai merged 2 commits into
mainfrom
codex/linearize-history-normalization
Jun 15, 2026
Merged

linearize history output normalization#28309
jif-oai merged 2 commits into
mainfrom
codex/linearize-history-normalization

Conversation

@jif-oai

@jif-oai jif-oai commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Why

When we prepare the conversation history, every tool call needs a matching output.

Before this change, we scanned the full history again for every call. In a tool-heavy conversation, that makes the work O(items x calls), or O(n^2) in the worst case.

What

Scan the history once and collect the IDs of existing outputs. Then each call can check its ID with an expected O(1) lookup.

The full normalization step is now expected O(n). The output order and missing-output behavior stay the same.

Performance

Based on local rollout traces, one tool-heavy session reached roughly 17,050 transcript items with about 4,292 tool-call items. On a history of that shape, the old calls x items scan does about 73.2 million membership checks, while the new pass does about 21.3 thousand set inserts/lookups. That is roughly 3.4k times less membership work in this normalization step.

Validation

  • just test -p codex-core normalize_ (19 passed)

@jif-oai
jif-oai marked this pull request as ready for review June 15, 2026 13:22
@jif-oai
jif-oai requested a review from a team as a code owner June 15, 2026 13:22
@jif-oai jif-oai changed the title [codex] linearize history output normalization linearize history output normalization Jun 15, 2026
@jif-oai

jif-oai commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 242c548dfa

ℹ️ 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".

@jif-oai
jif-oai merged commit 828d747 into main Jun 15, 2026
31 checks passed
@jif-oai
jif-oai deleted the codex/linearize-history-normalization branch June 15, 2026 16:26
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants