-
Notifications
You must be signed in to change notification settings - Fork 103
fix(responses): persist conversation before stream completion #2707
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -859,7 +859,7 @@ async def shield_violation_generator( | |
| api_params: ResponsesApiParams | ||
| context: ResponsesContext | ||
| Yields: | ||
| SSE-formatted strings for streaming events, ending with [DONE] | ||
| SSE-formatted strings for streaming events | ||
| """ | ||
| normalized_conv_id = normalize_conversation_id(api_params.conversation) | ||
| available_quotas = get_available_quotas( | ||
|
|
@@ -935,8 +935,6 @@ async def shield_violation_generator( | |
| data_json = json.dumps(completed_event) | ||
| yield f"event: response.completed\ndata: {data_json}\n\n" | ||
|
|
||
| yield "data: [DONE]\n\n" | ||
|
|
||
|
|
||
| def _sanitize_response_dict( | ||
| response_dict: dict[str, Any], | ||
|
|
@@ -1249,8 +1247,6 @@ async def response_generator( | |
| latest_response_object.output, | ||
| ) | ||
|
|
||
| yield "data: [DONE]\n\n" | ||
|
|
||
|
|
||
| async def generate_response( | ||
| generator: AsyncIterator[str], | ||
|
|
@@ -1301,6 +1297,8 @@ async def generate_response( | |
| turn_summary.llm_response, | ||
| ) | ||
| _finalize_responses_root_span(root_span, turn_summary) | ||
| # Persist conversation state before clients can close the stream. | ||
| yield "data: [DONE]\n\n" | ||
| finally: | ||
| root_span.end() | ||
|
|
||
|
Comment on lines
1297
to
1304
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Assert persistence before
Record 🤖 Prompt for AI Agents |
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.