TOO MUCH Error running remote compact task

Resolved 💬 8 comments Opened May 25, 2026 by whj0425 Closed Jun 29, 2026
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

What version of the Codex App are you using (From “About Codex” dialog)?

26.519.41501 (3044)

What subscription do you have?

pro 100USD

What platform is your computer?

Darwin 25.5.0 arm64 arm

What issue are you seeing?

Ever since a certain release of version 5.5, I've frequently encountered this issue whenever the context length becomes even moderately long. From my experience, the probability exceeds 50%, making Codex completely unusable now. In previous versions, I never experienced this problem, even with equally long contexts and under the same network conditions. This issue suddenly appeared in a recent update and has been occurring extremely frequently ever since. I encounter it heavily every day, and it's driving me to the brink of breakdown.

Codex ran out of room in the model's context window. Start a new thread or clear earlier history before retrying.
Error running remote compact task: stream disconnected before completion: error sending request for url (https://chatgpt.com/backend-api/codex/responses/compact)

What steps can reproduce the bug?

Feedback ID: 019e5f50-13ea-7a70-b8c6-37b28d5ccff7

What is the expected behavior?

_No response_

Additional information

_No response_

View original on GitHub ↗

8 Comments

github-actions[bot] contributor · 1 month ago

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #23733
  • #23050
  • #23263
  • #24378

Powered by Codex Action

jshaofa-ui · 1 month ago

Solution: openai/codex #24449 — TOO MUCH Error running remote compact task

Issue Summary

Since Codex v5.5, when context length becomes moderately long (>50% probability), the remote compaction task fails with: "stream disconnected before completion: error sending request for url (https://chatgpt.com/backend-api/codex/responses/compact)". This makes Codex completely unusable for long conversations. The error appeared suddenly in a recent release, indicating a regression.

Root Cause Analysis

The Error Pattern

TOO MUCH Error running remote compact task:
stream disconnected before completion:
error sending request for url (https://chatgpt.com/backend-api/codex/responses/compact)

Likely Causes

  1. Request timeout: The compaction request to the backend API times out for long contexts. The error sending request suggests a network-level failure (timeout, connection reset).
  1. Stream disconnection: The SSE/streaming connection to the compaction endpoint is dropped before completion. This could be due to:
  • Backend-side timeout for large compaction requests
  • Client-side read timeout
  • Network intermediary (proxy, firewall) dropping long-lived connections
  1. Regression in v5.5: The issue appeared suddenly, suggesting a change in:
  • The compaction request format/size
  • The timeout configuration
  • The streaming connection handling

Code Location

The compaction logic is likely in:

  • Desktop app: src/compaction/ or src/session/compact.ts
  • Extension: src/compact/ or similar

Proposed Fix

Fix 1: Increase compaction timeout with retry

// src/compaction/remote-compact.ts

const COMPACTION_CONFIG = {
  // Increase timeout for long contexts
  timeoutMs: 120_000,  // 2 minutes (was likely 30-60s)
  // Add retry with exponential backoff
  maxRetries: 3,
  retryDelayMs: 5_000,
};

async function runRemoteCompaction(
  sessionId: string,
  messages: Message[],
): Promise<CompactionResult> {
  let lastError: Error | null = null;
  
  for (let attempt = 0; attempt < COMPACTION_CONFIG.maxRetries; attempt++) {
    try {
      const controller = new AbortController();
      const timeoutId = setTimeout(
        () => controller.abort(),
        COMPACTION_CONFIG.timeoutMs
      );
      
      const response = await fetch(
        `${BACKEND_API}/codex/responses/compact`,
        {
          method: 'POST',
          headers: { 'Content-Type': 'application/json' },
          body: JSON.stringify({ sessionId, messages }),
          signal: controller.signal,
        }
      );
      
      clearTimeout(timeoutId);
      
      if (!response.ok) {
        throw new Error(`Compaction failed: ${response.status}`);
      }
      
      return await response.json();
    } catch (error) {
      lastError = error as Error;
      
      if (error instanceof DOMException && error.name === 'AbortError') {
        logger.warn(`Compaction attempt ${attempt + 1} timed out, retrying...`);
      } else {
        throw error;  // Non-timeout errors should fail immediately
      }
      
      // Exponential backoff
      await sleep(COMPACTION_CONFIG.retryDelayMs * Math.pow(2, attempt));
    }
  }
  
  throw new Error(
    `Compaction failed after ${COMPACTION_CONFIG.maxRetries} attempts: ${lastError?.message}`
  );
}

Fix 2: Chunked compaction for very long contexts

For extremely long conversations, split compaction into chunks:

async function runChunkedCompaction(
  sessionId: string,
  messages: Message[],
  chunkSize: number = 50,
): Promise<CompactionResult> {
  if (messages.length <= chunkSize) {
    return runRemoteCompaction(sessionId, messages);
  }
  
  // Split into chunks, compact each, then merge
  const chunks = chunkArray(messages, chunkSize);
  const results = await Promise.all(
    chunks.map(chunk => runRemoteCompaction(sessionId, chunk))
  );
  
  return mergeCompactionResults(results);
}

Fix 3: Fallback to local compaction

When remote compaction fails, fall back to local:

async function runCompactionWithFallback(
  sessionId: string,
  messages: Message[],
): Promise<CompactionResult> {
  try {
    return await runRemoteCompaction(sessionId, messages);
  } catch (error) {
    logger.warn(`Remote compaction failed, falling back to local: ${error.message}`);
    return runLocalCompaction(sessionId, messages);
  }
}

Test Plan

  1. Long context compaction: 100+ message conversation → compaction succeeds
  2. Timeout handling: Slow backend → retry succeeds
  3. Fallback: Remote compaction fails → local compaction works
  4. Chunked compaction: Very long conversation → chunked compaction produces correct summary
  5. No regression: Short conversations → normal compaction path unchanged

Impact Assessment

  • Severity: P0 — makes Codex unusable for long conversations
  • Affected users: Anyone with moderately long conversations (50%+ probability)
  • Fix complexity: Medium — timeout + retry + fallback
  • Risk: Low — defensive changes, fallback path ensures usability
yiheng8023 · 1 month ago

The same to me!

zhangyutao12 · 1 month ago

The same to me!

kuangyonglin · 1 month ago

The same to me!

pro 100USD

mickeyjoes · 1 month ago

Same here, since yesterday non-stop in all my codex sessions :/

Pro $100

CLI v0.134.0

Patrix999 · 1 month ago

same here, basically made codex unusable

etraut-openai contributor · 21 days ago

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.