Problem
On Windows with a non-UTF-8 system locale (e.g. cp1252), running \doctor, \�udit, or any specsmith CLI command via the agent tool runner raises a \UnicodeDecodeError\ or produces garbled output.
The \doctor\ and \�udit\ commands output Unicode checkmark/cross characters (\✓\ U+2713, \✗\ U+2717) via Rich. These are valid UTF-8 bytes but cp1252 cannot decode them, causing the subprocess capture in _run_specsmith\ to fail.
Reproduction
- Windows system with default cp1252 locale
- Open a specsmith agent session (Ollama or any provider)
- Run the \doctor\ quick command
- Agent receives a \UnicodeDecodeError\ or cannot render the output
Root cause
In \src/specsmith/agent/tools.py, _run_specsmith\ calls:
\\python
result = subprocess.run(cmd, capture_output=True, text=True, timeout=120, env=_SUBPROCESS_ENV)
\\
\ ext=True\ without \�ncoding='utf-8'\ means Python uses the system default encoding (cp1252 on Windows) to decode stdout/stderr. The subprocess itself outputs UTF-8 (because \PYTHONIOENCODING=utf-8\ is set in the env), but the parent process decodes with cp1252 — mismatch causes the error.
Fix
Add \�ncoding='utf-8'\ and \�rrors='replace'\ to the \subprocess.run\ call in _run_specsmith:
\\python
result = subprocess.run(
cmd, capture_output=True, text=True,
encoding='utf-8', errors='replace',
timeout=120, env=_SUBPROCESS_ENV,
)
\\
Affected
All Windows users with non-UTF-8 system locale when the agent uses governance tools (audit, doctor, validate, etc.)
Problem
On Windows with a non-UTF-8 system locale (e.g. cp1252), running \doctor, \�udit, or any specsmith CLI command via the agent tool runner raises a \UnicodeDecodeError\ or produces garbled output.
The \doctor\ and \�udit\ commands output Unicode checkmark/cross characters (\✓\ U+2713, \✗\ U+2717) via Rich. These are valid UTF-8 bytes but cp1252 cannot decode them, causing the subprocess capture in _run_specsmith\ to fail.
Reproduction
Root cause
In \src/specsmith/agent/tools.py, _run_specsmith\ calls:
\\python
result = subprocess.run(cmd, capture_output=True, text=True, timeout=120, env=_SUBPROCESS_ENV)
\\
\ ext=True\ without \�ncoding='utf-8'\ means Python uses the system default encoding (cp1252 on Windows) to decode stdout/stderr. The subprocess itself outputs UTF-8 (because \PYTHONIOENCODING=utf-8\ is set in the env), but the parent process decodes with cp1252 — mismatch causes the error.
Fix
Add \�ncoding='utf-8'\ and \�rrors='replace'\ to the \subprocess.run\ call in _run_specsmith:
\\python
result = subprocess.run(
cmd, capture_output=True, text=True,
encoding='utf-8', errors='replace',
timeout=120, env=_SUBPROCESS_ENV,
)
\\
Affected
All Windows users with non-UTF-8 system locale when the agent uses governance tools (audit, doctor, validate, etc.)