Commit 45665f7
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 eb42193 commit 45665f7
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 | |
|---|---|---|---|
| |||
837 | 837 | | |
838 | 838 | | |
839 | 839 | | |
840 | | - | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
841 | 846 | | |
842 | 847 | | |
843 | 848 | | |
| |||
859 | 864 | | |
860 | 865 | | |
861 | 866 | | |
862 | | - | |
| 867 | + | |
863 | 868 | | |
864 | 869 | | |
865 | 870 | | |
| |||
897 | 902 | | |
898 | 903 | | |
899 | 904 | | |
900 | | - | |
| 905 | + | |
901 | 906 | | |
902 | 907 | | |
903 | 908 | | |
| |||
910 | 915 | | |
911 | 916 | | |
912 | 917 | | |
913 | | - | |
| 918 | + | |
914 | 919 | | |
915 | 920 | | |
916 | 921 | | |
| |||
920 | 925 | | |
921 | 926 | | |
922 | 927 | | |
923 | | - | |
| 928 | + | |
924 | 929 | | |
925 | 930 | | |
926 | 931 | | |
| |||
934 | 939 | | |
935 | 940 | | |
936 | 941 | | |
937 | | - | |
| 942 | + | |
938 | 943 | | |
939 | 944 | | |
940 | 945 | | |
941 | 946 | | |
942 | 947 | | |
943 | 948 | | |
944 | | - | |
| 949 | + | |
945 | 950 | | |
946 | 951 | | |
947 | 952 | | |
| |||
| 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