You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 39bbe0b
Browse filesBrowse the repository at this point in the historyBrowse files
When using Claude models with extended thinking, the API returns `thinking`/`redacted_thinking` blocks. When OpenCode replays these back (on next message or compaction), if they're modified during storage/retrieval, Claude rejects them:
@@ -11,34 +11,93 @@ messages.3.content.1: `thinking` or `redacted_thinking` blocks in the latest ass
11
11
12
12
Session becomes stuck ā even compaction triggers the same error.
13
13
14
-
## Root Cause (verified via PR #14393)
15
-
1.**Bug 1:**`toModelMessages()` strips `providerMetadata` (including Bedrock thinking signatures) when `differentModel` is true ā which always happens during compaction due to model ID format mismatch.
16
-
2.**Bug 2:** Asymmetric compaction buffer (20K vs 32K) causes compaction to trigger too late for some models.
17
-
18
-
## Solution: Root Fix + Configurable Strategy
19
-
20
-
### Root Fix (from PR #14393)
21
-
- Always pass `providerMetadata` for reasoning parts and `callProviderMetadata` for tool parts (removed `differentModel` guard)
22
-
- Symmetric compaction buffer using `maxOutputTokens()` consistently
23
-
24
-
### Configurable Thinking Strategy
25
-
Three options available in Settings and Context tab:
26
-
-**"none" (default):** Original behavior ā send thinking blocks as-is. With the root fix, signatures are now preserved correctly.
27
-
-**"strip":** Proactively remove thinking from last assistant message before sending. Prevents errors but loses thinking context.
28
-
-**"compact":** Preserve thinking but auto-compact on error. First message may fail, then auto-recovers.
`MessageV2.toModelMessages()` stores reasoning parts as `{type: "reasoning", text: part.text}` but the original API response had `{type: "thinking", thinking: "..."}`. The reconstruction is not byte-identical. Claude's constraint only applies to the LAST assistant message.
16
+
17
+
## Approach: Strip reasoning from last assistant message (user-controlled)
0 commit comments