Resume exec-server sessions after disconnect#28512
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d22147952e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 447d8fb4ea
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Supersedes #28288 (closed).
Why
A short WebSocket interruption currently ends every client-side process handle, even though exec-server keeps the server session and its processes alive for a short time.
This is especially visible for executor-backed stdio MCP servers: a temporary connection loss becomes a permanent
Transport closederror. The server already has the information needed to resume the session, but the client opens a fresh session instead of using it.This change reconnects below the process and MCP layers. Existing process handles stay valid, missed output is recovered, and the same server-side processes continue running.
State machine
One logical
ExecServerClientstays alive while its underlying RPC connection changes generations.ConnectedRecoveringsession_id. The server may briefly report that the old connection is still attached, so that error is retried until the detach finishes.process/read.FailedRecovering process events
Output, exit, and close events share one sequence. During normal operation, the client buffers early events until every lower sequence has been published.
After reconnection, the client reads each process starting after its last published sequence:
The server reports its full next event sequence for unbounded reads, including exit and close events. Closed processes remain readable for the same 30-second window used to retain detached sessions.
Other details
User impact
Long-running commands and stdio MCP servers can survive a temporary exec-server WebSocket interruption without changing process IDs or losing output produced during the outage.