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
Finalize streaming state and handle terminal events
Add a finalized flag to streamingState (markFinalized/isFinalized) and use it to guard finalization paths across the streaming lifecycle. Ensure streams are closed in runAgentLoopStreamStep and short-circuit when state is nil in finishStreamingWithFailure. Update responsesTurnAdapter/FinaleAgentLoop and chatCompletionsTurnAdapter to use isFinalized checks, make processResponseStreamEvent explicitly handle response.failed and response.incomplete (finalize metadata, log, and return loop-stop), and return on response.completed. Add early-finalize guard in completeStreamingSuccess. Include new tests to cover completed, failed, and finalize behavior. These changes prevent duplicate finalization/races and ensure terminal events stop the loop and close resources correctly.
0 commit comments