Repository navigation
fix: batch OpenAI conversation session writes within the API limit - #5334
Conversation
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: 5e5a30566b
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4b3a79b717
ℹ️ 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".
markstuart-oai
left a comment
There was a problem hiding this comment.
One P2 finding: a partial batch can be replayed by the built-in Runner resume path when its saved suffix matches the previous history. The batching and lock ordering otherwise look sound. Reviewed the pinned source and hosted CI; I did not run repository tests locally.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ea1da4f367
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a674687b44
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 972d573d3e
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8ecddf7a3e
ℹ️ 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".
|
Thanks to everyone involved for fixing this and carefully handling concurrency, cancellation, and partial-write recovery. The implementation and review discussion helped me understand these failure cases much better. Really appreciate the work! |
Summary
This pull request fixes oversized conversation-session writes.
OpenAIConversationsSession.add_items()sent the full input list in one request, exceeding the Conversations API's 20-item limit for larger writes. Send sequential batches of at most 20 items while preserving input order and the existing public API. A per-instance mutation lock keeps concurrent reads, appends, pops, and clears from interleaving with a batched append.For multi-request appends, cancellation waits for the current request to complete or fail while retaining the instance lock, then raises the original cancellation without sending later chunks. A checkpoint between chunks delivers queued cancellation before scheduling the next mutation. Single-request cancellation behavior is unchanged. Multi-request appends also disable automatic client retries for each chunk, including configured retries, so a lost response raises an error instead of silently duplicating a saved chunk. The shared client’s settings and single-request retry behavior are unchanged.
Multi-request writes are non-atomic: failure or cancellation stops later batches and leaves earlier batches saved. The method docstring explains that callers must reconcile remote history before retrying; no automatic rollback or whole-list retry is added. Release-timed guidance in
docs/sessions/index.mdis a separate documentation follow-up.Runner resume also rejects ambiguous partial writes when repeated history could appear unchanged or fully committed. The existing repair-required error prevents duplicate appends or silently discarded pending items; provider ID matching and serialized RunState formats are unchanged. The new check is limited to multi-request Conversations writes; atomic backends and single-request recovery retain their existing behavior. When the prior snapshot contains all history, its item count distinguishes unchanged, partial, and full progress.
Test plan
httpx.MockTransport: 0, 20, 21, and 41 items; request ordering; partial failure; controlled cancellation; first/later lost-response chunks with default/custom retry settings and subsequent single-request retry compatibility; streaming and non-streaming Runner integration.Issue number
Closes #5333
Checks
.agents/skills/code-change-verification/scripts/run.sh/reviewbefore submitting this PR