Skip to content

fix(cli): fall back to plain print when prompt_toolkit has no Win32 console#22482

Closed
0x003600x wants to merge 1 commit into
NousResearch:mainfrom
0x003600x:fix/cli-cprint-redirected-stdout-windows-22445
Closed

fix(cli): fall back to plain print when prompt_toolkit has no Win32 console#22482
0x003600x wants to merge 1 commit into
NousResearch:mainfrom
0x003600x:fix/cli-cprint-redirected-stdout-windows-22445

Conversation

@0x003600x

Copy link
Copy Markdown

Summary

Kanban worker processes on Windows spawn with stdout/stderr redirected to log files (subprocess.Popen in the Kanban dispatcher). In that setup there is no Win32 console buffer, so prompt_toolkit’s print_formatted_text path can raise NoConsoleScreenBufferError and the worker exits before doing work.

This change introduces _safe_pt_print in cli.py: try the existing ANSI → print_formatted_text path, and on any failure fall back to plain print(..., flush=True). All _cprint emission paths and output-history replay use this helper.

Related issue

Fixes #22445

Changes

  • cli.py: add _safe_pt_print; route _cprint and _replay_output_history through it.
  • tests/cli/test_cprint_redirect_fallback.py: regression tests when _pt_print raises and for replay history.

Testing

python -m pytest tests/cli/test_cprint_redirect_fallback.py -q -n 0

Kanban worker subprocesses redirect stdout to log files on Windows, so prompt_toolkit Win32Output raises NoConsoleScreenBufferError. Centralize emission in _safe_pt_print and use it from _cprint paths and output-history replay.

Fixes NousResearch#22445
@ygd58

ygd58 commented May 14, 2026

Copy link
Copy Markdown
Contributor

This is the canonical fix for NoConsoleScreenBufferError on Windows non-interactive contexts. Confirmed from kanban dispatcher logs: crashed=1 traces directly to this error. Closing my duplicate #25556 in favor of this PR.

@teknium1

Copy link
Copy Markdown
Contributor

Closing as superseded by #28330.

Triage notes (high confidence):
Fallback to plain print on Exception already present in cli.py:2017-2024 on origin/main; merged via PR #28330 (fix(windows): handle redirected stdout in _cprint fallback).

Thanks for the contribution — the underlying problem this PR addresses has been resolved by the linked PR on current main. If you believe this was closed in error, please comment and we'll reopen.

(Bulk-closed during a CLI PR triage sweep.)

@teknium1 teknium1 closed this May 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows: Kanban worker crashes with NoConsoleScreenBufferError when stdout is redirected

4 participants