Skip to content

fix(openai): support opt-in streaming chat completions for long-running turns - #671

Open
BlueX888 wants to merge 2 commits into
OpenBMB:mainfrom
BlueX888:fix/653-stream-chat-completions
Open

fix(openai): support opt-in streaming chat completions for long-running turns#671
BlueX888 wants to merge 2 commits into
OpenBMB:mainfrom
BlueX888:fix/653-stream-chat-completions

Conversation

@BlueX888

@BlueX888 BlueX888 commented Sep 1, 2026

Copy link
Copy Markdown

What

Add an opt-in params.stream: true on the model node. When set, OpenAIProvider issues Chat Completions with stream=True (+ stream_options: {"include_usage": true}) and reassembles the chunks — content, tool calls, and usage — into the classic chat.completion shape, so token tracking, timeline recording, and deserialization are unchanged. Gateways that reject stream_options get one retry without it. Default (non-streaming) behavior is untouched.

Why

Anthropic-backed OpenAI-compatible endpoints (Anthropic API, Bedrock, enterprise LLM gateways) reject non-streaming operations that may exceed 10 minutes with HTTP 400 "Streaming is required". Any long single-turn output currently fails there, and the node's final_message becomes the error text.

How tested

7 new tests in tests/test_openai_provider_streaming.py: non-streaming default preserved, streaming opt-in flags, chunk reassembly into the classic response shape, streamed tool-call accumulation, stream_options rejection fallback, and call_model end-to-end. Full tests/ suite passes on Python 3.12.

Fixes #653

BlueX888 added 2 commits September 1, 2026 21:35
…ng turns

Non-streaming chat completions fail against Anthropic-backed
OpenAI-compatible endpoints once a turn exceeds the upstream 10-minute
cap (HTTP 400 'Streaming is required'). Add an opt-in params.stream flag
on the model node: the provider issues the request with stream=True and
stream_options include_usage, then reassembles the chunks (content,
tool calls, usage) into the classic chat.completion shape so the rest of
the pipeline is unchanged. Gateways that reject stream_options get one
retry without it.

Fixes OpenBMB#653
Add tests for the params.stream opt-in: non-streaming default preserved,
streaming request flags, chunk reassembly into the classic response
shape, streamed tool-call accumulation, stream_options rejection
fallback, and call_model end-to-end.
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.

Non-streaming chat completions fail against Anthropic-backed OpenAI-compatible endpoints on long-running turns (HTTP 400 "Streaming is required")

1 participant