Repository navigation
fix: await typed LLM stream source cleanup - #1607
Conversation
|
No actionable comments were generated in the recent review. WalkthroughThe typed JSON stream adapter now awaits optional source-iterator cleanup when forwarding ends, including on early closure and conversion failures. Tests cover normal exhaustion, repeated closure, iteration and cleanup errors, encoding failures, and cancellation. ChangesTyped stream cleanup
Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix · Severity of issue fixed: Medium Merge Risk:
|
|
@ericevans-nv this should also target |
def9682 to
b243ec4
Compare
The base branch was changed.
Signed-off-by: Eric Evans II <[email protected]>
b243ec4 to
f95420a
Compare
Overview
Closing a stream returned by
nemo_relay.typed.llm_stream_execute()could finish without closing its source iterator, leaving source-owned resources open. This change awaits the source iterator’s optionalaclose()before forwarding finishes.Details
The typed wrapper previously forwarded chunks without a cleanup boundary. It now retains the source iterator and awaits its optional
aclose()in afinallyblock, including early closure, cancellation, and chunk-encoding failures. Cleanup errors propagate, and sources withoutaclose()remain supported.Adds a regression through the native SDK and unit coverage for normal exhaustion, awaited early cleanup, repeated closure, cancellation, and iteration, encoding, and cleanup failures. The public docstring explains that callers stopping early should await
stream.aclose().Public signatures and returned JSON chunk behavior are unchanged.
Validation passed: 12 focused stream tests, the canonical
just test-pythonsuite (81 native, 1,319 Python, and 24 example tests),just docs, and all applicable commit hooks. Fern’s published-redirect comparison was skipped because its service returned HTTP 403.Where should the reviewer start?
Start with the typed stream forwarding function, then the native-stream regression and lifecycle unit tests.
Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)
Summary by CodeRabbit