-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Closed
Labels
Description
Description
Streaming Response Message Reconstruction Issue:
The current streaming implementation cannot correctly reconstruct the (await result.response).messages
array from streaming deltas, which prevents proper multi-turn conversation continuity. Specific issues include:
- Complex Reasoning Structure: Reasoning items can contain arrays of summary texts that cannot be properly reconstructed from individual deltas
- Missing Output Index: The
output_index
needed to correctly place chunk deltas in the final array structure is not exposed to consumers - Incomplete State Building: The streaming parser does not correctly build the final message state from deltas, particularly for complex reasoning content
- Multi-turn Conversation Breakage: For deep research models and similar advanced reasoning models, users cannot continue conversations with the correct message prefix without implementing custom parsing logic
This means that for streaming scenarios with reasoning models, developers currently need to either:
- Use non-streaming mode for multi-turn conversations, or
- Implement custom delta parsing logic (which lacks access to necessary metadata like
output_index
)
See real output from responses API to highlight this issue:
curl https://api.openai.com/v1/responses \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "o3-deep-research",
"input": "Research the economic impact of semaglutide on global healthcare systems. Include specific figures, trends, statistics, and measurable outcomes. Prioritize reliable, up-to-date sources: peer-reviewed research, health organizations (e.g., WHO, CDC), regulatory agencies, or pharmaceutical earnings reports. Include inline citations and return all source metadata. Be analytical, avoid generalities, and ensure that each section supports data-backed reasoning that could inform healthcare policy or financial modeling.",
"tools": [
{ "type": "web_search_preview" }
],
"reasoning": {
"effort": "medium",
"summary": "auto"
},
"include": ["reasoning.encrypted_content"],
"stream": true
}'
AI SDK Version
No response