openai/codex · error · CodexError

Invalid JSON-RPC line: {line!r}

Error message

Invalid JSON-RPC line: {line!r}

What it means

Error "Invalid JSON-RPC line: {line!r}" thrown in openai/codex.

Source

Thrown at sdk/python/src/openai_codex/client.py:856

            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)

Solutions

  1. Update SDK and runtime to matching protocol versions; the process emitted a non JSON-RPC line.

When it happens

Trigger: Thrown at sdk/python/src/openai_codex/client.py:856 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of openai/codex@339751715c (2026-08-25). Data as JSON: /api/errors/9aa54bdd420faac5. Report an issue: GitHub.