Skip to content

Avoid false OpenAI stream failures on incomplete terminal events - #270

Merged
veithly merged 1 commit into
mainfrom
codex/fix-openai-incomplete-stream
Apr 22, 2026
Merged

Avoid false OpenAI stream failures on incomplete terminal events#270
veithly merged 1 commit into
mainfrom
codex/fix-openai-incomplete-stream

Conversation

@veithly

@veithly veithly commented Apr 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • treat OpenAI Responses response.incomplete as a valid terminal event
  • synthesize a partial terminal response when the stream ends after yielding usable text, reasoning, or tool calls
  • add focused regressions for incomplete and missing-terminal-event streaming paths

Testing

  • python -m pytest tests/test_tool_streaming_output.py::test_openai_chat_with_tools_accepts_response_incomplete_terminal_event tests/test_tool_streaming_output.py::test_openai_chat_with_tools_falls_back_to_streamed_tool_call_when_terminal_event_is_missing tests/test_tool_streaming_output.py::test_openai_chat_stream_uses_responses_reasoning_summary_when_effort_requested -q

The Responses streaming path treated any stream that ended without response.completed as a hard runtime error, including cancel/incomplete cases that already carried usable partial state. Accept response.incomplete, synthesize partial terminal responses when needed, and cover the behavior with focused regressions.

Constraint: keep provider-specific handling inside spoon-core and preserve existing streaming callbacks and metadata.
Rejected: surfacing the failure to spoon-bot as a generic runtime error; clearing partial output on incomplete streams.
Confidence: high
Scope-risk: medium
Reversibility: high
Directive: incomplete OpenAI Responses streams should degrade gracefully instead of poisoning agent control flow.
Tested: python -m pytest tests/test_tool_streaming_output.py::test_openai_chat_with_tools_accepts_response_incomplete_terminal_event tests/test_tool_streaming_output.py::test_openai_chat_with_tools_falls_back_to_streamed_tool_call_when_terminal_event_is_missing tests/test_tool_streaming_output.py::test_openai_chat_stream_uses_responses_reasoning_summary_when_effort_requested -q
Not-tested: full spoon-core suite
Related: OpenAI Responses stream cancel and incomplete handling
@veithly veithly changed the title Allow callers to control provider reasoning depth consistently Avoid false OpenAI stream failures on incomplete terminal events Apr 22, 2026
@veithly
veithly merged commit 2244e45 into main Apr 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant