The Codex app-server uses a "JSON-RPC lite" protocol over stdio (standard input/output).
Key Protocol Characteristics:
- Framing: The protocol uses newline-delimited JSON (NDJSON). Each individual JSON message is contained on a single line. You must buffer incoming data until a newline (
\n) is encountered before attempting to decode the JSON. - JSON-RPC Variant: It is a "lite" version that omits the standard
"jsonrpc": "2.0" field from the wire objects. - Transport: The default transport is
stdio (invoked via --listen stdio://). - Message Types: The protocol supports four main object shapes:
- Request: Includes an
id and expects a response. - Response: A successful result matching a request
id. - Error response: An error object matching a request
id. - Notification: A message with a
method but no id (no response expected).
Implementation Note
Do not use Content-Length framing or LSP headers. Use line-based reading (e.g., BufReader::lines() in Rust or line-mode ports in Elixir).
// Example Request
{"id":1,"method":"initialize","params":{"clientInfo":{"name":"client","version":"1.0"}}}
// Example Response
{"id":1,"result":{"userAgent":"..."}}
// Example Error
{"id":7,"error":{"code":-32001,"message":"Server overloaded; retry later."}}
// Example Notification
{"method":"turn/completed"}