Commit 7e20991
committed
fix(memory-flush): fallback to estimatePromptTokensFromSessionTranscript when usage data is unavailable
When a model provider (e.g., MiniMax) does not return usage data
in its API response, the session entry's totalTokens stays undefined.
The preflight compaction path already handles this via
estimatePromptTokensFromSessionTranscript, but the memory-flush
path did not have the same fallback. This caused entry.totalTokens
to remain undefined across compactions, preventing the system from
recognizing context reductions and triggering redundant compactions.
This change adds the same fallback from the preflight path into the
memory-flush path, ensuring entry.totalTokens is populated even when
the model does not provide usage data.1 parent 800a0d3 commit 7e20991
1 file changed
Lines changed: 18 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
870 | 870 | | |
871 | 871 | | |
872 | 872 | | |
873 | | - | |
874 | | - | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
875 | 891 | | |
876 | 892 | | |
877 | 893 | | |
| |||
0 commit comments