Commit 8cf0b72
committed
fix(transform): preserve thinking-block integrity on Opus 4.7
Two related fixes for Anthropic's stricter thinking-block validation
that landed with Claude Opus 4.7. The same long-history session that
worked fine on Opus 4.6 was rejected by 4.7 with:
'thinking or redacted_thinking blocks in the latest assistant
message cannot be modified. These blocks must remain as they were
in the original response.'
1. Preserve dropped user-message shells. Removing a user message
collapses turn boundaries so @ai-sdk/anthropic merges adjacent
assistants into one Anthropic assistant block, which invalidates
the signed thinking history inside. Dropped user content is now
replaced with a [truncated §N§] preview (keeping the shell) rather
than removing the message.
2. Workaround @ai-sdk/anthropic's groupIntoBlocks producing
interleaved [thinking, text, thinking, text, ...] layouts when
multiple consecutive OpenCode assistants each carry signed
reasoning. The new stripReasoningFromMergedAssistants pass strips
reasoning from all but the first assistant in each consecutive run
so the merged block keeps thinking at position 0. Upstream bug
tracked for removal when @ai-sdk/anthropic is fixed (same class as
Bedrock #13583/#13585/#13972).
Also:
- nudge-injection no longer targets thinking-bearing assistants; file
parts are no longer treated as metadata-only content.
- Mock-provider now streams thinking_delta + signature_delta and
advertises image/PDF modalities so the new e2e suite can exercise
the live OpenCode + Anthropic-wire regressions end-to-end.1 parent aa536b2 commit 8cf0b72
10 files changed
Lines changed: 1200 additions & 14 deletions
File tree
- packages
- e2e-tests
- src
- mock-provider
- opencode-runner
- tests
- plugin/src/hooks/magic-context
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
235 | 235 | | |
236 | 236 | | |
237 | 237 | | |
238 | | - | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
239 | 245 | | |
240 | 246 | | |
241 | 247 | | |
| |||
253 | 259 | | |
254 | 260 | | |
255 | 261 | | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
256 | 313 | | |
257 | | - | |
| 314 | + | |
258 | 315 | | |
259 | 316 | | |
260 | 317 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
115 | 123 | | |
116 | 124 | | |
117 | 125 | | |
| |||
0 commit comments