Commit 611ebdb
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 745cc65 commit 611ebdb
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 | |
|---|---|---|---|
| |||
814 | 814 | | |
815 | 815 | | |
816 | 816 | | |
817 | | - | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
818 | 823 | | |
819 | 824 | | |
820 | 825 | | |
| |||
836 | 841 | | |
837 | 842 | | |
838 | 843 | | |
839 | | - | |
| 844 | + | |
840 | 845 | | |
841 | 846 | | |
842 | 847 | | |
| |||
874 | 879 | | |
875 | 880 | | |
876 | 881 | | |
877 | | - | |
| 882 | + | |
878 | 883 | | |
879 | 884 | | |
880 | 885 | | |
| |||
887 | 892 | | |
888 | 893 | | |
889 | 894 | | |
890 | | - | |
| 895 | + | |
891 | 896 | | |
892 | 897 | | |
893 | 898 | | |
| |||
897 | 902 | | |
898 | 903 | | |
899 | 904 | | |
900 | | - | |
| 905 | + | |
901 | 906 | | |
902 | 907 | | |
903 | 908 | | |
| |||
911 | 916 | | |
912 | 917 | | |
913 | 918 | | |
914 | | - | |
| 919 | + | |
915 | 920 | | |
916 | 921 | | |
917 | 922 | | |
918 | 923 | | |
919 | 924 | | |
920 | 925 | | |
921 | | - | |
| 926 | + | |
922 | 927 | | |
923 | 928 | | |
924 | 929 | | |
| |||
| 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 | |
|---|---|---|---|
| |||
457 | 457 | | |
458 | 458 | | |
459 | 459 | | |
460 | | - | |
461 | | - | |
462 | | - | |
463 | | - | |
464 | | - | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
465 | 464 | | |
466 | | - | |
467 | | - | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
468 | 468 | | |
469 | 469 | | |
470 | 470 | | |
471 | 471 | | |
472 | 472 | | |
473 | | - | |
| 473 | + | |
474 | 474 | | |
475 | 475 | | |
476 | 476 | | |
| |||
496 | 496 | | |
497 | 497 | | |
498 | 498 | | |
499 | | - | |
| 499 | + | |
500 | 500 | | |
501 | 501 | | |
502 | 502 | | |
| |||
516 | 516 | | |
517 | 517 | | |
518 | 518 | | |
519 | | - | |
| 519 | + | |
520 | 520 | | |
521 | 521 | | |
522 | 522 | | |
523 | 523 | | |
524 | 524 | | |
525 | 525 | | |
526 | 526 | | |
527 | | - | |
| 527 | + | |
528 | 528 | | |
529 | 529 | | |
530 | 530 | | |
| |||
0 commit comments