Commit c8af25d
committed
fix: preserve thinking block signatures and fix compaction headroom asymmetry
Two compounding bugs caused sessions to crash with 'thinking blocks cannot
be modified' when compaction fired for models with extended thinking:
1. toModelMessages() stripped providerMetadata (including cryptographic
signatures) from message parts when the current model differed from the
original. Anthropic's API requires signatures to be byte-identical.
Fix: always pass providerMetadata through — the API handles filtering.
2. isOverflow() used an asymmetric buffer when limit.input was set
(capped at 20K via COMPACTION_BUFFER) vs the full maxOutputTokens on
the non-input path. This caused compaction to trigger too late.
Fix: use maxOutputTokens (capped at 32K) for both paths. Also fixed
the non-input path to respect config.compaction.reserved.1 parent 92c0058 commit c8af25d
4 files changed
Lines changed: 245 additions & 27 deletions
File tree
- packages/opencode
- src/session
- test/session
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
688 | 688 | | |
689 | 689 | | |
690 | 690 | | |
691 | | - | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
692 | 697 | | |
693 | 698 | | |
694 | 699 | | |
| |||
710 | 715 | | |
711 | 716 | | |
712 | 717 | | |
713 | | - | |
| 718 | + | |
714 | 719 | | |
715 | 720 | | |
716 | 721 | | |
| |||
746 | 751 | | |
747 | 752 | | |
748 | 753 | | |
749 | | - | |
| 754 | + | |
750 | 755 | | |
751 | 756 | | |
752 | 757 | | |
| |||
759 | 764 | | |
760 | 765 | | |
761 | 766 | | |
762 | | - | |
| 767 | + | |
763 | 768 | | |
764 | 769 | | |
765 | 770 | | |
| |||
769 | 774 | | |
770 | 775 | | |
771 | 776 | | |
772 | | - | |
| 777 | + | |
773 | 778 | | |
774 | 779 | | |
775 | 780 | | |
| |||
783 | 788 | | |
784 | 789 | | |
785 | 790 | | |
786 | | - | |
| 791 | + | |
787 | 792 | | |
788 | 793 | | |
789 | 794 | | |
790 | 795 | | |
791 | 796 | | |
792 | 797 | | |
793 | | - | |
| 798 | + | |
794 | 799 | | |
795 | 800 | | |
796 | 801 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
8 | 6 | | |
9 | 7 | | |
10 | 8 | | |
11 | 9 | | |
12 | | - | |
13 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | | - | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
418 | 418 | | |
419 | 419 | | |
420 | 420 | | |
421 | | - | |
422 | | - | |
423 | | - | |
424 | | - | |
425 | | - | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
426 | 425 | | |
427 | | - | |
428 | | - | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
429 | 429 | | |
430 | 430 | | |
431 | 431 | | |
432 | 432 | | |
433 | 433 | | |
434 | | - | |
| 434 | + | |
435 | 435 | | |
436 | 436 | | |
437 | 437 | | |
| |||
457 | 457 | | |
458 | 458 | | |
459 | 459 | | |
460 | | - | |
| 460 | + | |
461 | 461 | | |
462 | 462 | | |
463 | 463 | | |
| |||
477 | 477 | | |
478 | 478 | | |
479 | 479 | | |
480 | | - | |
| 480 | + | |
481 | 481 | | |
482 | 482 | | |
483 | 483 | | |
484 | 484 | | |
485 | 485 | | |
486 | 486 | | |
487 | 487 | | |
488 | | - | |
| 488 | + | |
489 | 489 | | |
490 | 490 | | |
491 | 491 | | |
| |||
0 commit comments