{"record":{"id":"894d0eb2501e44d4","repo":"openclaw/openclaw","slug":"bedrock-redacted-reasoning-block-is-missing-its-op","errorCode":null,"errorMessage":"Bedrock redacted reasoning block is missing its opaque signature","messagePattern":"Bedrock redacted reasoning block is missing its opaque signature","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"extensions/amazon-bedrock/stream.runtime.ts","lineNumber":976,"sourceCode":"              if (c.text.trim().length === 0) {\n                continue;\n              }\n              contentBlocks.push({ text: sanitizeSurrogates(c.text) });\n              break;\n            case \"toolCall\":\n              contentBlocks.push({\n                toolUse: { toolUseId: c.id, name: c.name, input: c.arguments as DocumentType },\n              });\n              break;\n            case \"thinking\": {\n              if (c.redacted) {\n                // transformMessages already strips opaque reasoning after a model\n                // switch; this also rejects routes that cannot consume the format.\n                if (!supportsThinkingSignature(model)) {\n                  continue;\n                }\n                if (!c.thinkingSignature) {\n                  throw new Error(\n                    \"Bedrock redacted reasoning block is missing its opaque signature\",\n                  );\n                }\n                contentBlocks.push({\n                  reasoningContent: {\n                    redactedContent: decodeBedrockBase64(\n                      c.thinkingSignature,\n                      \"Bedrock redacted reasoning block has a malformed opaque signature\",\n                    ),\n                  },\n                });\n                break;\n              }\n              const thinkingSignature = c.thinkingSignature;\n              const normalizedThinkingSignature = thinkingSignature?.trim();\n              const supportsSignature = supportsThinkingSignature(model);\n              const hasNativeThinkingSignature =\n                supportsSignature &&","sourceCodeStart":958,"sourceCodeEnd":994,"githubUrl":"https://github.com/openclaw/openclaw/blob/01804a75319da4b69c9ab98ceaa30477e22b8c0b/extensions/amazon-bedrock/stream.runtime.ts#L958-L994","documentation":"Thrown during message conversion (convertMessages) when an assistant message contains a redacted 'thinking' block (c.redacted === true), the model supports thinking signatures (supportsThinkingSignature(model)), but c.thinkingSignature is missing. Bedrock requires the opaque signature to replay redacted reasoning content; without it, the block cannot be reconstructed and the error protects against sending invalid content.","triggerScenarios":"Replaying a conversation history that includes a redacted reasoning block where the thinkingSignature field was not persisted or was stripped. The convertMessages path at stream.runtime.ts:968 hits the redacted branch, confirms the model supports signatures, and finds c.thinkingSignature falsy.","commonSituations":"Conversation history was persisted without the thinkingSignature (older format, partial save, or external tool that dropped it); a message was replayed after a format migration; or a redacted block was constructed manually without the signature. The guard prevents sending malformed reasoning content to Bedrock.","solutions":["Drop the redacted thinking block before sending (it cannot be replayed without its signature).","Persist thinkingSignature alongside redacted reasoning content so replays are valid.","If the history is from an external source, filter out thinking blocks missing signatures before conversion.","Use a non-redacted thinking representation if signature persistence is unreliable."],"exampleFix":"// before: history missing thinkingSignature triggers the throw\nmessages.push({ role: \"assistant\", content: [{ type: \"thinking\", redacted: true }] });\n\n// after: drop blocks missing signatures before sending\nconst safeContent = msg.content.filter(\n  (c) => !(c.type === \"thinking\" && c.redacted && !c.thinkingSignature)\n);","handlingStrategy":"validation","validationCode":"// Strip redacted thinking blocks that lack a signature before sending\nfunction sanitizeThinkingBlocks(messages: any[]): any[] {\n  return messages.map((m) => ({\n    ...m,\n    content: (m.content || []).filter(\n      (c: any) => !(c.type === \"thinking\" && c.redacted && !c.thinkingSignature)\n    ),\n  }));\n}","typeGuard":"function hasValidRedactedSignature(block: { type?: string; redacted?: boolean; thinkingSignature?: unknown }): boolean {\n  if (block.type !== \"thinking\" || !block.redacted) return true;\n  return typeof block.thinkingSignature === \"string\" && block.thinkingSignature.length > 0;\n}","tryCatchPattern":null,"preventionTips":["Persist thinkingSignature alongside redacted reasoning content in conversation history.","Filter out thinking blocks missing signatures before replaying history.","Avoid manually constructing redacted thinking blocks without the signature field."],"tags":["bedrock","reasoning","thinking","signature","message-conversion"],"backgroundTag":null,"analyzedSha":"01804a75319da4b69c9ab98ceaa30477e22b8c0b","analyzedAt":"2026-08-12T04:37:58.197Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}