{"record":{"id":"13857ab2ea4c647e","repo":"openclaw/openclaw","slug":"codex-remote-workspace-artifact-exceeds-the-limit","errorCode":null,"errorMessage":"Codex remote workspace artifact exceeds the limit of ${remainingBytes} bytes.","messagePattern":"Codex remote workspace artifact exceeds the limit of (.+?) bytes\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"extensions/codex/src/app-server/remote-workspace-media.ts","lineNumber":351,"sourceCode":"  for (const [localPath, remotePath] of remotePathsByLocalPath) {\n    params.signal?.throwIfAborted();\n    const remainingBytes = maxBytes - totalBytes;\n    const remainingMs = deadline - Date.now();\n    if (remainingMs <= 0) {\n      throw new Error(\"Codex remote workspace attachment batch timed out.\");\n    }\n    const response = await readRemoteFile({\n      path: remotePath,\n      maxBytes: remainingBytes,\n      workspaceRoot: remoteWorkspaceRoot,\n      signal: params.signal,\n      timeoutMs: remainingMs,\n    });\n    if (!response || typeof response.dataBase64 !== \"string\") {\n      throw new Error(`Codex remote workspace artifact returned no file data: ${remotePath}`);\n    }\n    if (response.dataBase64.length > Math.ceil(remainingBytes / 3) * 4) {\n      throw new Error(\n        `Codex remote workspace artifact exceeds the limit of ${remainingBytes} bytes.`,\n      );\n    }\n    const remoteBuffer = Buffer.from(response.dataBase64, \"base64\");\n    if (\n      remoteBuffer.byteLength > remainingBytes ||\n      remoteBuffer.toString(\"base64\") !== response.dataBase64\n    ) {\n      throw new Error(\n        `Codex remote workspace artifact returned invalid or oversized file data: ${remotePath}`,\n      );\n    }\n    totalBytes += remoteBuffer.byteLength;\n    const saved = await saveMediaBuffer(\n      remoteBuffer,\n      undefined,\n      \"outbound\",\n      maxBytes,","sourceCodeStart":333,"sourceCodeEnd":369,"githubUrl":"https://github.com/openclaw/openclaw/blob/01804a75319da4b69c9ab98ceaa30477e22b8c0b/extensions/codex/src/app-server/remote-workspace-media.ts#L333-L369","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","solutions":["Reduce the total size of attachments in the batch to fit within maxBytes.","Split large batches across multiple prepareCodexRemoteWorkspaceMessageMedia calls.","Pass a larger maxBytes if the caller supports it.","Prioritize smaller files first to avoid partial batch failures on large files."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const MAX_BYTES = 64 * 1024 * 1024;\nlet totalSize = 0;\nfor (const [, remotePath] of remotePathsByLocalPath) {\n  const stat = await statRemoteFile(remotePath);\n  totalSize += stat.size;\n}\nif (totalSize > MAX_BYTES) {\n  throw new Error(`Total attachment size (${totalSize} bytes) exceeds limit (${MAX_BYTES} bytes).`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Estimate total attachment size before initiating the batch.","Split large batches to keep cumulative size within maxBytes.","Pass a larger maxBytes if the caller supports it.","Prioritize smaller files first to fail early on budget exhaustion."],"tags":["codex","remote-workspace","media-transfer","limits"],"backgroundTag":null,"analyzedSha":"01804a75319da4b69c9ab98ceaa30477e22b8c0b","analyzedAt":"2026-08-12T04:37:58.197Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}