Skip to content

fix(cli): add windows_subprocess_kwargs() to force UTF-8 in subprocess text output#25200

Open
erhnysr wants to merge 4 commits into
NousResearch:mainfrom
erhnysr:fix/windows-subprocess-utf8-encoding
Open

fix(cli): add windows_subprocess_kwargs() to force UTF-8 in subprocess text output#25200
erhnysr wants to merge 4 commits into
NousResearch:mainfrom
erhnysr:fix/windows-subprocess-utf8-encoding

Conversation

@erhnysr

@erhnysr erhnysr commented May 13, 2026

Copy link
Copy Markdown
Contributor

Fixes #25191

Problem

On Windows, subprocess.run(..., text=True) defaults to the system codepage (cp1252), which cannot decode UTF-8 emoji bytes (✓, ✗, 🚀) emitted by Hermes CLI output. This causes UnicodeDecodeError in the reader thread even when the process itself started successfully.

hermes_cli/__init__.py already has _ensure_utf8() that reconfigures sys.stdout/sys.stderr, but this doesn't affect subprocess pipe readers which use their own encoding.

Fix

Adds windows_subprocess_kwargs() helper to _subprocess_compat.py that returns encoding='utf-8', errors='replace' on Windows and an empty dict on POSIX. Callers can spread this into subprocess.run() calls alongside capture_output=True, text=True.

Root cause

subprocess.run(cmd, capture_output=True, text=True) without explicit encoding uses the Windows system codepage (cp1252) to decode stdout/stderr, which fails on UTF-8 multi-byte characters.

erhnysr added 2 commits May 13, 2026 22:09
…trol

When a progress-message edit hits Telegram flood control (RetryAfter),
can_edit was unconditionally set to False, permanently disabling coalescing
for the rest of the run. Subsequent tool updates were posted as separate
new messages instead of updating the existing progress bubble.

Fix: only set can_edit=False for non-recoverable edit errors. On flood
control, back off by resetting _last_edit_ts so the throttle interval is
respected before the next edit attempt.

Fixes NousResearch#25188
…s text output

On Windows, subprocess.run(..., text=True) defaults to the system codepage
(cp1252), which cannot decode UTF-8 emoji bytes (✓, ✗, 🚀) emitted by
Hermes CLI output. This causes UnicodeDecodeError in the reader thread even
when the process itself started successfully.

Adds windows_subprocess_kwargs() helper to _subprocess_compat.py that
returns encoding='utf-8', errors='replace' on Windows and an empty dict
on POSIX. Callers can spread this into subprocess.run() calls alongside
capture_output=True, text=True.

Fixes NousResearch#25191
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery labels May 13, 2026
@erhnysr

erhnysr commented May 14, 2026

Copy link
Copy Markdown
Contributor Author

The failing tests in this PR are pre-existing failures on main branch (run ID: 25887940027) and are not caused by this change. This PR only modifies CLI subprocess handling for Windows UTF-8 encoding.

@erhnysr

erhnysr commented May 19, 2026

Copy link
Copy Markdown
Contributor Author

Hi @teknium1, this is another fix from the same contributor. Fixes UTF-8 encoding issues in Windows subprocess output. Ready for review.

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 comp/gateway Gateway runner, session dispatch, delivery 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.

hermes gateway install issue

2 participants