hermes - 💡(How to fix) Fix PTY stdin write fails: 'bytes' object cannot be converted to 'PyString'

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

When using terminal(pty=true, background=true) to run interactive CLI tools (e.g. opencode), the process(action="write") and process(action="submit") actions fail with:

argument to_write: bytes object cannot be converted to PyString

This blocks sending any input to PTY-based background processes.

Error Message

  1. Observe the error. The error message references PyString — a Python 2 C API type that was removed in Python 3. This suggests a Python 2/3 compatibility issue in the PTY stdin writing code path. Likely a ctypes or C extension call is using the wrong type for string data on Python 3.11.

Root Cause

When using terminal(pty=true, background=true) to run interactive CLI tools (e.g. opencode), the process(action="write") and process(action="submit") actions fail with:

argument to_write: bytes object cannot be converted to PyString

This blocks sending any input to PTY-based background processes.

Fix Action

Workaround

Use non-PTY mode or tmux as an intermediary for interactive CLI sessions (as documented in the Hermes spawning guide).

Code Example

argument to_write: bytes object cannot be converted to PyString

---

terminal(command="opencode", background=true, pty=true)

---

process(action="write", session_id="proc_xxx", data="test")
RAW_BUFFERClick to expand / collapse

Description

When using terminal(pty=true, background=true) to run interactive CLI tools (e.g. opencode), the process(action="write") and process(action="submit") actions fail with:

argument to_write: bytes object cannot be converted to PyString

This blocks sending any input to PTY-based background processes.

Steps to Reproduce

  1. Start a PTY process:
    terminal(command="opencode", background=true, pty=true)
  2. Try writing input:
    process(action="write", session_id="proc_xxx", data="test")
  3. Observe the error.

Environment

  • Hermes Agent: v0.15.1 (2026.5.29)
  • OS: Windows 10 (git-bash)
  • Python: 3.11.15
  • OpenAI SDK: 2.24.0

Notes

The error message references PyString — a Python 2 C API type that was removed in Python 3. This suggests a Python 2/3 compatibility issue in the PTY stdin writing code path. Likely a ctypes or C extension call is using the wrong type for string data on Python 3.11.

Workaround

Use non-PTY mode or tmux as an intermediary for interactive CLI sessions (as documented in the Hermes spawning guide).

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - 💡(How to fix) Fix PTY stdin write fails: 'bytes' object cannot be converted to 'PyString'