Skip to content

fix(run): preserve last known response_id on conversation resume#3245

Merged
seratch merged 1 commit intoopenai:mainfrom
adityasingh2400:fix/oaiconv-audit
May 8, 2026
Merged

fix(run): preserve last known response_id on conversation resume#3245
seratch merged 1 commit intoopenai:mainfrom
adityasingh2400:fix/oaiconv-audit

Conversation

@adityasingh2400
Copy link
Copy Markdown
Contributor

Summary

OpenAIServerConversationTracker.hydrate_from_state seeds previous_response_id from model_responses[-1].response_id. When the final saved response has no id (e.g., a non-Responses provider returns response_id=None), the conversation chain silently resets to None on resume — even though earlier responses had valid ids.

Live runs do not exhibit this because track_server_items only updates previous_response_id when the new response carries an id, preserving the last-known value across turns. Resume should mirror that behavior.

Fix

Walk the saved model_responses and capture the most recent response that actually carries an id; seed previous_response_id from that value instead of from model_responses[-1] unconditionally.

Test plan

  • New test test_hydrate_from_state_uses_latest_non_none_response_id reproduces the bug — fails on main, passes with the fix.
  • Existing tests/test_server_conversation_tracker.py (20 tests) all pass.
  • 249 tests across conversation/tracker/resume/oaiconv keywords pass.
  • ruff check and ruff format --check clean.

…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.
@github-actions github-actions Bot added bug Something isn't working feature:core labels May 8, 2026
@seratch
Copy link
Copy Markdown
Member

seratch commented May 8, 2026

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

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

@seratch seratch added this to the 0.17.x milestone May 8, 2026
@seratch seratch merged commit 250fb97 into openai:main May 8, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working feature:core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants