# #33747 runtime transcript: settling a Codex thread and its MCP server

Setup for both sides: T3 dev server (T3CODE_DEV_SEED=0, fresh database), Codex CLI 0.163.0, one stub stdio MCP server (stub_mcp.py, logs start/SIGTERM) added via T3CODE_CODEX_LAUNCH_ARGS. One Codex thread created with 't3 thread start --wait' ('Reply with the single word: ok'), then settled from the sidebar's Settle button. Provider log lines trimmed to 260 chars.

```
## main 4c361199f4: real T3 dev server, Codex 0.163, stub stdio MCP injected via T3CODE_CODEX_LAUNCH_ARGS
thread settled at: 2026-11-10T07:59:57.627Z
[2026-11-10T07:59:57.643Z] outgoing {"id":4,"method":"thread/unsubscribe","params":{"threadId":"01a1c478-1fe3-7e52-ae7e-5eab69138378"}}
[2026-11-10T07:59:57.645Z] incoming {"id":4,"result":{"status":"unsubscribed"}}
stub MCP log:
1794297569.3 pid=360394 started
at 08:00:46 (49 s after settle):
    PID     ELAPSED COMMAND
 360394       01:17 python3 -I /tmp/issue-lead-33747-r1/repro/stub_mcp.py
```

Before: the stub stayed up after settle until the dev server was restarted for the fix (SIGTERM at 08:02:06 came from that restart, not from Codex).

```
## fix/issue-33747 5e90d1e189: same dev server (reloaded), Codex 0.163, stub stdio MCP via T3CODE_CODEX_LAUNCH_ARGS
app-server argv (parent of the stub MCP): codex app-server -c thread_unload_delay_secs=0 -c mcp_servers.stub.command=... (launch args from T3CODE_CODEX_LAUNCH_ARGS)
thread settled at: 2026-11-10T08:07:37.615Z
[2026-11-10T08:07:37.635Z] outgoing {"id":4,"method":"thread/unsubscribe","params":{"threadId":"01a1c47f-3b08-7973-ab5d-dd98a80090ff"}}
[2026-11-10T08:07:37.638Z] incoming {"id":4,"result":{"status":"unsubscribed"}}
[2026-11-10T08:07:37.660Z] incoming {"method":"thread/closed","params":{"threadId":"01a1c47f-3b08-7973-ab5d-dd98a80090ff"},"emittedAtMs":1794298057659}
stub MCP log (after run section):
--- after run 08:07:12
1794298035.1 pid=376613 started
1794298057.6 pid=376613 SIGTERM
at 08:07:47 (ps shows no process 376613):
    PID     ELAPSED COMMAND
```

# Final head 2ee9784c8d (adds the resume-after-closing retry)

```
## fix/issue-33747 2ee9784c8d: same dev server (reloaded)
thread settled at: 2026-11-10T08:29:13.263Z
[2026-11-10T08:29:13.270Z] outgoing {"id":4,"method":"thread/unsubscribe","params":{"threadId":"01a1c491-5e0b-7ba3-8781-c54f4f97d809"}}}}
[2026-11-10T08:29:13.272Z] incoming {"id":4,"result":{"status":"unsubscribed"}}}}
[2026-11-10T08:29:13.279Z] incoming {"method":"thread/closed","params":{"threadId":"01a1c491-5e0b-7ba3-8781-c54f4f97d809"},"emittedAtMs":1794299353276
[2026-11-10T08:29:31.825Z] outgoing {"id":5,"method":"thread/resume","params":{"threadId":"01a1c491-5e0b-7ba3-8781-c54f4f97d809","excludeTurns":true,"
stub MCP log:
--- head2 run 08:27:02 2ee9784c8d
1794299223.6 pid=415092 started
1794299353.3 pid=415092 SIGTERM
--- head2 follow-up 08:29:30
1794299371.9 pid=419357 started
follow-up 't3 thread send --wait' to the settled thread: reply 'again', exit 0 (thread/resume reloaded the thread and started a new MCP server)
```

# Model-free check against codex app-server 0.163 directly (driver.py)

## run-075415-default
```
+    0.0s spawned codex app-server pid=350646 args=[]
+    2.9s initialize -> {"userAgent": "repro/0.163.0 (Ubuntu 24.4.0; x86_64) unknown (repro; 0)", "codexHome": "/tmp/issue-lead-33747-r1/repro/run-075415-default/codex-home", "platformFamily": "unix",
+    6.3s stub MCP processes under app-server after thread/start: [350791]
+    6.4s thread/unsubscribe -> {"status": "unsubscribed"}
+    6.4s stub MCP processes under app-server: [350791]
+   52.3s end of watch; app-server alive=True; stub processes [350791]
```

## run-075514-delay0
```
+    0.0s spawned codex app-server pid=351641 args=['-c', 'thread_unload_delay_secs=0']
+    0.4s initialize -> {"userAgent": "repro/0.163.0 (Ubuntu 24.4.0; x86_64) unknown (repro; 0)", "codexHome": "/tmp/issue-lead-33747-r1/repro/run-075514-delay0/codex-home", "platformFamily": "unix", 
+    3.5s stub MCP processes under app-server after thread/start: [351747]
+    3.5s notification thread/status/changed {"threadId": "01a1c474-3d4d-7fb1-9803-d1918440f37b", "status": {"type": "notLoaded"}}
+    3.5s notification thread/closed {"threadId": "01a1c474-3d4d-7fb1-9803-d1918440f37b"}
+    3.5s thread/unsubscribe -> {"status": "unsubscribed"}
+    3.6s stub MCP processes under app-server: []
+   29.0s end of watch; app-server alive=True; stub processes []
```

## run-075629-order
```
+    0.0s spawned codex app-server pid=354505 args=['-c', 'thread_unload_delay_secs=0', '-c', 'thread_unload_delay_secs=1800']
+    0.2s initialize -> {"userAgent": "repro/0.163.0 (Ubuntu 24.4.0; x86_64) unknown (repro; 0)", "codexHome": "/tmp/issue-lead-33747-r1/repro/run-075629-order/codex-home", "platformFamily": "unix", "
+    3.3s stub MCP processes under app-server after thread/start: [354617]
+    3.3s thread/unsubscribe -> {"status": "unsubscribed"}
+    3.4s stub MCP processes under app-server: [354617]
+   11.5s end of watch; app-server alive=True; stub processes [354617]
```

## run-075640-order2
```
+    0.0s spawned codex app-server pid=354745 args=['-c', 'thread_unload_delay_secs=1800', '-c', 'thread_unload_delay_secs=0']
+    0.3s initialize -> {"userAgent": "repro/0.163.0 (Ubuntu 24.4.0; x86_64) unknown (repro; 0)", "codexHome": "/tmp/issue-lead-33747-r1/repro/run-075640-order2/codex-home", "platformFamily": "unix", 
+    3.4s stub MCP processes under app-server after thread/start: [354843]
+    3.4s notification thread/status/changed {"threadId": "01a1c475-8f92-7db2-87b0-2f62e09d8987", "status": {"type": "notLoaded"}}
+    3.4s notification thread/closed {"threadId": "01a1c475-8f92-7db2-87b0-2f62e09d8987"}
+    3.4s thread/unsubscribe -> {"status": "unsubscribed"}
+    3.5s stub MCP processes under app-server: []
+   11.7s end of watch; app-server alive=True; stub processes []
```
