Commit 64bb2b3
authored
Fix whitespace-only text block from orphaned CacheBreakpoint (#4839)
When a CacheBreakpoint had no preceding content block to attach
cache_control to, rawContentToAnthropicContent created a placeholder
{ type: 'text', text: ' ' } block. The Anthropic API rejects
whitespace-only text blocks with 'text content block must contain
non-whitespace text'.
This happens in long conversations after prompt-tsx prunes content to
fit the token budget, leaving a CacheBreakpoint with no real content
before it.
Fix: defer the cache_control to the next cacheable content block. If
no subsequent block exists, silently drop it (nothing to cache anyway).
Fixes microsoft/vscode#3059561 parent 00df316 commit 64bb2b3
2 files changed
Lines changed: 42 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
381 | 381 | | |
382 | 382 | | |
383 | 383 | | |
| 384 | + | |
| 385 | + | |
384 | 386 | | |
385 | 387 | | |
386 | 388 | | |
| |||
419 | 421 | | |
420 | 422 | | |
421 | 423 | | |
422 | | - | |
423 | | - | |
424 | | - | |
425 | | - | |
426 | | - | |
427 | | - | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
428 | 430 | | |
429 | 431 | | |
430 | 432 | | |
| |||
467 | 469 | | |
468 | 470 | | |
469 | 471 | | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
470 | 481 | | |
471 | 482 | | |
472 | 483 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
370 | 370 | | |
371 | 371 | | |
372 | 372 | | |
373 | | - | |
374 | | - | |
| 373 | + | |
| 374 | + | |
375 | 375 | | |
376 | 376 | | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
377 | 400 | | |
378 | 401 | | |
379 | 402 | | |
| |||
0 commit comments