Repository navigation
Description
What version of Codex CLI is running?
0.169.0 (also reproduced on 0.167.0 and 0.166.0)
What subscription do you have?
ChatGPT sign-in, planType: prolite
Which model were you using?
n/a: only app-server account RPCs, no turns
What platform is your computer?
Linux 7.2.8-9-omarchy x86_64 unknown (Arch-based Omarchy 4.0.6)
What terminal emulator and version are you using (if applicable)?
n/a: codex app-server is spawned over stdio by a background process. It reproduces the same way from Ghostty 1.4.0.
Codex doctor report
{
"codexVersion": "0.167.0",
"overallStatus": "ok",
"checks": {
"app_server.status": "ok (background daemon app-server 0.169.0)",
"auth.credentials": "ok (stored auth mode chatgpt, file storage)",
"config.load": "ok",
"network.env": "ok (no proxy)",
"network.provider_reachability": "ok",
"network.websocket_reachability": "ok (HTTP 101; DNS 2 IPv4, 2 IPv6, first IPv6)"
}
}(Trimmed to the summary of each check; the full report is available on request.)
What issue are you seeing?
When a client sends account/read to codex app-server over stdio, the reply is often never written: in 4 of 5 runs on 0.169.0 it had not arrived after 30 s. The request finishes on the server side in about 0.5 s. The reply is written only once the client sends another request, and then it comes out together with that request's reply.
Server-side trace from a stalled run (RUST_LOG=codex_app_server=debug, with connection-pool lines and identifiers removed):
05:10:34.371966Z INFO app_server.request{rpc.method="account/read" rpc.request_id=2 rpc.transport="stdio"}: new
05:10:34.372010Z DEBUG app_server.request{...}:app_server.serialized_request_queue{key=Global("account-auth")}: new
05:10:34.883093Z DEBUG app_server.request{...}:app_server.serialized_request_queue{key=Global("account-auth")}: close time.busy=1.04ms time.idle=510ms
05:10:34.883112Z INFO app_server.request{rpc.method="account/read" rpc.request_id=2}: close time.busy=1.05ms time.idle=510ms
-- nothing on stdout for id 2; client waits 20 s, then sends id 3 --
05:10:54.410060Z INFO app_server.request{rpc.method="account/rateLimits/read" rpc.request_id=3}: new
05:10:54.862852Z INFO app_server.request{rpc.method="account/rateLimits/read" rpc.request_id=3}: close
What the client saw on stdout during that run:
[ 0.09s] {"id":1,"result":{...}} initialize
[ 0.40s] {"method":"remoteControl/status/changed",...}
[ 0.40s] {"method":"account/updated","params":{"authMode":"chatgpt","planType":"prolite"}}
[20.18s] (client gives up waiting, sends id 3 = account/rateLimits/read)
[20.51s] {"id":2,"result":{"account":{"type":"chatgpt",...}}} <- account/read, held since 0.5 s
[20.51s] {"id":3,"result":{"rateLimits":{...}}} <- same instant
In every stalled run the account/updated notification arrives at the moment the account/read reply should. In good runs both arrive within the same millisecond. That suggests a race between this notification and the reply on the outbound stdio path, where the reply is written but not flushed, or the writer isn't woken, until the next outbound message. This is a guess from the outside; I haven't read the source.
account/rateLimits/read sent on its own never stalled: 8 of 8 runs replied within 1.3 s.
What steps can reproduce the bug?
- Sign in with ChatGPT (
codex login). - Save the script below as
repro.pyand runpython3 repro.py 5, orpython3 repro.py 5 -- /path/to/codex app-serverto pick a binary.
The script starts codex app-server, sends initialize, initialized and account/read (id 2), and then either waits up to 30 s (wait) or sends account/rateLimits/read (id 3) after 5 s (poke).
Output on 0.169.0:
wait #1: 1 @0.2s | remoteControl/status/changed @0.5s | account/updated @0.5s | NO REPLY to id2 after 30s
wait #2: 1 @0.2s | remoteControl/status/changed @0.4s | account/updated @0.4s | 2 @0.4s
wait #3: 1 @0.2s | remoteControl/status/changed @0.5s | account/updated @0.5s | NO REPLY to id2 after 30s
wait #4: 1 @0.2s | remoteControl/status/changed @0.6s | account/updated @0.6s | NO REPLY to id2 after 30s
wait #5: 1 @0.2s | remoteControl/status/changed @0.4s | account/updated @0.4s | NO REPLY to id2 after 30s
poke #1: 1 @0.2s | remoteControl/status/changed @0.4s | account/updated @0.4s | 2 @0.4s
poke #2: 1 @0.2s | remoteControl/status/changed @0.4s | account/updated @0.4s | sent id3 @5.0s | 2 @5.4s
poke #3: 1 @0.2s | remoteControl/status/changed @0.4s | account/updated @0.4s | 2 @0.4s
poke #4: 1 @0.2s | remoteControl/status/changed @0.6s | account/updated @0.6s | 2 @0.6s
poke #5: 1 @0.2s | remoteControl/status/changed @0.4s | account/updated @0.4s | sent id3 @5.0s | 2 @5.3s
Every held reply is released once the next request completes.
repro.py
#!/usr/bin/env python3
"""Repro: `codex app-server` sometimes holds the account/read reply until the
client sends another message on stdin.
Usage: python3 repro.py [runs] [-- codex command...]
Default command: codex app-server
"""
import json
import select
import subprocess
import sys
import time
argv = sys.argv[1:]
cmd = ["codex", "app-server"]
if "--" in argv:
i = argv.index("--")
cmd = argv[i + 1:]
argv = argv[:i]
runs = int(argv[0]) if argv else 6
def run(mode):
proc = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL, text=True)
t0 = time.time()
def send(msg):
proc.stdin.write(json.dumps(msg) + "\n")
proc.stdin.flush()
send({"id": 1, "method": "initialize", "params": {"clientInfo": {"name": "repro", "version": "1"}}})
send({"method": "initialized", "params": {}})
time.sleep(0.2)
send({"id": 2, "method": "account/read", "params": {}})
events, poked = [], False
while time.time() - t0 < 30:
if mode == "poke" and not poked and time.time() - t0 > 5:
send({"id": 3, "method": "account/rateLimits/read", "params": {}})
poked = True
events.append(f"sent id3 @{time.time() - t0:.1f}s")
ready, _, _ = select.select([proc.stdout], [], [], 0.2)
if not ready:
continue
line = proc.stdout.readline()
if not line:
events.append("EOF")
break
try:
msg = json.loads(line)
except ValueError:
continue
events.append(f"{msg.get('id', msg.get('method'))} @{time.time() - t0:.1f}s")
if msg.get("id") == 2:
break
else:
events.append("NO REPLY to id2 after 30s")
proc.terminate()
try:
proc.wait(timeout=5)
except subprocess.TimeoutExpired:
proc.kill()
return events
for mode in ("wait", "poke"):
for n in range(runs):
print(f"{mode} #{n + 1}: " + " | ".join(run(mode)), flush=True)What is the expected behavior?
The account/read reply should be written to stdout as soon as the request completes, about 0.5 s here, whether or not the client sends anything else.
Additional information
- Real-world impact: Omarchy's bar widget (through 4.0.6) calls
account/readand thenaccount/rateLimits/readto show Codex limits. It waits up to 4 s for the first reply, so 7 of 10 refreshes report "Codex limits unavailable". Omarchy worked around it in Read Codex limits without waiting on account/read omacom/omarchy#13733, shipped in 4.5.0, by asking for the limits first. That PR saw the same stall on Codex 0.158, so this has been around for at least ten releases. - Related: Expose rate-limit window (5h/weekly) status via a stable, non-interactive interface #56370 (a stable non-interactive interface for rate-limit status). Tools are using app-server for exactly that today, which this bug breaks.
Activity
iyuzhang commentedon Nov 15, 2026
Confirmed the buffering explanation above against codex-cli 0.169.0, Linux x86_64, Python 3.12.3, ChatGPT sign-in: in an affected run,
account/updatedarrived at 1.733s, the reader timed out at 17.067s, and the pipe FD was not readable, yet a nonblockingproc.stdout.readline()immediately returned the successful id-2 reply without another stdin write.Two fresh-process controls using
text=Falsewithos.read()and persistent newline framing received notification + reply at 1.534s and 1.411–1.412s; this confirms that the posted reproduction can time out on an already-delivered reply, while the cause of the Omarchy/widget failures still needs separate verification.To check an affected run of the posted script, add
import osand insert this after the wait loop times out, before terminating the child:The affected run printed
fd readable: Falseandbuffered reply id: 2; no poke RPC was sent.goodman-oai commentedon Nov 16, 2026
A signed-in retest on Codex 0.169.0 found the
account/readreply already in the Python reader’s buffer before a second request. With a notification and reply written together, Omarchy’s 4.0.6 reader timed out in all three trials and its 4.5.0 reader returned the reply in all three. Omarchy shipped the client-side fix in 4.5.0.