Files
Niko1221 1dfdb25a87 agent: judge the compaction guard by the request's fixed part, not by what lies outside the range (fixes a 991fe4fc5b regression)
991fe4fc5b skipped a pressure compaction when the tokens outside the range plus a minimal summary reached the model's limit. "Outside the range" includes the
newest messages, so a huge newest message (priced by its characters by the meter) made the guard skip the very summary that makes room for it. The real
Harness test "a chat the model server refused once is not stuck: the next message compacts ... and goes through" caught it: before 991fe4fc5b it passes (35 of
36 in agent-context + agent-context-optimizer, the one failure is another test); on 0.2.24 / main it fails with "only the first, too large, prompt was refused:
32914, 52940" (the chat stayed refused). The tests that need the real Harness are skipped without STRATA_HARNESS_DIR, which is why the full-suite run missed it.

The guard now uses what no summary can remove: the fixed part, the measured total less every conversation message (system prompt and tool list), and skips only
when that alone, plus a minimal summary, reaches the limit (a 16K window: 10.9K of instructions and tools against a 10,036 limit). The 16K case is still
guarded; the refused-once case compacts again. Verified with the real Harness of the 0.2.24 package (AppImage extracted on a rental): agent-context.test.mjs
passes with the fix. Tests: agent-compaction-limit.test.mjs, now 6, with the huge-newest-message case.
2026-12-02 13:26:22 +01:00
..