diff --git a/hermes_cli/pty_bridge.py b/hermes_cli/pty_bridge.py index 9a8a73bad..66fdb4ac7 100644 --- a/hermes_cli/pty_bridge.py +++ b/hermes_cli/pty_bridge.py @@ -108,9 +108,14 @@ class PtyBridge: "(or pip install -e '.[pty]')." ) raise PtyUnavailableError("Pseudo-terminals are unavailable.") - # Let caller-supplied env fully override inheritance; if they pass - # None we inherit the server's env (same semantics as subprocess). - spawn_env = os.environ.copy() if env is None else env + # PTY-hosted programs expect TERM to describe the terminal type. + # CI often runs without TERM in the parent process, which makes + # simple terminal probes like `tput cols` fail before winsize reads. + # Preserve explicit caller overrides, but backfill a sensible default + # when TERM is missing or blank. + spawn_env = (os.environ.copy() if env is None else env.copy()) + if not spawn_env.get("TERM"): + spawn_env["TERM"] = "xterm-256color" proc = ptyprocess.PtyProcess.spawn( # type: ignore[union-attr] list(argv), cwd=cwd,