agents-cli update floods console with Python UnicodeDecodeError tracebacks on non-UTF-8 Windows consoles
agents-cli update floods the console with Python UnicodeDecodeError tracebacks on non-UTF-8 Windows consoles
Note: this report was drafted with AI assistance. The root cause, the reproduction, and the captured output were all verified on a real affected machine before filing.
Repo: google/agents-cli Version: agents-cli 0.5.0 Platform: Windows 11 (Spanish locale, OEM code page cp850), Python 3.12, Node v24.16.0
Summary
Running agents-cli update prints many copies of this traceback (one per spawned reader thread):
Exception in thread Thread-N (_readerthread):
Traceback (most recent call last):
File ".../threading.py", line 1012, in run
self._target(*self._args, **self._kwargs)
File ".../subprocess.py", line 1599, in _readerthread
buffer.append(fh.read())
File "<frozen codecs>", line 322, in decode
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa2 in position 3: invalid start byte
The update still proceeds (these are non-essential daemon reader threads), so it's cosmetic — but it's alarming noise and looks like a crash.
Root cause
agents-cli runs the underlying npx skills ... update command as a subprocess and reads its stdout/stderr in subprocess._readerthread, decoding as UTF-8. On a non-UTF-8 Windows console (here Spanish, OEM code page cp850) the child's output contains bytes that are not valid UTF-8 — e.g. 0xa2, which is ó in cp850. UTF-8 decoding of that byte raises UnicodeDecodeError and kills the reader thread.
The decode encoding is hard-coded rather than matched to the console code page, and there's no errors= fallback.
Reproduction
- Windows with a non-UTF-8 OEM console code page (e.g. Spanish cp850).
- Run
agents-cli update. - Observe the repeated
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa2 ...tracebacks.
Note: running the wrapped command directly (npx skills update -g) produces no such tracebacks — they come only from the Python subprocess wrapper's UTF-8 decoding.
Suggested fix
When capturing subprocess output, either:
- decode with a fallback:
subprocess.Popen(..., encoding="utf-8", errors="replace")(orerrors="backslashreplace"), or - decode using the console's actual code page instead of hard-coding UTF-8 (e.g.
locale.getpreferredencoding(False)/ the OEM code page on Windows), or - read bytes and decode explicitly with a fallback.
Any of these stops the reader threads from crashing on non-UTF-8 console output.
This should have been fixed back in April or so: since then, we do in fact use encoding="utf-8", errors="replace" for npx skills calls.
I have been unable to repro on my Windows test machine:
PS C:\Users\crwilson> chcp 850
Active code page: 850
PS C:\Users\crwilson> $env:PYTHONIOENCODING = "charmap"
PS C:\Users\crwilson> $env:PYTHONLEGACYWINDOWSSTDIO = "1"
PS C:\Users\crwilson> agents-cli update
@lenintorresact can you please verify if this is still an issue on the latest versions of agents-cli?
Going ahead and closing this, but please feel free to reopen if this is still an issue.