Codex Remote SSH auto-reconnect restarts intentionally stopped GitHub Codespaces
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 125k
- Forks
- 19.4k
- PR merge metrics
- PR metrics pending
Description
What variant of Codex are you using?
Codex Desktop
What feature would you like to see?
Summary
When Codex Desktop is connected to a GitHub Codespace through Remote SSH, stopping the Codespace intentionally does not keep it stopped.
Codex automatically attempts to reconnect to the remote host, which causes GitHub Codespaces to start the Codespace again.
As a result, the only reliable way I currently have to stop the Codespace is to manually disable the SSH remote connection in Codex settings before stopping it, and then enable it again the next time I want to work.
This adds unnecessary friction and, more importantly, can cause unintended Codespaces compute usage.
Environment
- Codex Desktop
- Remote SSH
- GitHub Codespaces
- Codespace accessed through its SSH configuration
- GitHub CLI used to explicitly stop the Codespace
Steps to reproduce
- Create or start a GitHub Codespace.
- Configure it as a Remote SSH connection in Codex Desktop.
- Open a project through that remote connection.
- Finish working but leave Codex Desktop open.
- Explicitly stop the Codespace:
gh codespace stop -c <codespace-name>
- Observe the Codespace after the SSH connection goes down.
Actual behavior
Codex detects that the SSH connection was lost and automatically attempts to reconnect.
Because the target is a GitHub Codespace, that reconnect attempt causes the intentionally stopped Codespace to start again.
The effective behavior becomes:
User stops Codespace
↓
SSH connection closes
↓
Codex auto-reconnects
↓
Codespaces starts the environment again
↓
Codespace continues consuming compute
To actually leave the Codespace stopped, I currently have to:
- Open Codex settings.
- Disable the Remote SSH connection.
- Stop the Codespace.
- Later re-enable the Remote SSH connection when I need it again.
Expected behavior
Codex should provide a supported way to keep a Remote SSH host configured without automatically reconnecting to it after an intentional shutdown.
Possible solutions could include:
- An
Auto reconnecttoggle per remote host. - A
Disconnect/Pause connectionaction that does not remove or disable the remote configuration. - Reconnect only while an active Codex task requires the remote.
- A retry limit followed by a disconnected state requiring explicit user action.
- Separate
EnabledandAuto-connectsettings.
For cloud development environments such as GitHub Codespaces, a particularly useful behavior would be:
Reconnect:
○ Always
● Only while needed by an active task
○ Never automatically
This would allow the native GitHub Codespaces idle timeout to work as intended.
Why this matters
For a normal SSH server, aggressive reconnect behavior is mostly an inconvenience.
For GitHub Codespaces and similar on-demand development environments, reconnecting has side effects: attempting an SSH connection can start billable compute resources that the user explicitly stopped.
This means Codex can unintentionally override the lifecycle decision made by the user.
Related issue
This appears related to:
- #35733 — Remote SSH auto-connect / repeated reconnection behavior and request for lazy connections.
However, this case has an additional consequence specific to on-demand cloud environments: the automatic reconnect can restart infrastructure that the user intentionally stopped.
Because of that, I believe supporting an explicit disconnected state or disabling automatic reconnect independently from the remote configuration would be useful.
Additional information
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the behavior with the GitHub CLI command shown in the issue and review related issue #35733 for the existing Remote SSH reconnect design. Trace where Codex Desktop detects a lost SSH connection and initiates retries. Done means an intentionally stopped Codespace remains stopped without requiring the remote configuration to be disabled, with the chosen disconnected-state behavior covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- github
- Domain
- cloud, desktop
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100