OpenViking icon indicating copy to clipboard operation
OpenViking copied to clipboard

[Bug]: AsyncStream' object has no attribute 'choices'

Open kjekro opened this issue 7 months ago • 3 comments

Bug Description

Tracebacks in the log:

2026-04-27 18:48:49,619 - openviking.session.compressor_v2 - ERROR - Failed to extract memories with v2: 'AsyncStream' object has no attribute 'choices' Traceback (most recent call last): File "/home/kjekro/.local/share/pipx/venvs/openviking/lib/python3.13/site-packages/openviking/session/compressor_v2.py", line 196, in extract_long_term_memories operations, tools_used = await orchestrator.run() ^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/kjekro/.local/share/pipx/venvs/openviking/lib/python3.13/site-packages/openviking/session/memory/extract_loop.py", line 202, in run tool_calls, operations = await self._call_llm(messages) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/kjekro/.local/share/pipx/venvs/openviking/lib/python3.13/site-packages/openviking/session/memory/extract_loop.py", line 366, in _call_llm response = await self.vlm.get_completion_async( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...<3 lines>... ) ^ File "/home/kjekro/.local/share/pipx/venvs/openviking/lib/python3.13/site-packages/openviking/telemetry/tracer.py", line 356, in async_wrapper return await func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/kjekro/.local/share/pipx/venvs/openviking/lib/python3.13/site-packages/openviking/models/vlm/backends/openai_vlm.py", line 404, in get_completion_async return await retry_async( ^^^^^^^^^^^^^^^^^^ ...<4 lines>... ) ^ File "/home/kjekro/.local/share/pipx/venvs/openviking/lib/python3.13/site-packages/openviking/utils/model_retry.py", line 129, in retry_async return await func() ^^^^^^^^^^^^ File "/home/kjekro/.local/share/pipx/venvs/openviking/lib/python3.13/site-packages/openviking/models/vlm/backends/openai_vlm.py", line 398, in _call return self._build_vlm_response(response, has_tools=True) ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/kjekro/.local/share/pipx/venvs/openviking/lib/python3.13/site-packages/openviking/models/vlm/backends/openai_vlm.py", line 179, in _build_vlm_response choice = response.choices[0] ^^^^^^^^^^^^^^^^ AttributeError: 'AsyncStream' object has no attribute 'choices'

Steps to Reproduce

Install with pix in linux nas openviking 0.3.13.dev0

OpenViking Doctor:

Config: PASS /home/kjekro/.openviking/ov.conf Python: PASS 3.13.5 (>= 3.10 required) Native Engine: PASS variant=x86_avx2 AGFS: PASS AGFS SDK 0.1.7 Embedding: PASS openai/Qwen3-Embedding-0.6B-Q8_0.gguf VLM: PASS openai/Qwen2.5-VL-7B-Instruct-Q5_K_M.gguf Ollama: PASS not configured Disk: PASS 155.3 GB free in /home/kjekro/.openviking/data

All checks passed.

Expected Behavior

No traceback

Actual Behavior

Minimal Reproducible Example

.\llama-b8946-bin-win-cpu-x64\llama-server.exe `
  -m Qwen2.5-VL-7B-Instruct-Q5_K_M.gguf `
  --host 192.168.10.123 `
  -ngl 0 `
  -c 16384 `
  --port 8082 `
  --mmproj Qwen2.5-VL-7B-Instruct-Q5_K_M_mmproj-F16.gguf `
  --jinja

+

.\llama-b8946-bin-win-cpu-x64\llama-server.exe `
  -hf Qwen/Qwen3-Embedding-0.6B-GGUF `
  --embeddings `
  --host 192.168.10.123 `
  --port 8081 `
  -c 8192 `
  -b 512 `
  -ub 512 `
  --n-gpu-layers 0 `
  --pooling last

Error Logs


OpenViking Version

0.3.13.dev0

Python Version

3.13.5

Operating System

Linux

Model Backend

None

Additional Context

ov.log ovconf.txt

kjekro avatar Apr 27 '26 19:04 kjekro

I've been looking into this — I want to trace the async response path and see where streamed chunks stop matching the expected choices shape. Happy to send a fix.

onthebed avatar Apr 27 '26 22:04 onthebed

Which vlm model are you using?

qin-ctx avatar May 06 '26 11:05 qin-ctx

Thanks for reporting this!

I looked at the attached ovconf.txt; the relevant part is that VLM streaming is explicitly enabled:

"stream": true

OpenViking does not currently support streaming responses on the OpenAI-compatible VLM path used by memory extraction with tools. That path calls get_completion_async(..., tools=...) and then parses the result as a complete non-streaming ChatCompletion object via response.choices[0]. When stream=true, the OpenAI SDK returns an AsyncStream instead, which is an async iterator of chunks and has no top-level choices attribute. That is why memory extraction logs AttributeError: 'AsyncStream' object has no attribute 'choices'.\n\nAs a workaround, please disable streaming for the VLM config:\n\njson\n"stream": false\n\n\nor remove the stream field, since the default is non-streaming.\n\nFrom the project side, the OpenAI-compatible backend should either force stream=False for internal tool-calling paths such as memory extraction, or implement proper streaming chunk aggregation for tool calls before parsing. For now, the supported configuration for this path is non-streaming.

qin-ctx avatar May 06 '26 12:05 qin-ctx