Skip to main content
Glama

Compact the memory store

memory_compact
Destructive

Frees persistent-memory budget after a refused save by archiving the stalest facts, returning what moved so you can retry the save; archived facts remain restorable, not deleted.

Instructions

Free room in persistent memory when memory_save was refused for budget. Archives the stalest facts of the writable project store until a fact as large as the biggest one kept will fit, and returns what moved — every archived name with its type and description. Nothing is deleted: archived facts leave the index but stay on disk under archive/, memory_recall with include_archived still finds them, and bringing one back is an operator action rather than a tool — bantamkit-memory restore <name> (Node) or python -m bantamkit.memory restore <name> (Python) on the store; no tool deletes a fact. Read-only grants and the profile layer are never touched. Call it after a budget refusal, then retry the save; calling it under budget archives nothing and says so. It is not the pass for two copies of one name across layers — that is memory_dream.

Input Schema

NameRequiredDescriptionDefault
reserveNoBytes of index headroom to free below the budget: the target is `budget - reserve`, a negative value counts as 0, any value is capped at half the budget, and 0 compacts to the budget itself. Omit for the default: the room the degraded-index warning demands (the budget minus `(90 * budget - 1) // 100`) plus the size of the largest index line the store holds -- at the default 24000-byte budget with a 39-byte largest line that is 2401 + 39 = 2440, a 21560-byte target.

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.36.0

TDQS

A4.4/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Adds substantial context beyond the annotations: what actually moves, that nothing is deleted and archived facts remain on disk and are still visible to memory_recall with include_archived, that restoration is an operator CLI action rather than a tool, and that read-only grants and the profile layer are untouched. The 'Nothing is deleted' line could read as tension with destructiveHint=true, but it is a clarification of what 'destructive' means here (index removal, recoverable archive) rather than a contradiction.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with the trigger and the action, and each subsequent clause adds a distinct, load-bearing fact (returns, recoverability, operator restore, scope exclusions, sibling differentiation). It is dense and parenthetical-heavy, which costs a little readability, but no sentence is filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With annotations, a fully documented single parameter, and an output schema, the description covers what an agent still needs: when to call, what happens under budget, what is returned ('every archived name with its type and description'), and that recovery is out-of-band. Nothing material is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description never mentions the single parameter, but schema description coverage is 100% and the schema's `reserve` description is unusually thorough, including the default formula and a worked numeric example. Baseline 3 applies since the schema carries the parameter meaning.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb (compact/archive) and resource (the writable project memory store), names the exact trigger ('when memory_save was refused for budget'), and describes the selection rule ('stalest facts ... until a fact as large as the biggest one kept will fit'). It also pre-empts the nearest sibling by declaring 'It is not the pass for ... memory_dream.'

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives the precise usage sequence ('Call it after a budget refusal, then retry the save'), the negative case ('calling it under budget archives nothing and says so'), and the explicit alternative for a different problem ('that is memory_dream'). Nothing about when to reach for this tool is left to inference.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.