+- **In-loop phase-1 compaction.** A long tool chain (file dumps, verbose bash) used to push token usage past the trigger ratio mid-loop with no relief until the user ran `/compact` manually. The agent loop now checks `needs_compaction()` between tool round-trips and, if the split point is non-zero, truncates large tool-result payloads in older messages before the next API call. Phase 1 is purely local and history-preserving — every message stays in place, only big tool-result bodies shrink — so the model still sees the full conversation flow without an extra LLM call per iteration. Phase 2 (LLM summarization) is still gated behind explicit `/compact`.
0 commit comments