Skip to content

fix(openai): drop response item ids when store is false - #38372

Merged
Mason Daugherty (mdrxy) merged 7 commits into
masterfrom
mdrxy-openai-store-false-response-ids
Jun 22, 2026
Merged

fix(openai): drop response item ids when store is false#38372
Mason Daugherty (mdrxy) merged 7 commits into
masterfrom
mdrxy-openai-store-false-response-ids

Conversation

@mdrxy

@mdrxy Mason Daugherty (mdrxy) commented Jun 22, 2026

Copy link
Copy Markdown
Member

Some Responses API conversations can safely replay prior response item IDs because the server stored those items. That assumption breaks when store=False: prior rs_* reasoning items and msg_* assistant message IDs are not available on the server for the next turn, so replaying them can crash with Item with id 'rs_...' not found or similar item lookup errors.

This updates the Responses API payload builder to treat store=False as a stateless replay mode. The visible assistant text is still preserved in history, but server-side response item IDs are not sent back unless they are usable without server persistence.

In practical terms:

  • Bare rs_* reasoning items are dropped for store=False because they only reference server-side state that was not stored.
  • Reasoning items with encrypted_content are preserved because OpenAI uses them as the stateless/ZDR way to carry reasoning context forward.
  • Prior assistant msg_* IDs are omitted for store=False; the assistant message is replayed as ordinary assistant text instead of as a reference to a stored server item.

Dropping msg_* IDs in this case should not remove useful user-visible context: the text content remains in the request. It only removes an item identity that the server cannot reliably resolve when store=False. Persisted store=True Responses flows continue to replay item IDs as before.

The regression test mirrors the minimal user story: make one Responses/Codex call, reuse the returned AIMessage in a follow-up request, and verify the next payload keeps the visible assistant message and encrypted reasoning context while omitting unresolvable bare item references.

@github-actions github-actions Bot added fix For PRs that implement a fix integration PR made that is related to a provider partner package integration internal openai `langchain-openai` package issues & PRs size: XS < 50 LOC labels Jun 22, 2026

@open-swe open-swe Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open SWE Review found 1 potential issue.

Open in WebView Open SWE trace

Comment thread libs/partners/openai/langchain_openai/chat_models/base.py
@github-actions github-actions Bot added size: S 50-199 LOC and removed size: XS < 50 LOC labels Jun 22, 2026
@github-actions github-actions Bot added size: M 200-499 LOC and removed size: S 50-199 LOC labels Jun 22, 2026
@mdrxy
Mason Daugherty (mdrxy) merged commit 792c1a7 into master Jun 22, 2026
94 checks passed
@mdrxy
Mason Daugherty (mdrxy) deleted the mdrxy-openai-store-false-response-ids branch June 22, 2026 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix For PRs that implement a fix integration PR made that is related to a provider partner package integration internal openai `langchain-openai` package issues & PRs size: M 200-499 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant