Why LCM Exists
Standard context management has a fundamental problem: when the context window fills up, old messages are summarized into a flat blob and the originals are discarded. The agent loses access to details discussed earlier in the conversation. LCM solves this by maintaining a hierarchical summary DAG (directed acyclic graph) alongside an immutable message store. Summaries compress the history for the model’s context window, but the originals are always available for recall via agent tools.Within-session
LCM keeps the agent coherent during long conversations via DAG compression with full recall.
Across sessions
MemU provides persistent memory across months and years of interaction.
How It Works
Immutable Message Store
Every user message, assistant response, and tool result is persisted verbatim in a SQLite database (~/.argentos/lcm.db). Messages are never modified or deleted. This is the ground truth that everything else builds on.
The Summary DAG
As the context window fills, LCM compresses older messages into a hierarchical tree of summaries:- Leaf summaries (depth 0): Created from chunks of ~20,000 tokens of raw messages, compressed to ~1,200 tokens each
- Condensed summaries (depth 1+): Created when 4+ same-depth summaries accumulate, merged into ~2,000 token nodes
- Fresh tail: The 32 most recent messages are always kept raw (configurable)
Context Assembly
Each turn, the agent sees compressed history summaries followed by the fresh tail of recent raw messages. The summaries provide continuity while the fresh tail preserves full detail for the active conversation.Three-Level Escalation
Compaction always converges, guaranteed:| Level | Strategy | Temperature | When |
|---|---|---|---|
| Normal | Narrative summary, preserve details | 0.2 | Default |
| Aggressive | Bullet points only, half tokens | 0.1 | Normal summary too large |
| Deterministic | Mechanical truncation, no LLM | N/A | LLM fails or returns oversized output |
Agent Tools
LCM registers three tools that give agents recall capabilities over compacted history:aos_lcm_grep
Full-text search across the entire conversation history, including messages compacted out of context.
aos_lcm_describe
Retrieve the full content of a specific message or summary node by ID.
aos_lcm_expand_query
Expand a summary back to its original source messages by walking the DAG.
- Agent calls
aos_lcm_grepwith a search query - Gets ranked results with snippets and message IDs
- Calls
aos_lcm_describeto read the full message - Or calls
aos_lcm_expand_queryto expand a summary back to its originals
Configuration
LCM is enabled by default. Configuration is inargent.json:
Options
| Option | Default | Description |
|---|---|---|
enabled | true | Enable LCM context management |
freshTailCount | 32 | Recent messages kept raw (not summarized) |
contextThreshold | 0.75 | Trigger compaction at this fraction of context window |
summaryModel | "auto" | Model for summarization. "auto" uses the model router |
leafChunkTokens | 20000 | Token target per leaf compaction chunk |
leafTargetTokens | 1200 | Token target for leaf summary output |
condensedTargetTokens | 2000 | Token target for condensed summaries |
incrementalMaxDepth | -1 | Maximum DAG depth (-1 = unlimited) |
largeFileTokenThreshold | 25000 | Files above this are stored externally |
databasePath | ~/.argentos/lcm.db | Custom database path |
Disabling LCM
Large File Handling
Files over 25,000 tokens (configurable) are automatically stored externally with compact exploration summaries injected into context. The full content remains accessible viaaos_lcm_describe.
Database
LCM uses its own standalone SQLite database at~/.argentos/lcm.db, separate from MemU’s PostgreSQL. The database uses WAL mode for concurrent reads and includes FTS5 full-text indexes for fast grep searches.
| Table | Purpose |
|---|---|
messages | Immutable message store |
messages_fts | FTS5 full-text search index |
summaries | DAG summary nodes |
summary_messages | Leaf summary to source message links |
summary_sources | Condensed summary to source summary links |
context_items | Active context window state |
large_files | Externally stored large file metadata |
