fix(agent): protect bootstrap prefix from pruning

This commit is contained in:
Max Sumrall
2026-01-07 18:15:54 +01:00
committed by Peter Steinberger
parent bf00b733c9
commit 5ddf9b2c65
3 changed files with 54 additions and 2 deletions

View File

@@ -837,6 +837,7 @@ This is intended to reduce token usage for chatty agents that accumulate large t
High level:
- Never touches user/assistant messages.
- Protects the last `keepLastAssistants` assistant messages (no tool results after that point are pruned).
- Protects the bootstrap prefix (nothing before the first user message is pruned).
- Modes:
- `adaptive`: soft-trims oversized tool results (keep head/tail) when the estimated context ratio crosses `softTrimRatio`.
Then hard-clears the oldest eligible tool results when the estimated context ratio crosses `hardClearRatio` **and**