-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat: Add file read caching to prevent redundant reads in conversation history #4393
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
atttempt 2.
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
hannesrudolph
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good implementation of file read caching. The architecture is sound and test coverage is comprehensive. Main concerns are memory management and error handling - see specific comments below.
hannesrudolph
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Memory management concern: Consider implementing cache size limits and eviction policies to prevent memory issues with large files or long conversations.
hannesrudolph
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error handling: Add proper error handling for file system operations when checking mtime. Consider what happens if a file is deleted between cache check and actual read.
hannesrudolph
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider separating the dependency updates (package.json, pnpm-lock.yaml changes) into a separate PR. This makes the feature changes easier to review and track.
|
Will do so soon, thanks Hannes |
|
Closing this in favor of the new PR #4501 |
Related GitHub Issue
Closes: #4009
Description
This pull request introduces a file read caching mechanism to prevent re-reading file content that is already present in the conversation history. This improves performance and reduces redundant operations.
The core implementation includes:
fileReadCacheService.tsthat tracks file content and modification times (mtime) within the conversation history.read_filetool request. If the requested file content is fresh (i.e.,mtimehas not changed), the tool returns a notice instead of reading the file again.readFileTool,applyDiffTool, andwriteToFileToolto include file metadata (modification time and line ranges) in their XML output, which is used to populate the cache.vitestand related testing dependencies to thepackage.jsonfiles, which was necessary to write tests for the new caching service in accordance with the project's contribution guidelines.Reviewers should pay close attention to the caching logic in
fileReadCacheService.tsand how themtimeis used to invalidate the cache.Test Procedure
This implementation was validated through a combination of new and updated unit tests:
src/core/services/__tests__/fileReadCacheService.spec.ts, was created to cover the caching logic, including cache hits, misses, partial hits, and invalidation based on file modification times.src/core/tools/__tests__/readFileTool.test.ts, was significantly updated to mock the caching service and verify that the tool correctly interacts with the cache (e.g., skipping file reads on a cache hit).pnpm testfrom the root of the repository.Type of Change
srcor test files.Pre-Submission Checklist
npm run lint).console.log) has been removed.npm test).mainbranch.npm run changesetif this PR includes user-facing changes or dependency updates.Screenshots / Videos
N/A. This is a non-UI change.
Documentation Updates
The internal developer documentation should be updated to reflect the new file read caching behavior and the importance of the metadata now included in tool responses.
Additional Notes
The updates to
package.jsonandpnpm-lock.yamlare a result of addingvitestas a testing framework for the new service, which is in line with the project's testing standards.Get in Touch
Mnehmos