Repository navigation
Description
Bug Description
On Windows, Hermes crashes when the copilot ACP subprocess emits UTF-8 characters (e.g. emojis). The _stdout_reader thread in agent/copilot_acp_client.py errors with a UnicodeDecodeError because of how the subprocess pipes are opened and decoded. Popen is called with text=True but without encoding, so Python uses the system codepage (cp1252), which cannot decode certain UTF-8 bytes.
Steps to Reproduce
- On Windows, run Hermes with the Copilot provider configured (default).
- Trigger image analysis or any flow that prints emoji or non-Latin characters (Hermes prints
'👁️ analyzing ...'during vision analysis). - Hermes crashes with
UnicodeDecodeErrorincopilot_acp_client.py _stdout_readerwhen iterating overproc.stdout.
Expected Behavior
The subprocess stdout/stderr pipes should be read as UTF-8 regardless of Windows locale. If the Copilot CLI uses UTF-8 output, Hermes must use encoding='utf-8' when opening the pipes to avoid crashes. The _stdout_reader loop should gracefully handle invalid bytes if necessary (errors='replace' or similar).
Actual Behavior
UnicodeDecodeError in copilot_acp_client.py at the _stdout_reader loop when iterating over proc.stdout. Example traceback:
UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position 7040: character maps to <undefined>
Affected Component
CLI (interactive chat), Other
Messaging Platform (if gateway-related)
N/A (CLI only)
Debug Report
Report https://paste.rs/6Do1r
agent.log https://paste.rs/HAbf0
gateway.log https://paste.rs/elTP6
desktop.log https://paste.rs/TzuhEOperating System
Windows_NT x64 10.0.26200
Python Version
3.14.3
Hermes Version
Hermes Agent v0.16.0 (2026.6.5) · upstream d62979a
Project: C:\Users\ar271\AppData\Local\hermes\hermes-agent
Python: 3.11.15
OpenAI SDK: 2.24.0
Additional Logs / Traceback (optional)
I can provide additional logs if helpful; the debug report links above contain the full agent.log and gateway logs.Root Cause Analysis (optional)
The root cause is an encoding mismatch when spawning the Copilot ACP subprocess. In agent/copilot_acp_client.py, the subprocess is started with text=True but without an explicit encoding argument, so Python uses the platform default encoding (CP1252 on many Windows systems). When the Copilot CLI emits UTF-8 bytes (for example, emojis or other characters outside CP1252), the stdout reader attempts to decode those bytes with CP1252 and raises UnicodeDecodeError.
Concretely, the problematic call is in _run_prompt, where the process is created like:
proc = subprocess.Popen(..., text=True, ...)The fix is to pass an explicit encoding (e.g. encoding='utf-8') or to read the streams in binary and decode with an error-safe strategy (e.g. errors='replace') so that non-decodable bytes do not crash the reader thread.
Proposed Fix (optional)
Add encoding='utf-8' to the subprocess.Popen call in _run_prompt (agent/copilot_acp_client.py line ~440). Optionally set errors='replace' or decode manually to avoid crashes on invalid bytes. Workaround: set PYTHONUTF8=1 in the environment.
Are you willing to submit a PR for this?
- I'd like to fix this myself and submit a PR
Activity
teknium1 commentedon Jul 24, 2026
Fixed in PR #70875 (merged, commit 0f732cb), which closes out this bug class codebase-wide. Every
subprocesscall withtext=Truenow passes an explicitencoding="utf-8", errors="replace"(163 call sites; salvaged from @Stoltemberg's #55339 and @jinglun010-cpu's #60741 with authorship preserved, extended to the sites that had landed since). @jinglun010-cpu's linter rule (#60751) now runs in CI viascripts/check-windows-footguns.py— any futuretext=Truewithout an explicitencoding=fails the build, so the class cannot silently regress.Two deliberate exceptions preserved:
schtasksoutput decodes with the locale code page (it genuinely emits OEM-encoded text, #38186), and cron's_run_job_scriptkeeps its platform-conditional decode. Platform-gated sites (Termux, Singularity, macOS-only) carry# windows-footgun: oksuppressions instead of blanket kwargs.The desktop/TUI backend half of this shipped earlier today in #70850. Update to latest; reopen with a fresh traceback if any decode crash persists.