Skip to content

fix(cache): auto-generate .deepseek/instructions.md to stabilize KV prefix cache#1080

Merged
Hmbown merged 1 commit intoHmbown:mainfrom
lloydzhou:fix-cache-missing
May 7, 2026
Merged

fix(cache): auto-generate .deepseek/instructions.md to stabilize KV prefix cache#1080
Hmbown merged 1 commit intoHmbown:mainfrom
lloydzhou:fix-cache-missing

Conversation

@lloydzhou
Copy link
Copy Markdown
Contributor

Summary

When a workspace has no context file (AGENTS.md, CLAUDE.md, .deepseek/instructions.md, etc.), the system prompt assembly falls back to calling summarize_project() + project_tree() on every turn via refresh_system_prompt(). Both functions use WalkBuilder to 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.md once 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-features
  • cargo fmt --all -- --check
  • cargo clippy --all-targets --all-features

Checklist

  • Updated docs or comments as needed
  • Added or updated tests where relevant
  • Verified TUI behavior manually if UI changes

…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.
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@lloydzhou
Copy link
Copy Markdown
Contributor Author

@Hmbown
可以看看这个可能导致缓存失效的bug,我感觉影响范围还挺大的,希望可以尽快处理

@Hmbown Hmbown merged commit 6d3e67e into Hmbown:main May 7, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

完成相似的任务 缓存命中率比claudecode低很多

2 participants