{"record":{"id":"7797a88beb4040a2","repo":"openclaw/openclaw","slug":"codex-settled-turn-projection-found-oversized-la","errorCode":null,"errorMessage":"Codex settled-turn projection found oversized ${label}","messagePattern":"Codex settled-turn projection found oversized (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"extensions/codex/src/app-server/settled-turn-projection.ts","lineNumber":34,"sourceCode":"  calls: ProjectedToolReference[];\n  results: ProjectedToolReference[];\n  bytes: number;\n};\n\nfunction readNonEmptyString(value: unknown): string | undefined {\n  return typeof value === \"string\" ? value.trim() || undefined : undefined;\n}\n\nfunction readBoundedText(\n  value: unknown,\n  label: string,\n  maxBytes = MAX_TEXT_BYTES,\n): string | undefined {\n  if (typeof value !== \"string\" || !value.trim()) {\n    return undefined;\n  }\n  if (Buffer.byteLength(value, \"utf8\") > maxBytes) {\n    throw new Error(`Codex settled-turn projection found oversized ${label}`);\n  }\n  return value;\n}\n\nfunction requireBoundedText(value: unknown, label: string, maxBytes = MAX_TEXT_BYTES): string {\n  const text = readBoundedText(value, label, maxBytes);\n  if (!text) {\n    throw new Error(`Codex settled-turn projection found empty ${label}`);\n  }\n  return text;\n}\n\nfunction responseItemBytes(item: JsonValue): number {\n  return Buffer.byteLength(JSON.stringify(item), \"utf8\");\n}\n\nfunction requireCallId(value: unknown): string {\n  const callId = readNonEmptyString(value);","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/openclaw/openclaw/blob/01804a75319da4b69c9ab98ceaa30477e22b8c0b/extensions/codex/src/app-server/settled-turn-projection.ts#L16-L52","documentation":"Thrown by readBoundedText when a text field in the projected transcript exceeds MAX_TEXT_BYTES (64 KiB). The projection caps every individual text field so a single oversized user/assistant/tool string cannot blow the bounded turn's history payload.","triggerScenarios":"Projecting a user message, assistant text, or tool result whose text field is over 64 KiB; a tool result that dumped a large log/fixture into its text content; an upstream user message that inlined a huge base64 or log blob as text.","commonSituations":"Tool that returns a full file or log dump as text; a channel that forwards an oversized attachment body as a text part; a model that produced a very long assistant turn before compaction.","solutions":["Identify which label (user text, assistant text, tool result text, tool arguments, tool result output) tripped the cap — it is interpolated into the message.","Truncate or summarize the offending payload at its producer (the tool or channel adapter) before it reaches the transcript.","If a larger cap is genuinely needed, raise MAX_TEXT_BYTES deliberately and re-check MAX_PROJECTION_BYTES budgeting."],"exampleFix":"// before: tool returns a 200 KiB log dump\nconst text = fs.readFileSync(hugeLog).toString();\n\n// after: cap at the producer\nconst MAX = 60 * 1024;\nconst text = fs.readFileSync(hugeLog, { encoding: \"utf8\" }).slice(0, MAX);","handlingStrategy":"validation","validationCode":"const MAX_TEXT_BYTES = 64 * 1024;\n\nfunction fitsTextByteLimit(value: unknown): boolean {\n  return typeof value === \"string\" && Buffer.byteLength(value, \"utf8\") <= MAX_TEXT_BYTES;\n}\n\n// before projection, truncate oversized producers\nif (!fitsTextByteLimit(textField)) textField = textField.slice(0, MAX_TEXT_BYTES / 2);","typeGuard":"function isBoundedText(value: unknown, maxBytes = 64 * 1024): value is string {\n  return typeof value === \"string\" && Buffer.byteLength(value, \"utf8\") <= maxBytes;\n}","tryCatchPattern":null,"preventionTips":["Cap tool/channel text output at the producer so the projection never sees >64 KiB strings.","Treat MAX_TEXT_BYTES and MAX_PROJECTION_BYTES as a shared budget when raising either.","Log byte sizes of tool results during heavy-output scenarios to catch growth early."],"tags":["codex","settled-turn","projection","size-limit","validation"],"backgroundTag":null,"analyzedSha":"01804a75319da4b69c9ab98ceaa30477e22b8c0b","analyzedAt":"2026-08-12T04:37:58.197Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}