Repository navigation
fix(vlm): read the streamed API answer from reasoning_content/tool calls and report stream errors - #5033
Conversation
…lls and report stream errors Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Alex Castillo <alex.castillog33@gmail.com>
|
✅ DCO Check Passed Thanks @pcbeingused333, all your commits are properly signed off. 🎉 |
Merge Protections🟢 Merge protection satisfied — ready to merge. Show 1 satisfied protection🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
AI triage (advisory)Checked commit The streaming API request path now uses Topic labels added: CI safety: no concern found. A maintainer must still approve CI. 1 related pull request(s) in the same code
The |
There was a problem hiding this comment.
AI first review (advisory): no blocker found
This review covers the full diff at b4c090f3e4. It read the code and did not run it.
I checked that streaming fallbacks for reasoning content and tool-call arguments align with the non-streaming path, and that SSE error chunks are correctly caught to report failures instead of truncations. All added test cases are complete and valid.
A maintainer makes the merge decision. This review never approves the pull request.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
@cau-git I think we need to think about this one ... |
| ) | ||
| text = "".join(full_text) | ||
| if not text: | ||
| text = "".join(reasoning_text).strip() |
There was a problem hiding this comment.
I am not sure we want the reasoning or tool-call in the text. It would be cleaner to have dedicated fields for those in the return object and assign them.
Continues #4561.
api_image_request_streamingread the answer fromdelta.contentonly, and a server error inside the stream ended the call as if it had succeeded._extract_generated_text) falls back toreasoning_contentand then to the text in the tool-call arguments whencontentis empty, because some OpenAI-compatible servers route the whole answer there. The streaming path now does the same: it collectsdelta.reasoning_contentand thedelta.tool_calls[].function.argumentsfragments (joined per call index), and uses them when nocontentwas streamed.contentstill wins, and the stoppers still look atcontentonly.data: {"error": {...}}with nochoiceswas skipped like any unexpected shape and the stream ended asEND_OF_SEQUENCEwith whatever text had arrived. It now ends the call the way an HTTP error does: an empty result witherrorset andINFERENCE_ERROR, so the page is reported as failed instead of as a truncated success.Checklist:
Review evidence: four tests in
tests/test_api_image_request.py(TestApiImageRequestStreamingFallbacks): reasoning-only stream, tool-call-argument stream split over two chunks,contenttaking precedence overreasoning_content, and an error chunk after partial text. Onmainthree of them fail (the precedence one already passed); with the changetests/test_api_image_request.pyandtests/test_api_usage_propagation.pypass (28 tests) andruff checkis clean. mypy, the full suite and requests against a real server were not run.This change was prepared with AI assistance (Claude Code).
🤖 Generated with Claude Code