Skip to content

Error running remote compact task #14860

Closed

Description

@Grallen

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 exit is 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

  1. Grallen commented on Mar 16, 2026

    @Grallen
    Author

    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.

  2. peroksid90 commented on Mar 17, 2026

    @peroksid90

    I tried your fix - it works for me, now no any errors. Thank you!

  3. CBZ199671 commented on Mar 18, 2026

    @CBZ199671

    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.

  4. FixingInProd commented on Mar 18, 2026

    @FixingInProd

    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.

  5. Grallen commented on Mar 18, 2026

    @Grallen
    Author

    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.

  6. FixingInProd commented on Mar 18, 2026

    @FixingInProd

    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.

    That was my plan for tomorrow, I'll report back if it resolves it.

  7. lvillis commented on Mar 19, 2026

    @lvillis

    Same issue here — I’ve been seeing this ~150s timeout for months. This fix would definitely help. Thanks.

  8. tang1024 commented on Mar 19, 2026

    @tang1024

    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.

  9. Grallen commented on Mar 19, 2026

    @Grallen
    Author

    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.

    I'm glad I could help.

  10. added
    contextIssues related to context management (including compaction)
    on Mar 23, 2026
  11. it-zyf commented on Mar 24, 2026

    @it-zyf

    Image 为啥,每次提问都会报这样的问题

  12. SheriffRabbit commented on Mar 24, 2026

    @SheriffRabbit

    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).

  13. miguelmanlyx commented on Mar 24, 2026

    @miguelmanlyx

    Just a thought — that looks like a openai timeout failure. Could be worth a quick npx ai-doctor run to see what it flags.

  14. Grallen commented on Mar 24, 2026

    @Grallen
    Author

    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

  15. 81 remaining items

  16. chenzewang commented on Jun 6, 2026

    @chenzewang

    same issue

  17. wxl2578 commented on Jun 7, 2026

    @wxl2578

    "If your development skills are lacking, just let AI do the development."

  18. garyfpga commented on Jun 8, 2026

    @garyfpga

    https://github.com/garyfpga/codex-compact-fix

    try my fork if you are using CLI
    I change it to use local compact

  19. garyfpga commented on Jun 8, 2026

    @garyfpga

    they just shipped a big update but this is still open lol

    just use my fork for the moment

  20. Rafik-Belkadi-Reccap commented on Jun 9, 2026

    @Rafik-Belkadi-Reccap

    Yo they fixed it in the last update, finally

  21. SmartManoj commented on Jun 11, 2026

    @SmartManoj

    Still happens in v0.139.0

    garyfpga/codex-compact-fix

    try my fork if you are using CLI I change it to use local compact

    @garyfpga Not created a PR?

  22. garyfpga commented on Jun 11, 2026

    @garyfpga

    Still happens in v0.139.0

    garyfpga/codex-compact-fix
    try my fork if you are using CLI I change it to use local compact

    @garyfpga Not created a PR?

    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

    1. auto switch the /fast tier before compact
    2. switch back to the original tier afterward

    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.

  23. SmartManoj commented on Jun 11, 2026

    @SmartManoj

    I am using the .sh only

    ■ Error running remote compact task: {
        "error": {
          "message": "Your input exceeds the context window of this model. Please adjust your input and try again.",
          "type": "invalid_request_error",
          "param": "input",
          "code": "context_length_exceeded"
        }
      }
    

    @garyfpga, sorry it is a different error, #18052 (comment)

  24. garyfpga commented on Jun 11, 2026

    @garyfpga

    I am using the .sh only

    ■ Error running remote compact task: {
        "error": {
          "message": "Your input exceeds the context window of this model. Please adjust your input and try again.",
          "type": "invalid_request_error",
          "param": "input",
          "code": "context_length_exceeded"
        }
      }
    

    @garyfpga, sorry it is a different error, #18052 (comment)

    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

  25. garyfpga commented on Jun 11, 2026

    @garyfpga

    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

  26. garyfpga commented on Jun 12, 2026

    @garyfpga
    Image Just to show off a bit...
  27. etraut-openai commented on Jun 29, 2026

    @etraut-openai
    Contributor

    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 /feedback and open a new bug report.

  28. PixelDrennen commented on Aug 13, 2026

    @PixelDrennen

    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

  29. garyfpga commented on Aug 13, 2026

    @garyfpga

    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

    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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcontextIssues related to context management (including compaction)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions