fix(run): preserve last known response_id on conversation resume#3245
Merged
seratch merged 1 commit intoopenai:mainfrom May 8, 2026
Merged
fix(run): preserve last known response_id on conversation resume#3245seratch merged 1 commit intoopenai:mainfrom
seratch merged 1 commit intoopenai:mainfrom
Conversation
…runs `OpenAIServerConversationTracker.hydrate_from_state` only inspects `model_responses[-1].response_id` when seeding `previous_response_id`. If the final saved response carries no id (for example, a non-Responses provider used mid-run), the chain silently resets to None even when earlier responses had valid ids. Live runs do not have this problem because `track_server_items` preserves the last non-None response_id across turns. Walk the saved responses and seed `previous_response_id` from the most recent response that actually has an id, mirroring the live-run behavior on resume.
Member
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep it up! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
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
OpenAIServerConversationTracker.hydrate_from_stateseedsprevious_response_idfrommodel_responses[-1].response_id. When the final saved response has no id (e.g., a non-Responses provider returnsresponse_id=None), the conversation chain silently resets toNoneon resume — even though earlier responses had valid ids.Live runs do not exhibit this because
track_server_itemsonly updatesprevious_response_idwhen the new response carries an id, preserving the last-known value across turns. Resume should mirror that behavior.Fix
Walk the saved
model_responsesand capture the most recent response that actually carries an id; seedprevious_response_idfrom that value instead of frommodel_responses[-1]unconditionally.Test plan
test_hydrate_from_state_uses_latest_non_none_response_idreproduces the bug — fails onmain, passes with the fix.tests/test_server_conversation_tracker.py(20 tests) all pass.conversation/tracker/resume/oaiconvkeywords pass.ruff checkandruff format --checkclean.