OpenViking icon indicating copy to clipboard operation
OpenViking copied to clipboard

[Bug]: OpenAIVLM ignores the configured stream flag — SSE/streaming providers broken; 11 unit tests fail on main

Open huangruiteng opened this issue 3 months ago • 4 comments

Bug Description

The stream config flag for the OpenAI-compatible VLM provider is accepted by VLMConfig/VLMBase (self.stream = config.get("stream", False) in openviking/models/vlm/base.py:78) and documented as supported, but OpenAIVLM no longer honors it. As a result, requests to providers that require/return SSE streaming (where the OpenAI SDK needs stream=true to parse the response) are broken, and token usage is not extracted from streaming chunks.

This is a regression introduced by PR #1711 ("Feat/memory isolation 支持群聊模式"), which removed:

  • _extract_from_chunk()
  • _process_streaming_response() / _process_streaming_response_async()
  • the "stream": self.stream kwarg from _build_text_kwargs() and _build_vision_kwargs()
  • the if self.stream: branch in _extract_completion_content() / _extract_completion_content_async()

…while the base class, VLMConfig migration, configuration docs, the changelog ("OpenAI VLM streaming"), and the codex_vlm backend (which still reads self.stream) all still treat streaming as a supported feature.

Evidence

The committed test suite tests/unit/test_stream_config_vlm.py encodes the contract and has 11 failures on current main (674f5e60), e.g.:

FAILED tests/unit/test_stream_config_vlm.py::TestVLMStreamConfig::test_stream_false_by_default
FAILED ...::test_stream_true_passed_to_api
FAILED ...::test_stream_false_uses_non_streaming_path
FAILED ...::test_async_stream_true
FAILED ...::test_vision_completion_stream_true
FAILED ...::TestStreamingResponseProcessing::test_process_streaming_response_with_content
...

Root failure: _build_text_kwargs() does not put stream in the API kwargs, so call_kwargs.get("stream") is None instead of False/True, and get_completion() tries to parse a chunk iterator as a non-streaming response.

Steps to Reproduce

PYTHONPATH=. .venv/bin/python -m pytest -q tests/unit/test_stream_config_vlm.py --no-cov
# 11 failed, 9 passed

Expected Behavior

  • stream: false (default) sends stream=false and uses the non-streaming response path (unchanged).
  • stream: true sends stream=true, concatenates choices[0].delta.content chunks, and records token usage from the final chunk usage.
  • get_completion_async, get_vision_completion, and get_vision_completion_async behave the same.

Impact

  • Documented configuration vlm.stream / per-credential providers.<name>.stream is silently ignored.
  • OpenAI-compatible gateways that force SSE responses cannot be used (the docs explicitly call this out: "OpenAI SDK 需要 stream=true 才能正确解析 SSE 响应").
  • 11 unit tests are red on main.

Proposed Fix

Restore streaming support in openviking/models/vlm/backends/openai_vlm.py:

  1. Re-add _extract_from_chunk(), _process_streaming_response(), and _process_streaming_response_async().
  2. Add "stream": self.stream to _build_vision_kwargs(), and to _build_text_kwargs() for non-tool calls (tool calls require the structured non-streaming message, so they correctly remain non-streaming).
  3. Branch _extract_completion_content() / _extract_completion_content_async() on self.stream.

This makes all 20 tests in tests/unit/test_stream_config_vlm.py pass with no production behavior change for the default stream=false path.

Environment

  • OpenViking: current main @ 674f5e60
  • Backend: N/A (unit-test verified; also affects OpenAI-compatible SSE providers)
  • Introduced by: #1711

huangruiteng avatar Aug 05 '26 21:08 huangruiteng

Update: after posting this I found the earlier draft implementations in #3406, #3756, and #3863. To avoid opening a fourth overlapping implementation, I am stepping back from #3755 and will not submit a PR here. Sorry for the noise.

HaningZS avatar Aug 18 '26 20:08 HaningZS

Status update for future readers: current main resolves this by explicitly rejecting the flag rather than restoring streaming — VLMConfig now raises on stream (and on extra_request_body.stream) with "stream is not supported; OpenViking VLM calls return complete responses" (openviking_cli/utils/config/vlm_config.py, _reject_stream_config), and the OpenAI VLM backend no longer reads a stream mode at all. The earlier draft implementations (#3406/#3756/#3863) were all closed without merging.

So the regression described here is now a deliberate product decision: OpenViking's VLM surface is completion-only. If a provider genuinely requires SSE to return anything, that's a new feature request (a supported streaming path with chunk aggregation), not a reopening of this bug. Suggest closing this issue as resolved-by-rejection — happy to convert it into a feature-request writeup if maintainers want to keep tracking the "SSE-only provider" case.

now-ing avatar Sep 03 '26 18:09 now-ing

+1 to closing as resolved-by-rejection per @now-ing — completion-only VLM is the current product decision on main; SSE-only providers would be a separate feature request.

ktz03 avatar Sep 04 '26 23:09 ktz03

Thanks for reporting this! #4541 resolves the silent configuration mismatch by explicitly rejecting stream, including extra_request_body.stream, instead of accepting it and quietly returning a non-streaming response. The current VLM contract is complete responses; remove these stream settings and use a provider endpoint that supports non-streaming requests.

Closing the ignored-configuration bug as resolved on main. This does not mean SSE-only providers are now supported; the separate streaming feature request is tracked in #5020.

If a version containing #4541 still silently accepts a stream setting, or a supported non-streaming request fails, please reopen, or comment requesting reopening, with the version, sanitized VLM configuration and error.

qin-ctx avatar Sep 18 '26 08:09 qin-ctx