hermes - 💡(How to fix) Fix Windows: Kanban worker crashes with NoConsoleScreenBufferError when stdout is redirected

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

File "cli.py", line 9602, in chat
    _cprint(f"{_DIM}Initializing agent...{_RST}")
File "cli.py", line 1480, in _cprint
    _pt_print(_PT_ANSI(text))
File "prompt_toolkit/shortcuts/utils.py", line 111, in print_formatted_text
    output = get_app_session().output
File "prompt_toolkit/application/current.py", line 67, in output
    self._output = create_output()
File "prompt_toolkit/output/defaults.py", line 91, in create_output
    return Win32Output(stdout, default_color_depth=color_depth_from_env)
File "prompt_toolkit/output/win32.py", line 115, in __init__
    info = self.get_win32_screen_buffer_info()
File "prompt_toolkit/output/win32.py", line 219, in get_win32_screen_buffer_info
    raise NoConsoleScreenBufferError
prompt_toolkit.output.win32.NoConsoleScreenBufferError: Found xterm-256color,
while expecting a Windows console.

Root Cause

The kanban dispatcher spawns workers via subprocess.Popen in _default_spawn() (hermes_cli/kanban_db.py, line 3760):

proc = subprocess.Popen(
    cmd,
    stdin=subprocess.DEVNULL,
    stdout=log_f,          # <-- redirected to file
    stderr=subprocess.STDOUT,
    env=env,
    start_new_session=True,
)

The child process has no Win32 console. When cli.py's chat() method calls _cprint("Initializing agent...") at line 9602, it invokes _pt_print(_PT_ANSI(text)). On Windows, prompt_toolkit's create_output() detects a non-console stdout and raises NoConsoleScreenBufferError.

_cprint() has no fallback for this exception — it propagates up and kills the worker before it can do any work.

Fix Action

Workaround

None currently. The worker crashes on every dispatch attempt, making kanban unusable on Windows.

Code Example

File "cli.py", line 9602, in chat
    _cprint(f"{_DIM}Initializing agent...{_RST}")
File "cli.py", line 1480, in _cprint
    _pt_print(_PT_ANSI(text))
File "prompt_toolkit/shortcuts/utils.py", line 111, in print_formatted_text
    output = get_app_session().output
File "prompt_toolkit/application/current.py", line 67, in output
    self._output = create_output()
File "prompt_toolkit/output/defaults.py", line 91, in create_output
    return Win32Output(stdout, default_color_depth=color_depth_from_env)
File "prompt_toolkit/output/win32.py", line 115, in __init__
    info = self.get_win32_screen_buffer_info()
File "prompt_toolkit/output/win32.py", line 219, in get_win32_screen_buffer_info
    raise NoConsoleScreenBufferError
prompt_toolkit.output.win32.NoConsoleScreenBufferError: Found xterm-256color,
while expecting a Windows console.

---

proc = subprocess.Popen(
    cmd,
    stdin=subprocess.DEVNULL,
    stdout=log_f,          # <-- redirected to file
    stderr=subprocess.STDOUT,
    env=env,
    start_new_session=True,
)

---

def _cprint(text: str):
    _record_output_history(text)
    # ... existing imports ...
    try:
        _pt_print(_PT_ANSI(text))
    except Exception:
        # Windows: NoConsoleScreenBufferError when stdout is redirected
        # (kanban workers, piped output). Fall back to plain print.
        print(text)
RAW_BUFFERClick to expand / collapse

Bug Description

On Windows 11, kanban workers crash immediately at startup when stdout is redirected to a log file. The crash occurs in _cprint() -> _pt_print() -> prompt_toolkit's create_output(), which raises NoConsoleScreenBufferError because there is no Win32 console buffer attached.

Environment

  • OS: Windows 11
  • Hermes Agent: v0.13.0 (2026.5.7)
  • Shell: git-bash (MSYS) — dispatcher runs here
  • Python: 3.12
  • prompt_toolkit: bundled venv

Reproduction Steps

  1. Create a kanban task: hermes kanban add "test task"
  2. Dispatch it: hermes kanban dispatch
  3. The spawned worker process (hermes chat -q "work kanban task ...") crashes immediately.

Stack Trace

File "cli.py", line 9602, in chat
    _cprint(f"{_DIM}Initializing agent...{_RST}")
File "cli.py", line 1480, in _cprint
    _pt_print(_PT_ANSI(text))
File "prompt_toolkit/shortcuts/utils.py", line 111, in print_formatted_text
    output = get_app_session().output
File "prompt_toolkit/application/current.py", line 67, in output
    self._output = create_output()
File "prompt_toolkit/output/defaults.py", line 91, in create_output
    return Win32Output(stdout, default_color_depth=color_depth_from_env)
File "prompt_toolkit/output/win32.py", line 115, in __init__
    info = self.get_win32_screen_buffer_info()
File "prompt_toolkit/output/win32.py", line 219, in get_win32_screen_buffer_info
    raise NoConsoleScreenBufferError
prompt_toolkit.output.win32.NoConsoleScreenBufferError: Found xterm-256color,
while expecting a Windows console.

Root Cause

The kanban dispatcher spawns workers via subprocess.Popen in _default_spawn() (hermes_cli/kanban_db.py, line 3760):

proc = subprocess.Popen(
    cmd,
    stdin=subprocess.DEVNULL,
    stdout=log_f,          # <-- redirected to file
    stderr=subprocess.STDOUT,
    env=env,
    start_new_session=True,
)

The child process has no Win32 console. When cli.py's chat() method calls _cprint("Initializing agent...") at line 9602, it invokes _pt_print(_PT_ANSI(text)). On Windows, prompt_toolkit's create_output() detects a non-console stdout and raises NoConsoleScreenBufferError.

_cprint() has no fallback for this exception — it propagates up and kills the worker before it can do any work.

Suggested Fix

Add a try/except around _pt_print calls in _cprint() (cli.py) to fall back to a plain print() when prompt_toolkit cannot create a Win32 console output:

def _cprint(text: str):
    _record_output_history(text)
    # ... existing imports ...
    try:
        _pt_print(_PT_ANSI(text))
    except Exception:
        # Windows: NoConsoleScreenBufferError when stdout is redirected
        # (kanban workers, piped output). Fall back to plain print.
        print(text)

This should wrap every _pt_print(_PT_ANSI(text)) call in _cprint() (lines 1480, 1504, 1516, 1524).

Impact

  • Severity: High — kanban is completely broken on Windows.
  • Scope: Only affects Windows when stdout is not a real console (kanban workers, redirected/piped output).
  • Normal interactive CLI: Not affected (has a real console).

Workaround

None currently. The worker crashes on every dispatch attempt, making kanban unusable on Windows.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING