Repository navigation
fix(cli): buffer reasoning tokens to avoid one-token-per-line display - #3878
Merged
Merged
Conversation
Contributor
Author
Re-bin
approved these changes
May 17, 2026
Collaborator
There was a problem hiding this comment.
This is ready to merge. The original fix addresses the CLI reasoning-token display issue, and the follow-up commit keeps the buffering state local to each CLI progress path instead of using module-level mutable state. I also added focused regression coverage for buffering until a sentence boundary and flushing on reasoning_end.
Verified locally:
- CLI/reasoning/channel focused tests: 43 passed
- Full pytest after installing the missing local test dependency lxml_html_clean: 3201 passed, 4 skipped
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Problem
In CLI mode, streaming reasoning tokens from models like DeepSeek-V4 are
printed one per line with a
✻prefix, producing output like:This is because
_print_cli_reasoningcallsconsole.print()for everyindividual delta token, and Rich's
Console.print()adds a newlineeach time.
Solution
Add a module-level buffer (
_reasoning_buf) that accumulates incomingreasoning deltas and only flushes to the display when:
./!/?/。/!/?) is reachedA new
_flush_reasoning()helper handles the actual print, and boththe direct hook path (
_cli_progress) and the bus path(
_maybe_print_interactive_progress) flush remaining content whenreasoning_endis signaled.After
Changes
nanobot/cli/commands.py— 3 modifications:_reasoning_bufvariable_print_cli_reasoning→ buffer + flush; new_flush_reasoningreasoning_endin both_cli_progressand_maybe_print_interactive_progress