Skip to main content

Module microcompact

Module microcompact 

Source
Expand description

Microcompact — lightweight tool result aging without full compaction. Microcompact — lightweight tool result aging without full compaction.

Replaces old tool result content with a stub ([Old tool result content cleared]) directly in the database. No LLM call, no API cost — just a SQL UPDATE.

Time-based trigger: only fires when the gap since the last assistant message exceeds a threshold (default 5 minutes). This prevents aggressive clearing during active tool use and matches Claude Code’s pattern where microcompact only runs when the prompt cache has gone cold.

Inspired by Claude Code’s microCompact.ts.

Structs§

MicrocompactResult
Result of a microcompact pass.

Constants§

CLEARED_MESSAGE
Stub text that replaces cleared tool results.

Functions§

diagnosis
Identifies the best candidates for microcompact using context analysis.
microcompact_session
Run microcompact on a session — clear old compactable tool results.