Repository navigation
Add compaction-time micro-compaction policy (AgentSpec.microcompact, default off) - #279
raymondginger2018-sudo wants to merge 1 commit into
Conversation
|
Thanks @raymondginger2018-sudo for a well-structured PR. The off-by-default guard is careful: with it off, the runtime behaves exactly as before (the compaction and runner tests are unchanged, and the full suite passes). We can't merge it as is, though:
A version we'd accept: fixes 2-4 (never clear the latest tool batch, keep the saved-output path line); drops or properly wires the idle trigger; adds a user-facing switch; and adds integration tests through |
Add a cheap first rung to the compaction ladder: before the summarizer is considered, old tool results (all but the most recent N and the entire latest tool batch) are replaced by a placeholder. The runner owns the decision — the pressure gate has already fired on the provider's real token count, so the pass makes no second estimate. - Keep the whole latest tool batch (the one the model has not read yet), not just a count-based recency window, so more than N parallel calls can no longer be cleared before the model reads them. - Preserve a spilled result's "Full output saved to:" pointer so the model can still find the output on disk. - Drop the idle trigger and the internal pressure re-check; the runner decides. - Expose a user-facing switch (agents.defaults.microcompact), off by default so existing runs are unchanged. Tests cover the clear policy directly plus integration through AgentRunner._maybe_compact: one showing the summarizer is skipped and tool-call pairs stay intact, one showing the history is unchanged when it is off.
4a91806 to
85c71f8
Compare
|
Thanks @Zongwei9888 — all of this is addressed in the force-pushed revision (now rebased onto the latest
Fixed — there's now a user-facing switch.
Rather than passing
Fixed — the pass now protects the entire latest tool batch, not just a count. It scans for the most recent assistant message with
Fixed — when a stale result is cleared, the pass preserves the
Fixed by dropping it. The idle trigger (and On the acceptance list:
Local verification: Happy to adjust anything further. |
Summary
Adds a cheap first rung to the compaction ladder: before the summarizer is ever considered, a model-free pass replaces stale tool-result contents with a placeholder. Borrowed from ZCode's
applyMicrocompactPolicy, adapted to this runtime's message model.Armed only via
AgentSpec.microcompact— the defaultNonekeeps existing runs byte-for-byte unchanged.Changes
core/agent_runtime/microcompact.py: keep-recency policy with dual triggers (token pressure at 0.9x context budget OR idle timeout), pair integrity (thetool_call_idis preserved while content becomes"[Old tool result content cleared]"), media blocks pass through untouched, copy-on-write over the message list, and a min-savings convergence floor so an ineffective clear never loops.core/agent_runtime/runner.py: wire the pass intocompact_historywhen a policy is armed; after a clear, recompute the prompt estimate and return early once pressure is resolved.tests/test_microcompact.py(12 tests: triggers, recency window, pair integrity, media pass-through, copy-on-write, convergence).Tests
tests/test_microcompact.py— 12 passedpre-commit run --all-files(ruff 0.15.21 check + format) — passedNotes