fix: prevent conversation sync failures from breaking response delivery - #5059
Closed
iamemilio wants to merge 1 commit into
Closed
fix: prevent conversation sync failures from breaking response delivery#5059iamemilio wants to merge 1 commit into
iamemilio wants to merge 1 commit into
Conversation
iamemilio
force-pushed
the
fix/sync-response-to-conversation-error-handling
branch
from
March 5, 2026 20:45
203c73e to
499a9fd
Compare
Wrap the conversation sync block in _create_streaming_response with a try/except so that failures in _sync_response_to_conversation or store_conversation_messages are logged but don't prevent the client from receiving the successfully generated response. Made-with: Cursor
iamemilio
force-pushed
the
fix/sync-response-to-conversation-error-handling
branch
from
March 5, 2026 20:46
499a9fd to
d10ed42
Compare
iamemilio
marked this pull request as ready for review
March 5, 2026 20:51
iamemilio
requested review from
ashwinb,
bbrowning,
cdoern,
ehhuang,
franciscojavierarceo,
leseb,
mattf and
raghotham
as code owners
March 5, 2026 20:51
Contributor
Author
|
Closing: swallowing the sync error would cause silent conversation context loss. The original behavior (propagating the exception) is correct — the client needs to know when a conversation write fails. |
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
When a response is created with a
conversationparameter,_create_streaming_responsesyncs the input and output items to the conversation after inference completes. Previously, if this sync failed (e.g. the conversation store was temporarily unavailable oradd_itemsraised), the exception propagated through the streaming generator. For non-streaming callers this meant losing the completed response entirely; for streaming callers theresponse.completedevent was never yielded. In both cases the client lost a successfully generated response because of a secondary side-effect failure.This PR wraps the conversation sync block in a
try/exceptso that sync failures are logged with the full traceback but don't prevent the client from receiving its response. The_sync_response_to_conversationmethod itself still raises, so callers that invoke it directly retain the original behavior.Test plan
test_sync_failure_still_yields_completed_responsepasses with the fix and fails without ittest_sync_response_to_conversation_api_errorstill passes (method itself still raises)