Skip to main content

Module compact_backstop

Module compact_backstop 

Source
Expand description

The srv backstop of an agent’s compaction. For a route agent it is the model’s budget (docs/specs/SPEC_ROUTE_AGENT_BRAKES_2026_11_10.md section 4.2): the launch environment moves the CLI’s own auto-compact down to it; if the agent’s context is still more than 1.5 times that budget (the variable was ignored, or the CLI’s compaction is off or failing), srv sends the agent /compact the way Agents compact does: once per try, between turns, never mid-turn. For a container agent it is one size well under its window (agent:compactbackstopat, 600K unless set), for an agent that does not act on the note it is given at 400K: the same rule, with the compaction placed at the head of the container’s queue. After two tries that left either over, the agent’s pane gets a warning line (block meta agent:context_warning, its own key: the spend watcher’s 80% warning is not touched) and its leader a note, once.

A route agent is looked at off the spend watcher’s per-response event, a container agent when a turn of it ends well: a map lookup each.

Structs§

Episode 🔒
What srv has done about one pane’s context since it passed the limit.
Subject 🔒
Whose context is looked at, for the log and the note to its leader.

Enums§

Step 🔒

Constants§

CONTEXT_WARNING_META_KEY
The pane’s context warning: {at, context}. Taken off when the context is back under the limit.
SETTLE_MS 🔒
After the last try, how long the context may stay over the limit before that try counts as failed.
TRIES 🔒
Compactions sent for one stretch over the limit before the agent’s pane and leader are told.

Functions§

after_container_turn 🔒
A container agent’s turn has ended well: look at how full its context is, against agent:compactbackstopat. An agent on a model route has the budget’s backstop already, so it is left to that one.
after_settled 🔒
A response of grant‘s agent has been counted: look at how full each of its panes’ contexts is.
compact 🔒
decide 🔒
What to do for a pane whose context is tokens against limit, the size it may not stay over.
episodes 🔒
look 🔒
One pane: settle the last try, decide what is next and do it.
recovered 🔒
The context is back under the limit: forget the episode, and take our warning off the pane.
tell 🔒