Skip to content

client: detect incomplete chat and generation streams - #797

Open
remote-controlled-man wants to merge 1 commit into
ollama:mainfrom
remote-controlled-man:codex/prflow-9d641f04f388
Open

remote-controlled-man wants to merge 1 commit into
ollama:mainfrom
remote-controlled-man:codex/prflow-9d641f04f388

Conversation

@remote-controlled-man

Copy link
Copy Markdown

A streamed chat() or generate() response can end cleanly at the HTTP layer before Ollama sends done: true. The sync and async iterators currently stop normally, allowing consumers to treat truncated output as complete.

Track the completion marker and raise the existing ResponseError at natural EOF when it is absent, while preserving chunks already yielded. This follows the completion check in the official JavaScript client. The change leaves non-streaming calls and pull/push/create progress streams unchanged.

The new stream tests fail on the original implementation (12 failed, 28 passed) and pass after the fix (40 passed, Python 3.12). They cover empty/incomplete streams, normal completion with and without a final newline, explicit close, and HTTP/server/JSON errors, including an error after done: true.

Validation on the final commit:

  • hatch test -acp: 162 passed in each of eight environments, Python 3.10–3.15, including 3.14t and 3.15t. Local requests explicitly bypassed the machine's proxy.
  • Hatch formatting/lint checks, uv lock --check, and the uv export comparison with requirements.txt passed.
  • uv build --sdist --wheel passed; both file lists were checked for accidental environment or reproduction artifacts.

The Hatch coverage controllers emitted no-data warnings, while the combined coverage report completed successfully. Hosted CI and Python 3.8/3.9 runtime tests have not been run; Python 3.8 syntax was checked.

Found through proactive local protocol fault injection using a local HTTP server, without model/API calls. Prepared with OpenAI Codex assistance.

Copilot AI balanced review requested due to automatic review settings November 11, 2026 16:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

This branch has not been deployed

No deployments
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