From 26b44cebea96ba762e23b733676137824b4c742d Mon Sep 17 00:00:00 2001 From: Chris Guidry Date: Tue, 31 Mar 2026 08:31:50 -0400 Subject: [PATCH] Flush renderer word buffer when deferred tools start The last word before a run_code or roll tool call was hanging in the renderer's word buffer for the entire duration of the tool execution. Deferred notifications wait for ToolStop to extract the description/reason, but nothing was yielded at ToolStart, so the CLI never flushed the renderer. Now the engine yields an empty string at ToolStart for deferred tools, and the CLI flushes the renderer when it sees it. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/storied/cli.py | 3 +++ src/storied/engine.py | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/src/storied/cli.py b/src/storied/cli.py index 3d00387..d305d72 100644 --- a/src/storied/cli.py +++ b/src/storied/cli.py @@ -499,6 +499,9 @@ def cmd_play(args: argparse.Namespace) -> int: console.file.write("\n\n") console.print(f"[dim]{chunk}[/dim]") prev_type = "tool" + elif chunk == "": + # Flush signal from engine (deferred tool starting) + renderer.flush() else: if prev_type == "tool": console.print() diff --git a/src/storied/engine.py b/src/storied/engine.py index bfa5476..69a8516 100644 --- a/src/storied/engine.py +++ b/src/storied/engine.py @@ -439,6 +439,10 @@ class DMEngine: self.character_created = True if short in ("roll", "run_code") and not self.debug: + # Signal the CLI to flush the renderer before we + # wait for tool input (the notification comes at + # ToolStop once we know the reason/description). + yield "" deferred_notification = True elif self.debug: yield f"[→ {short}(...)]" -- 2.51.2