Commit ecc2e22
authored
🤖 fix: avoid invalid requests from tool-only partials (#1251)
## Summary
Fixes Anthropic API validation error: `messages.X: all messages must
have non-empty content except for the optional final assistant message`
## Root Cause
Anthropic's Extended Thinking API requires thinking blocks to include a
**signature** for replay. The Vercel AI SDK silently drops reasoning
parts without `providerOptions.anthropic.signature`. When all parts of
an assistant message are unsigned reasoning, the SDK drops them all,
leaving an empty message that Anthropic rejects.
## Changes
### Core Fix
- **`stripUnsendableReasoning()`** - Removes reasoning parts without
signatures before API calls, preventing empty messages from reaching
Anthropic
### Signature Capture (for future reasoning replay)
- Add `signature` and `providerOptions` fields to `MuxReasoningPart`
- Add `signature` to `ReasoningDeltaEventSchema` for event transmission
- Capture signatures from SDK stream events (`signature_delta`)
- Store `providerOptions.anthropic.signature` for SDK compatibility
### Debug Tooling
- Add `--workspace <id>` flag to CLI for testing against existing
workspaces
## Testing
Verified against a corrupted workspace (`e8dab40a78`) with 286 empty
assistant messages that previously caused consistent API failures. After
fix:
- Empty assistant messages filtered correctly
- Unsigned reasoning stripped before API call
- Request accepted by Anthropic, streaming succeeded
---
_Generated with `mux` • Model: `anthropic:claude-opus-4-5` • Thinking:
`high`_1 parent 4e342d5 commit ecc2e22
File tree
13 files changed
+520
-30
lines changed- docs
- src
- browser
- stories
- utils/messages
- cli
- common
- orpc/schemas
- types
- node/services
- tests/ipc
13 files changed
+520
-30
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
| |||
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
72 | 79 | | |
73 | 80 | | |
74 | 81 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
151 | | - | |
| 151 | + | |
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
| |||
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
174 | | - | |
| 174 | + | |
175 | 175 | | |
176 | 176 | | |
177 | 177 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
254 | 254 | | |
255 | 255 | | |
256 | 256 | | |
257 | | - | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
258 | 269 | | |
259 | 270 | | |
260 | 271 | | |
261 | 272 | | |
262 | 273 | | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
263 | 278 | | |
264 | 279 | | |
265 | 280 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
155 | | - | |
| 155 | + | |
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
| |||
1151 | 1151 | | |
1152 | 1152 | | |
1153 | 1153 | | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
1154 | 1218 | | |
1155 | 1219 | | |
1156 | 1220 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
51 | 78 | | |
52 | 79 | | |
53 | 80 | | |
| |||
463 | 490 | | |
464 | 491 | | |
465 | 492 | | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
466 | 549 | | |
467 | 550 | | |
468 | 551 | | |
| |||
512 | 595 | | |
513 | 596 | | |
514 | 597 | | |
515 | | - | |
516 | 598 | | |
517 | 599 | | |
518 | 600 | | |
| |||
610 | 692 | | |
611 | 693 | | |
612 | 694 | | |
613 | | - | |
| 695 | + | |
| 696 | + | |
614 | 697 | | |
615 | | - | |
| 698 | + | |
616 | 699 | | |
617 | 700 | | |
618 | 701 | | |
| |||
641 | 724 | | |
642 | 725 | | |
643 | 726 | | |
644 | | - | |
| 727 | + | |
645 | 728 | | |
646 | 729 | | |
647 | 730 | | |
| |||
658 | 741 | | |
659 | 742 | | |
660 | 743 | | |
661 | | - | |
| 744 | + | |
662 | 745 | | |
663 | 746 | | |
664 | 747 | | |
| |||
703 | 786 | | |
704 | 787 | | |
705 | 788 | | |
706 | | - | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
707 | 792 | | |
708 | 793 | | |
709 | 794 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
| 198 | + | |
198 | 199 | | |
199 | 200 | | |
200 | 201 | | |
| |||
227 | 228 | | |
228 | 229 | | |
229 | 230 | | |
| 231 | + | |
230 | 232 | | |
231 | 233 | | |
232 | 234 | | |
| |||
250 | 252 | | |
251 | 253 | | |
252 | 254 | | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | 255 | | |
258 | 256 | | |
259 | 257 | | |
| |||
266 | 264 | | |
267 | 265 | | |
268 | 266 | | |
269 | | - | |
| 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 | + | |
270 | 296 | | |
271 | 297 | | |
272 | 298 | | |
| |||
333 | 359 | | |
334 | 360 | | |
335 | 361 | | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
341 | 373 | | |
342 | 374 | | |
343 | 375 | | |
| |||
0 commit comments