Commit 6af2b88
committed
Fix uncalibrated overflow and trailing-message prefill error
- gradient: on first turn (no calibration data), apply a 1.5x safety
multiplier to tryFit output before accepting a layer. chars/4 estimates
undercount by up to 1.8x on sessions with large tool outputs, causing
tryFit to pack too many messages — the window estimates as fitting but
actually overflows the API limit. With the multiplier, the gradient
escalates to the next layer until the estimated total * 1.5 fits within
maxInput. Once calibrated (exact API counts available), the multiplier
is not applied.
- index: remove the 'break on tool parts' from the trailing-message drop
loop. The break left trailing assistant messages with tool parts at the
end of the compressed window, causing 'conversation must end with a user
message' prefill errors. Always drop trailing non-user messages
regardless of tool content — a hard API error is worse than the model
re-invoking a tool.1 parent 2438a07 commit 6af2b88
3 files changed
+29
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
722 | 722 | | |
723 | 723 | | |
724 | 724 | | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
725 | 744 | | |
726 | | - | |
| 745 | + | |
727 | 746 | | |
728 | 747 | | |
729 | 748 | | |
| |||
793 | 812 | | |
794 | 813 | | |
795 | 814 | | |
796 | | - | |
| 815 | + | |
797 | 816 | | |
798 | 817 | | |
799 | 818 | | |
| |||
812 | 831 | | |
813 | 832 | | |
814 | 833 | | |
815 | | - | |
| 834 | + | |
816 | 835 | | |
817 | | - | |
| 836 | + | |
818 | 837 | | |
819 | 838 | | |
820 | 839 | | |
| |||
833 | 852 | | |
834 | 853 | | |
835 | 854 | | |
836 | | - | |
| 855 | + | |
837 | 856 | | |
838 | | - | |
| 857 | + | |
839 | 858 | | |
840 | 859 | | |
841 | 860 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
389 | 389 | | |
390 | 390 | | |
391 | 391 | | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
392 | 395 | | |
393 | 396 | | |
394 | 397 | | |
395 | 398 | | |
396 | | - | |
397 | | - | |
398 | 399 | | |
399 | 400 | | |
400 | 401 | | |
| |||
0 commit comments