Add memory_compactions tool for browsing compaction checkpoints
Queries compaction-type parts in the DB to find session compaction events, then retrieves the summary text from the adjacent assistant message. Presents compactions as navigable checkpoints with list and read modes.
This commit is contained in:
12
AGENTS.md
12
AGENTS.md
@@ -59,12 +59,13 @@ src/
|
||||
| `experimental.chat.system.transform` | Inject context % used + advisory into system prompt |
|
||||
| `event` | Feed SSE events to ContextTracker |
|
||||
|
||||
### Tools (7)
|
||||
### Tools (8)
|
||||
|
||||
| Tool | Purpose |
|
||||
|------|---------|
|
||||
| `memory_context` | Current context window usage (% , tokens, model, status) |
|
||||
| `memory_compact` | Trigger compaction via `ctx.client.session.summarize()` |
|
||||
| `memory_compactions` | List/read compaction checkpoints (summaries) for a session |
|
||||
| `memory_summary` | Quick counts: projects, sessions, messages, todos |
|
||||
| `memory_sessions` | List recent sessions, optionally filtered by project path |
|
||||
| `memory_messages` | Read messages from a specific session |
|
||||
@@ -99,6 +100,15 @@ usable = model.limit.input ? model.limit.input - reserved
|
||||
|
||||
The `tokens.input` on the last assistant message approximates context size. We track against model context limit from config, falling back to 200k.
|
||||
|
||||
### Compaction Data in DB
|
||||
|
||||
When compaction occurs, OpenCode creates:
|
||||
1. A synthetic `user` message with a `compaction`-type part (`part.data = {type: "compaction", auto: true/false, overflow: true/false}`)
|
||||
2. `message.data.summary = {diffs: [...]}` on the compaction message
|
||||
3. The assistant message immediately after contains the actual summary text in a `text`-type part
|
||||
|
||||
The `memory_compactions` tool queries for `compaction`-type parts and retrieves the adjacent summary text, presenting them as navigable checkpoints.
|
||||
|
||||
### Write Operations
|
||||
|
||||
All write operations (compaction triggering) go through the OpenCode client SDK (`ctx.client.session.summarize`). The plugin never writes to the database or any OpenCode files.
|
||||
|
||||
Reference in New Issue
Block a user