You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Auto-finalize ResponseStream on iteration completion (#4478)
* Add multi-turn streaming sample and rename multi-turn samples
- Rename 03_multi_turn.py to 03a_multi_turn.py
- Add 03b_multi_turn_streaming.py showing streaming with session history
- The new sample demonstrates calling get_final_response() after
iterating the stream to persist conversation history
- Update READMEs to reflect the new file names
Closes#4447
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Auto-finalize ResponseStream on iteration completion
When a ResponseStream is fully consumed via async iteration,
automatically trigger finalization (finalizer + result hooks).
This ensures session history is persisted in streaming multi-turn
conversations without requiring an explicit get_final_response() call.
- Add auto-finalize call in __anext__ on StopAsyncIteration
- Guard inner stream finalization to prevent double-execution
- Re-check _finalized after iteration in get_final_response()
- Add tests for auto-finalization and streaming session history
- Revert sample file renames from previous commit
Closes#4447
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* README fix
* Fix SIM102 lint: combine nested if statements
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
0 commit comments