keepTokenBudget returns the verbatim-keep budget for a compaction, scaled to the context window so that the kept tail plus the summary always leave the post-compaction session well under the compaction threshold. A non-positive contextLimit (hook-supplied summaries may run without a resolvable model
(contextLimit int64)
| 72 | // run without a resolvable model definition) falls back to the |
| 73 | // unscaled policy. |
| 74 | func keepTokenBudget(contextLimit int64) int64 { |
| 75 | if contextLimit <= 0 { |
| 76 | return maxKeepTokens |
| 77 | } |
| 78 | return min(maxKeepTokens, contextLimit/5) |
| 79 | } |
| 80 | |
| 81 | // Result is the structural outcome of running a compaction strategy. |
| 82 | // The runtime applies it to the parent session by appending a |
no outgoing calls
no test coverage detected