fix(browser): decode Browser Use CLI stdout as UTF-8 - #87162
fix(browser): decode Browser Use CLI stdout as UTF-8#87162olympusbuildz wants to merge 1 commit into
Conversation
fix(browser): decode Browser Use CLI stdout as UTF-8 No blocking issues found. A few minor observations:
|
|
Confirmed reproduction on Chinese Windows (GBK locale, cp936), and it hits BOTH directions — not just reading the CLI's UTF-8 stdout:
Both disappear after adding Additional data point: Hermes 0.20.1 (git 423f92e) in an editable/git install still contains the unfixed call — so this affects the currently distributed version. |
Confirmed — Both read and write GBK-decoding directions confirmed addressed. Good. |
c687a19 to
1bafe2b
Compare
browser_exec ran subprocess with text=True and no encoding=. On Windows that uses the locale preferred encoding (cp1252/cp936), so UTF-8 CLI output with non-ASCII bytes kills the reader thread and returns empty tool output. Match install_cli and pass encoding=utf-8, errors=replace. Fixes NousResearch#87152 Signed-off-by: Olympusbuildz <Olympus.roots@outlook.com> Co-authored-by: Olympusbuildz <Olympus.roots@outlook.com> Signed-off-by: Olympusbuildz <Olympus.roots@outlook.com>
1bafe2b to
ea33896
Compare
Problem
On Windows,
browser_exec(Browser Use CLI backend) can return empty output even when the CLI succeeds. The subprocess reader thread dies with:UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 …(cp1252)Root cause
tools/browser_use_cli.pybrowser_execcallssubprocess.run(..., text=True)withoutencoding=. On Windows that decodes pipes withlocale.getpreferredencoding()while the Browser Use CLI emits UTF-8. Non-ASCII page text (em dash,€, …) crashes the reader.The sibling
install_clipath in the same file already passesencoding="utf-8", errors="replace". This call site was missed after the Browser Use CLI backend landed (related class: #47939 / #47456).Fix
Pass
encoding="utf-8", errors="replace"on the execsubprocess.run, matchinginstall_cliand other Windows-safe tool call sites.Why it matters
Windows users get intermittent empty
browser_execresults on any page with non-ASCII text — looks like flaky browser automation, is a decode bug.Test plan
9 passed @ this head (includes new regressions: kwargs assert utf-8/replace; non-ASCII stdout round-trip via UTF-8 fake CLI).
Risk
Low — same decode policy as install path;
errors="replace"avoids hard-fail on rare invalid bytes.Closest work
none found (open PR search for #87152 / browser_use_cli encoding empty)
Fixes #87152
Acceptance retest (2026-08-18)
Rebased onto current
main. Mini proof @1bafe2b68: tests/tools/test_browser_use_cli.py — 94 passed.