Skip to content

Commit e8d6d1c

Browse files
committed
fix(session): preserve thinking text whitespace for signature integrity
The Anthropic API computes a cryptographic signature on the exact thinking text including trailing whitespace. Calling trimEnd() invalidates the signature, causing "Invalid data in redacted_thinking block" errors when thinking blocks are replayed in subsequent API calls. Closes #10970
1 parent 449c5b4 commit e8d6d1c

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

packages/opencode/src/session/processor.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,10 @@ export namespace SessionProcessor {
8888
case "reasoning-end":
8989
if (value.id in reasoningMap) {
9090
const part = reasoningMap[value.id]
91-
part.text = part.text.trimEnd()
91+
// Do NOT trimEnd() thinking text - the signature is computed on the
92+
// exact text including trailing whitespace. Modifying it invalidates
93+
// the signature, causing "Invalid data in redacted_thinking block"
94+
// errors when the thinking is replayed in subsequent API calls.
9295

9396
part.time = {
9497
...part.time,

0 commit comments

Comments
 (0)