Repository navigation
Error running remote compact task #14860
Description
What version of Codex CLI is running?
0.114.0
What subscription do you have?
Pro
Which model were you using?
gpt-5.4
What platform is your computer?
Linux 6.17.0-19-generic x86_64 x86_64
What terminal emulator and version are you using (if applicable)?
Codex CLI in terminal
What issue are you seeing?
Problem:
/compact fails after ~150s (30s timeout × 4 retries) with a misleading error message that obscures the real cause
Root cause:
original compact path does not set a per-request timeout; shared reqwest client inherits upstream defaults; reqwest sets Linux-family tcp_user_timeout to 30s
Proposed fix:
explicitly set a higher tcp_user_timeout in core/src/default_client.rs
Suggested diff:
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();
}
Additional notes:
- The error message
timeout waiting for child process to exitis misleading for this path and warrants a separate cleanup - Consider making this value overridable via
config.toml
What steps can reproduce the bug?
Platform: linux
APP: Codex CLI
Model: gpt-5.4
Keep using a context.. it will eventually get the error after filing to auto compact for ~150s Error running remote compact task: timeout waiting for child process to exit.
It compacts usually a 1-3 times okay before it stops being able to compact it.
What is the expected behavior?
That the system doesn't timeout each compact attempt in 30 seconds as that is not enough time for the API to finish.
Additional information
Hire me ;)
I chase bug relentlessly.
Activity
Grallen commentedon Mar 16, 2026
I should mention that I applied this fix on my local Codex CLI and it has solved the auto-compact and /compact issue for me. My compacts take about 45 to 65 second. I'm using 258K tokens in my
config.toml.peroksid90 commentedon Mar 17, 2026
I tried your fix - it works for me, now no any errors. Thank you!
CBZ199671 commentedon Mar 18, 2026
Is there a fix for the VSCode extension on Windows? I couldn't locate the core/src/default_client.rs file. I attempted to compile the Codex CLI from source and configured VSCode to load my custom-built binary. After restarting, I returned to a previously failed session (where compression had crashed) to see if it would perform the "compact" behavior correctly. However, it didn't seem to work.
The background information auto-compaction still fails with the following output:
"Error running remote compact task: stream disconnected before completion: error sending request for url (https://chatgpt.com/backend-api/codex/responses/compact)".
I’m not sure what went wrong. I suspect that a new session might be required to properly load the newly compiled CLI. I am currently testing this to see if the auto-compact bug persists after multiple compression attempts in a fresh session.
FixingInProd commentedon Mar 18, 2026
This issue still exists on 0.115.0. I'm getting the same problem you described. Running on Linux Mint. Did not have this issue operating on same giant codebase with same tasks on WIndows.
Grallen commentedon Mar 18, 2026
I can't guarantee it will work out for anyone else but, I tested this in case others are desperate.
So.. Codex is capable of making this modification on itself. I allowed it to get the repo, make the change, install everything it needed to compile, compile, and overwrite parts of its own installation. I'm on a VM I backed up before letting it try. Worked out first attempt though.
It would be so much better if someone with pull request powers saw this very tiny and safe change though.
FixingInProd commentedon Mar 18, 2026
That was my plan for tomorrow, I'll report back if it resolves it.
lvillis commentedon Mar 19, 2026
Same issue here — I’ve been seeing this ~150s timeout for months. This fix would definitely help. Thanks.
tang1024 commentedon Mar 19, 2026
Thank you! This helped! I patched and rebuilt codex-cli 0.115.0, replaced the local binary, and /compact is working for me now on RHEL.
Grallen commentedon Mar 19, 2026
I'm glad I could help.
it-zyf commentedon Mar 24, 2026
SheriffRabbit commentedon Mar 24, 2026
may also be caused by a conflict between Codex CLI and the App, especially if you are using both at the same time.
It can happen when both tools operate on the same directory, which may lead to unexpected behavior or inconsistencies (for example, concurrent edits or state conflicts in the same workspace ).
You just need to isolate them.
The quickest solution is to uninstall everything and then reinstall only one of them.
Before uninstalling, you can create a backup. Then have another agent restore only the chat history from the backup (do not restore any non-chat data).
miguelmanlyx commentedon Mar 24, 2026
Just a thought — that looks like a openai timeout failure. Could be worth a quick npx ai-doctor run to see what it flags.
Grallen commentedon Mar 24, 2026
There might be settings to control the timeout for the config.toml .. but this was for a different OS, so maybe not #14559 (comment)
EDIT: I've confirmed creating a provider and setting it timeout works
81 remaining items
chenzewang commentedon Jun 6, 2026
same issue
wxl2578 commentedon Jun 7, 2026
"If your development skills are lacking, just let AI do the development."
garyfpga commentedon Jun 8, 2026
https://github.com/garyfpga/codex-compact-fix
try my fork if you are using CLI
I change it to use local compact
garyfpga commentedon Jun 8, 2026
just use my fork for the moment
Rafik-Belkadi-Reccap commentedon Jun 9, 2026
Yo they fixed it in the last update, finally
SmartManoj commentedon Jun 11, 2026
Still happens in v0.139.0
@garyfpga Not created a PR?
garyfpga commentedon Jun 11, 2026
which 139 are you using, npm or the .sh one?
I am using the .sh one (which I assume is from the rust binary)
and the problem is gone.
But if you still have the problem, I can add the binary in my fork and you can use it (linux cli)
I actually did some more "optimization" on the compact path, like
let me know if using the .sh official binary fix your problem first. My fork is just AI slop, I think it is okay as a temp solution but isn't worthy to merge back.
SmartManoj commentedon Jun 11, 2026
I am using the .sh only
@garyfpga, sorry it is a different error, #18052 (comment)
garyfpga commentedon Jun 11, 2026
https://github.com/garyfpga/codex-compact-fix/releases/tag/codex-cli-binary-2026-06-09
use this if you don't wanna compile, or you can just use rustc to compile from source. takes 30 minutes in my machine
also add that in config.toml
it will first try max_attempts on remote compact, then fall back to local
local must always work but lower quality
[remote_compact]
max_attempts = 3
attempt_timeout_sec = 180
tcp_keepalive_interval_ms = 1000
garyfpga commentedon Jun 11, 2026
Damn, I found that what they do is switched to v2 remote compact and a few things, but it is not entirely fixed and I still sometimes hit that problem
I will properly maintain and release my version then
garyfpga commentedon Jun 12, 2026
etraut-openai commentedon Jun 29, 2026
Thanks for reporting this problem. Until recently, Codex used a separate endpoint and server-side logic for compaction. We recently switched to a more robust approach where the compaction logic is moved locally using the same endpoint as normal turns. This eliminates "remote compaction" errors and increases the stability and reliability of compaction operations. If you see further problems with compaction, please use
/feedbackand open a new bug report.PixelDrennen commentedon Aug 13, 2026
This still happens (notably as new behavior for myself) in Rider using Codex. Only just started today. After running some tests on an application for ~5 minutes and then continuing chat, it will always report the compact error. Only solution I can figure out is new chat with chat dump as the prompt. Hope this gets fixed in rider, seems it's outdated or something
garyfpga commentedon Aug 13, 2026
hello are you using vpn
if so, try to use web browser open chatgpt.com first
sometimes the compact endpoint is blocked by cloudflare challenge