Skip to content

fix: close unconsumed cloud chat responses - #545

Open
rudycelekli wants to merge 1 commit into
VectifyAI:mainfrom
rudycelekli:fix/cloud-chat-close-unconsumed-streams-20261001
Open

rudycelekli wants to merge 1 commit into
VectifyAI:mainfrom
rudycelekli:fix/cloud-chat-close-unconsumed-streams-20261001

Conversation

@rudycelekli

Copy link
Copy Markdown

Cloud streams open an HTTP response immediately, but closing their unstarted parser generator never enters its cleanup block. Managed chat() additionally closes only an already opened view. As a result, .close() before the first iteration leaves the unread response and native socket open.

Give cloud streaming iterators explicit ownership of the response and let the managed ChatStream close its owned chunks even before a view starts. Cleanup remains idempotent, exhausted streams stay exhausted, and a parser cleanup exception still closes the response. Own-model streams retain lazy startup.

Validation: native HTTP/1.1 tests reproduce four unread-stream failures plus two parser-cleanup failures, with 13 passing controls before the fix. All 19 focused tests pass; removing the owning iterator's final response cleanup makes both exception-path regressions fail. The complete local python -m pytest -q passes 604 tests, 218 skipped on macOS/Python 3.12/PDFium 5 without optional agent frameworks. No live provider calls were used; the hosted Python 3.10/3.13/framework/PDFium matrix remains required.

Signed-off-by: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com>

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.

1 participant