openclaw/openclaw · error · Error

Codex remote workspace artifact exceeds the limit of ${remai

Error message

Codex remote workspace artifact exceeds the limit of ${remainingBytes} bytes.

What it means

Thrown by prepareCodexRemoteWorkspaceMessageMedia when the base64 string length of a file response exceeds ceil(remainingBytes / 3) * 4, meaning the file data is larger than the remaining byte budget (maxBytes minus bytes already transferred in the batch).

Source

Thrown at extensions/codex/src/app-server/remote-workspace-media.ts:351

  for (const [localPath, remotePath] of remotePathsByLocalPath) {
    params.signal?.throwIfAborted();
    const remainingBytes = maxBytes - totalBytes;
    const remainingMs = deadline - Date.now();
    if (remainingMs <= 0) {
      throw new Error("Codex remote workspace attachment batch timed out.");
    }
    const response = await readRemoteFile({
      path: remotePath,
      maxBytes: remainingBytes,
      workspaceRoot: remoteWorkspaceRoot,
      signal: params.signal,
      timeoutMs: remainingMs,
    });
    if (!response || typeof response.dataBase64 !== "string") {
      throw new Error(`Codex remote workspace artifact returned no file data: ${remotePath}`);
    }
    if (response.dataBase64.length > Math.ceil(remainingBytes / 3) * 4) {
      throw new Error(
        `Codex remote workspace artifact exceeds the limit of ${remainingBytes} bytes.`,
      );
    }
    const remoteBuffer = Buffer.from(response.dataBase64, "base64");
    if (
      remoteBuffer.byteLength > remainingBytes ||
      remoteBuffer.toString("base64") !== response.dataBase64
    ) {
      throw new Error(
        `Codex remote workspace artifact returned invalid or oversized file data: ${remotePath}`,
      );
    }
    totalBytes += remoteBuffer.byteLength;
    const saved = await saveMediaBuffer(
      remoteBuffer,
      undefined,
      "outbound",
      maxBytes,

View on GitHub (pinned to 01804a7531)

Solutions

  1. Reduce the total size of attachments in the batch to fit within maxBytes.
  2. Split large batches across multiple prepareCodexRemoteWorkspaceMessageMedia calls.
  3. Pass a larger maxBytes if the caller supports it.
  4. Prioritize smaller files first to avoid partial batch failures on large files.
Defensive patterns

Strategy: validation

Validate before calling

const MAX_BYTES = 64 * 1024 * 1024;
let totalSize = 0;
for (const [, remotePath] of remotePathsByLocalPath) {
  const stat = await statRemoteFile(remotePath);
  totalSize += stat.size;
}
if (totalSize > MAX_BYTES) {
  throw new Error(`Total attachment size (${totalSize} bytes) exceeds limit (${MAX_BYTES} bytes).`);
}

Prevention

When it happens

Trigger: The cumulative transferred bytes plus the current file exceed maxBytes (default 64 MiB). The remainingBytes budget shrinks with each file in the batch; a large file late in the batch can exhaust it.

Common situations: Many files in a single batch whose total exceeds 64 MiB; one unexpectedly large file; earlier attachments consumed most of the budget; a custom maxBytes was set too low.

Related errors


AI-assisted analysis of openclaw/openclaw@01804a7531 (2026-08-12). Data as JSON: /api/errors/13857ab2ea4c647e. Report an issue: GitHub.