openai/codex · error · TransportClosedError
Codex process closed stdout. stderr_tail=
Error message
Codex process closed stdout. stderr_tail={self._stderr_tail()[:2000]} What it means
_read_message got zero bytes from the Codex process's stdout: the child process exited or closed its stdout. The message embeds the last 2000 chars of captured stderr (_stderr_tail) to expose the crash cause; raised as TransportClosedError.
Solutions
- Inspect the stderr_tail in the message for the crash cause, fix it, and restart the Codex process.
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at sdk/python/src/openai_codex/client.py:849 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of openai/codex@339751715c (2026-08-25).
Data as JSON: /api/errors/1f050f590c3e8511.
Report an issue: GitHub.
Appendix: source
Thrown at sdk/python/src/openai_codex/client.py:849
return self._approval_handler(
method,
params if isinstance(params, dict) else None,
)
def _write_message(self, payload: JsonObject) -> None:
if self._proc is None or self._proc.stdin is None:
raise TransportClosedError("Codex process is not running")
with self._lock:
self._proc.stdin.write(json.dumps(payload) + "\n")
self._proc.stdin.flush()
def _read_message(self) -> dict[str, JsonValue]:
if self._proc is None or self._proc.stdout is None:
raise TransportClosedError("Codex process is not running")
line = self._proc.stdout.readline()
if not line:
raise TransportClosedError(
f"Codex process closed stdout. stderr_tail={self._stderr_tail()[:2000]}"
)
try:
message = json.loads(line)
except json.JSONDecodeError as exc:
raise CodexError(f"Invalid JSON-RPC line: {line!r}") from exc
if not isinstance(message, dict):
raise CodexError(f"Invalid JSON-RPC payload: {message!r}")
return message
def default_codex_home() -> str:
return str(Path.home() / ".codex")
View on GitHub (pinned to 339751715c)