Increase TCP user timeout for default client to avoid compaction hangs
What version of Codex CLI is running?
codex-cli 0.134.0
What subscription do you have?
GPT Pro 20x
Which model were you using?
gpt-5.5
What platform is your computer?
Ubuntu
What terminal emulator and version are you using (if applicable)?
_No response_
Codex doctor report
What issue are you seeing?
Long-running unary requests such as remote compaction can keep the connection open long enough that the default TCP user timeout is too short
on Linux-family targets.
When that happens, compaction may hang or fail before the server finishes responding.
## Fix
Set a bounded but longer timeout for the default client:
```rust
const DEFAULT_TCP_USER_TIMEOUT: Duration = Duration::from_secs(120);
and apply it when building the reqwest::Client:
builder = builder.tcp_user_timeout(DEFAULT_TCP_USER_TIMEOUT);
````rust
## Patch
diff --git a/codex-rs/core/src/default_client.rs b/codex-rs/core/src/default_client.rs
--- a/codex-rs/core/src/default_client.rs
+++ b/codex-rs/core/src/default_client.rs
@@
use std::sync::LazyLock;
use std::sync::Mutex;
use std::sync::RwLock;
+use std::time::Duration;
@@
pub const CODEX_INTERNAL_ORIGINATOR_OVERRIDE_ENV_VAR: &str = "CODEX_INTERNAL_ORIGINATOR_OVERRIDE";
pub const RESIDENCY_HEADER_NAME: &str = "x-openai-internal-codex-residency";
+const DEFAULT_TCP_USER_TIMEOUT: Duration = Duration::from_secs(120);
@@
let mut builder = reqwest::Client::builder()
.user_agent(ua)
.default_headers(default_headers());
- // reqwest defaults tcp_user_timeout to 30s on Linux-family targets, which is too short
- // for long-running unary requests such as remote compaction.
- builder = builder.tcp_user_timeout(DEFAULT_TCP_USER_TIMEOUT);
if is_sandboxed() {
builder = builder.no_proxy();
}
```
## Build
From the repository:
```
cd codex-rs
cargo build -p codex-cli --release
Optional musl build:
cargo build --target x86_64-unknown-linux-musl -p codex-cli --release
## Result
After applying this change and rebuilding, compact / remote compaction completed successfully instead of hanging.
## Comments
Increase TCP user timeout for default client
Set an explicit 120s tcp_user_timeout on the shared reqwest client.
The default timeout can be too short for long-running unary requests such
as remote compaction on Linux-family targets.
### What steps can reproduce the bug?
Use /goal and this bug will happen.
### What is the expected behavior?
_No response_
### Additional information
_No response_This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗