Collapse 8 tools to 2: memory router + memory_compact

All read-only operations now dispatch through a single memory tool that
routes by {tool: "name", args: {...}}. This cuts visible tool count from
8 to 2, significantly reducing context bloat for small models. The
memory_compact tool remains separate as it is a write/mutation operation.
This commit is contained in:
2026-04-21 11:17:34 +00:00
parent 38b84b8163
commit f822d93662
2 changed files with 355 additions and 398 deletions

View File

@@ -59,18 +59,27 @@ src/
| `experimental.chat.system.transform` | Inject context % used + advisory into system prompt |
| `event` | Feed SSE events to ContextTracker |
### Tools (8)
### Tools (2)
| 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 |
| `memory_search` | Text search across all conversations (LIKE-based) |
| `memory_plans` | List/read saved plan files |
| `memory` | Router for all read-only operations: summary, sessions, messages, search, compactions, context, plans, help. Call with `{tool: "help"}` to see available operations. |
| `memory_compact` | Trigger compaction via `ctx.client.session.summarize()` — kept separate because it's a mutation |
The `memory` tool dispatches to internal handlers by `tool` name, keeping the agent's visible tool count low (2 instead of 8) to minimize context bloat.
**Internal operations** (accessed via `memory({tool: "...", args: {...}})`):
| Operation | Purpose | Key args |
|-----------|---------|----------|
| help | Show available operations, or details for a specific one | tool (optional) |
| summary | Quick counts: projects, sessions, messages, todos | — |
| sessions | List recent sessions, optionally filtered by project | limit, projectPath |
| messages | Read messages from a specific session | sessionId, limit |
| search | Text search across all conversations (LIKE-based) | query, limit |
| compactions | List/read compaction checkpoints for a session | sessionId, read |
| context | Current context window usage (% , tokens, model, status) | — |
| plans | List or read saved plan files | read (filename) |
### Database Access