mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-21 03:39:54 +00:00
e4adb67ed8
The KawaiiSpinner animation would occasionally spam dozens of duplicate lines instead of overwriting in-place with \r. This happened because prompt_toolkit's StdoutProxy processes each flush() as a separate run_in_terminal() call — when the write thread is slow (busy event loop during long tool executions), each \r frame gets its own call, and the terminal layout save/restore between calls breaks the \r overwrite semantics. Fix: rate-limit flush() calls to at most every 0.4s. Between flushes, \r-frame writes accumulate in StdoutProxy's buffer. When flushed, they concatenate into one string (e.g. \r frame1 \r frame2 \r frame3) and are written in a single run_in_terminal() call where \r works correctly. The spinner still animates (flush ~2.5x/sec) but each flush batches ~3 frames, guaranteeing the \r collapse always works. Most visible with execute_code and terminal tools (3+ second executions).