Skip to content

fix(infer): ignore SSE heartbeat comments in InferClient - #10086

Merged
hjh0119 merged 1 commit into
modelscope:mainfrom
Excelius-Wang:fix/infer-client-sse-comments
Sep 10, 2026
Merged

hjh0119 merged 1 commit into
modelscope:mainfrom
Excelius-Wang:fix/infer-client-sse-comments

Conversation

@Excelius-Wang

Copy link
Copy Markdown
Contributor

InferClient currently asserts that every nonblank streaming line starts with data:. Valid SSE comment heartbeats therefore abort generation with AssertionError, including the : OPENROUTER PROCESSING heartbeat documented by OpenRouter.

Skip comment lines in the existing parser, as required by the SSE specification. Data payloads, [DONE], and server error handling remain unchanged. See OpenRouter's documented heartbeat example.

Validation: eight unittest methods pass, including real local aiohttp HTTP streaming with leading/interleaved heartbeats, LF/CRLF, fragmented UTF-8 content, [DONE], an error after a heartbeat, malformed JSON, comment-only streams, and usage events after a comment resembling [DONE]. The same tests produce ten assertion failures on the baseline. Applicable pre-commit hooks pass. No external API call or GPU is required.

@hjh0119
hjh0119 merged commit 1b2dd1a into modelscope:main Sep 10, 2026
3 checks 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.

2 participants