From b7b3c8797f682dcc5fba1409a9cb90a7709b6b48 Mon Sep 17 00:00:00 2001 From: Teknium Date: Sat, 28 Mar 2026 12:32:00 -0700 Subject: [PATCH] fix(display): show reasoning during streaming even when tool calls suppress content MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a model generates content (containing tags) alongside tool calls in the same API response, content deltas were suppressed from streaming once any tool call chunk arrived. This prevented the CLI's tag extraction from running, so reasoning was never shown during streaming. The post-response fallback then displayed reasoning AFTER the already-visible streamed response, creating a confusing reversed order. Fix: route suppressed content to stream_delta_callback even when tool calls are present. The CLI's _stream_delta handles tag extraction — reasoning tags are routed to the reasoning display box, while non-reasoning text is handled by the existing stream display logic. This ensures reasoning appears before tool execution and the final response, matching the expected visual order. --- run_agent.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/run_agent.py b/run_agent.py index 65f67f8d9a9e..480451ed41e3 100644 --- a/run_agent.py +++ b/run_agent.py @@ -3903,6 +3903,23 @@ class AIAgent: _fire_first_delta() self._fire_stream_delta(delta.content) deltas_were_sent["yes"] = True + else: + # Tool calls suppress regular content streaming (avoids + # displaying chatty "I'll use the tool..." text alongside + # tool calls). But reasoning tags embedded in suppressed + # content should still reach the display — otherwise the + # reasoning box only appears as a post-response fallback, + # rendering it confusingly after the already-streamed + # response. Route suppressed content through the stream + # delta callback so its tag extraction can fire the + # reasoning display. Non-reasoning text is harmlessly + # suppressed by the CLI's _stream_delta when the stream + # box is already closed (tool boundary flush). + if self.stream_delta_callback: + try: + self.stream_delta_callback(delta.content) + except Exception: + pass # Accumulate tool call deltas — notify display on first name if delta and delta.tool_calls: