From 5c6bb9798b4f84612cb28c6e60249d2499a7ca84 Mon Sep 17 00:00:00 2001 From: pewdiepie-archdaemon Date: Mon, 26 Oct 2026 16:34:56 +0000 Subject: [PATCH] Preserve completion gating and handle explicit idle stream status safely --- src/agent_runtime/completion.py | 5 ----- static/js/chat.js | 7 ++++++- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/agent_runtime/completion.py b/src/agent_runtime/completion.py index 8cd5d164a..f667b6937 100644 --- a/src/agent_runtime/completion.py +++ b/src/agent_runtime/completion.py @@ -309,11 +309,6 @@ def with_completion_gate(func): has_final = False answer += str(data.get('delta') or '') answer_events.append(data) - if data.get('thinking') is True and 'delta' in data: - # Stream reasoning deltas live; only the answer - # prose is held for the terminal evidence review. - streamed_answer_events.add(id(data)) - yield _event(data) continue yield chunk if provider_error and not answer_events and not metrics_events: diff --git a/static/js/chat.js b/static/js/chat.js index 7b0d70418..1aae61fcf 100644 --- a/static/js/chat.js +++ b/static/js/chat.js @@ -6149,7 +6149,12 @@ import { invalidateSettings } from './appConfig.js'; cache: 'no-store', }); if (!_getForegroundStreamState() || _backgroundStreams.has(sid)) return; - if (res.status !== 404) return; + if (res.status !== 404 && !res.ok) return; + let _probe = null; + try { _probe = await res.json(); } catch (_) { /* An invalid response is not an idle stream. */ } + const _noActiveStream = res.status === 404 || (res.ok && _probe && + typeof _probe.status === 'string' && _probe.status !== 'streaming'); + if (!_noActiveStream) return; console.warn('[stream-watchdog] Local stream was stale and server has no active stream. Unlocking composer.'); if (active.abortCtrl && !active.abortCtrl.signal.aborted) {