feat: add token-efficient recall and file compression tool#150
feat: add token-efficient recall and file compression tool#150
Conversation
Add memory_recall format and token budget support, plus a new memory_compress_file tool with API/MCP wiring, tests, and updated tool/endpoint docs.
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThis PR introduces markdown file compression ( Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant API as API Endpoint<br/>(api::compress-file)
participant Func as Function<br/>(mem::compress-file)
participant FS as File System
participant Provider as Summarization<br/>Provider
participant Audit as Audit Logger
User->>API: POST /compress-file<br/>{filePath}
API->>API: Validate filePath<br/>(non-empty string)
API->>Func: Trigger mem::compress-file
Func->>Func: Validate path<br/>(.md extension, not sensitive)
Func->>FS: Read file contents
FS-->>Func: Original content
Func->>Func: Check if empty
alt Not Empty
Func->>Provider: summarize(content)<br/>with compression prompt
Provider-->>Func: Compressed result
Func->>Func: Strip code fence<br/>if present
Func->>Func: Validate compression<br/>(headings, URLs, code blocks)
alt Validation Passes
Func->>FS: Write backup<br/>(filename.original.md)
FS-->>Func: Backup created
Func->>FS: Overwrite original<br/>with compressed content
FS-->>Func: File updated
Func->>Audit: Record audit event<br/>(paths, char counts)
Audit-->>Func: Logged (errors ignored)
Func-->>API: {success: true, ...sizes}
else Validation Fails
Func-->>API: {success: false, error, details}
end
else Empty File
Func-->>API: {success: true, skipped}
end
API-->>User: HTTP 200 JSON response
Estimated code review effort🎯 4 (Complex) | ⏱️ ~90 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Delete temporary architecture and memory-cycle asset files added during implementation.
Add memory_recall format and token budget support, plus a new memory_compress_file tool with API/MCP wiring, tests, and updated tool/endpoint docs.
This pull request primarily updates documentation to reflect the addition of a new MCP tool (bringing the total to 44) and a reduction in the number of REST API endpoints (now 104). It also introduces a new
assets/architecture.htmlfile that visually explains the system architecture and the flow of context and memory within the agentmemory system.Documentation updates:
README.mdandAGENTS.mdto show 44 MCP tools and 104 REST endpoints, including changes to badges, environment variable comments, and feature lists. [1] [2] [3] [4] [5] [6]New system architecture visualization:
assets/architecture.html, a comprehensive HTML file with diagrams and annotations illustrating how external context, memory, and context fragments interact with the computation box (model context window) in agentmemory.Summary by CodeRabbit
New Features
Documentation