fix(cache): auto-generate .deepseek/instructions.md to stabilize KV prefix cache#1080
Merged
Hmbown merged 1 commit intoHmbown:mainfrom May 7, 2026
Merged
fix(cache): auto-generate .deepseek/instructions.md to stabilize KV prefix cache#1080Hmbown merged 1 commit intoHmbown:mainfrom
Hmbown merged 1 commit intoHmbown:mainfrom
Conversation
…refix cache When no context file (AGENTS.md, CLAUDE.md, etc.) exists in the workspace, the previous fallback called summarize_project() and project_tree() on every turn via refresh_system_prompt(). These functions scan the filesystem in real-time, so any file change during a session alters the system prompt bytes and invalidates the entire KV prefix cache from that layer onward. Now load_project_context_with_parents() auto-generates .deepseek/instructions.md once when no context file is found. Subsequent turns load the file from disk — bytes are stable for the entire session. Users can edit or delete the file at any time.
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Contributor
Author
|
@Hmbown |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When a workspace has no context file (
AGENTS.md,CLAUDE.md,.deepseek/instructions.md, etc.), the system prompt assembly falls back to callingsummarize_project()+project_tree()on every turn viarefresh_system_prompt(). Both functions useWalkBuilderto scan the filesystem in real-time. Any file change during a session alters the system prompt bytes, invalidating the entire KV prefix cache — effectively zero cache hits for workspaces without context files.Fix:
load_project_context_with_parents()now auto-generates.deepseek/instructions.mdonce when no context file is found. Subsequent turns load the file from disk, keeping system prompt bytes stable for the entire session. The generated file is marked as auto-generated; users can freely edit or delete it.Closes #979
Testing
cargo test --all-featurescargo fmt --all -- --checkcargo clippy --all-targets --all-featuresChecklist