Commit 07ba2f7
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 88c5f6b commit 07ba2f7
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 | |
|---|---|---|---|
| |||
808 | 808 | | |
809 | 809 | | |
810 | 810 | | |
811 | | - | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
812 | 817 | | |
813 | 818 | | |
814 | 819 | | |
| |||
830 | 835 | | |
831 | 836 | | |
832 | 837 | | |
833 | | - | |
| 838 | + | |
834 | 839 | | |
835 | 840 | | |
836 | 841 | | |
| |||
866 | 871 | | |
867 | 872 | | |
868 | 873 | | |
869 | | - | |
| 874 | + | |
870 | 875 | | |
871 | 876 | | |
872 | 877 | | |
| |||
879 | 884 | | |
880 | 885 | | |
881 | 886 | | |
882 | | - | |
| 887 | + | |
883 | 888 | | |
884 | 889 | | |
885 | 890 | | |
| |||
889 | 894 | | |
890 | 895 | | |
891 | 896 | | |
892 | | - | |
| 897 | + | |
893 | 898 | | |
894 | 899 | | |
895 | 900 | | |
| |||
903 | 908 | | |
904 | 909 | | |
905 | 910 | | |
906 | | - | |
| 911 | + | |
907 | 912 | | |
908 | 913 | | |
909 | 914 | | |
910 | 915 | | |
911 | 916 | | |
912 | 917 | | |
913 | | - | |
| 918 | + | |
914 | 919 | | |
915 | 920 | | |
916 | 921 | | |
| |||
| 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