From 13949a95e4532af80e055bbb3e919d4e2301244f Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Wed, 2 Sep 2026 19:36:12 -0700 Subject: [PATCH] refactor(gateway): keep _final_for_stream anchor pinned by test_stream_final_adoption_gate --- gateway/run_turn_runner.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gateway/run_turn_runner.py b/gateway/run_turn_runner.py index 7ece196e80..0081d693a8 100644 --- a/gateway/run_turn_runner.py +++ b/gateway/run_turn_runner.py @@ -1623,7 +1623,7 @@ class TurnRunner: # completed final: interrupt paths return {interrupted: True, completed: False} with a # DIAGNOSTIC final_response — adopting it would seal the partial answer over with the # diagnostic AND suppress the gateway's own error delivery. - final = None + _final_for_stream = None if ( isinstance(result, dict) and not result.get("failed") @@ -1632,13 +1632,13 @@ class TurnRunner: ): fr = result.get("final_response") if isinstance(fr, str) and fr.strip() and fr != "(empty)": - final = fr - if final is None: + _final_for_stream = fr + if _final_for_stream is None: stream_consumer.finish() return # Duck-type safe: test doubles / older consumers may expose a zero-arg finish(). try: - stream_consumer.finish(final) + stream_consumer.finish(_final_for_stream) except TypeError: stream_consumer.finish()