add proactive context-size compaction with a notes-checkpoint turn

This commit is contained in:
damocles 2026-05-20 12:38:50 +02:00 committed by Mara
parent f2015954d9
commit 9cbb05bb86
3 changed files with 152 additions and 9 deletions

View file

@ -200,6 +200,23 @@ read them à la carte.
In-flight or recent context that hasn't earned a section yet.
Prune freely.
- **Just landed:** proactive context-size compaction. `turn::
drive_turn` now has two compaction paths. The old *reactive*
one (claude prints `Prompt is too long``/compact` + retry)
is unchanged — by then the session is already past the window
and no turn can run on it. The new *proactive* one fires after
a clean turn whose last-inference context
(`Bus::last_ctx_usage().context_tokens()`) crossed a watermark:
`drive_turn` injects one synthetic notes-checkpoint turn
(`CHECKPOINT_PROMPT` — "flush durable state into /state now")
then runs `/compact`, so the agent can persist in-flight state
before the detail collapses into a summary. Watermark is
`HIVE_COMPACT_WATERMARK_TOKENS` (default 150k, ~75% of a 200k
window; `0` disables). New `maybe_checkpoint_and_compact`
helper, all best-effort (a failed checkpoint/compact is a Note,
never fails the turn). Both ag3nt + m1nd loops get it for free
via the shared `drive_turn`. `docs/turn-loop.md` gained a
Compaction section.
- **Just landed:** dashboard side panel + forge-linked
config/approvals + per-bucket model stats. (a) Long content
(file previews, approval diffs, journald logs) opens in a
@ -608,8 +625,8 @@ Prune freely.
agent_web_port + collision banner + spawn/rebuild preflight,
browser notifications, focus-preserving refresh, generalised
<details data-restore-key> survival, prompt-on-submit pattern.
- **Open threads:** two-step spawn, notes compaction,
unprivileged containers, Bash allow-list, xterm.js. The
- **Open threads:** two-step spawn, unprivileged
containers, Bash allow-list, xterm.js. The
deployment / gateway / privsep cluster is tracked as
`area:ops` forge issues. (Landed since this note was first written:
extra per-agent MCP servers, per-agent send allow-list,