Improve prefix cache inspection and warmup
Summary
Improve DeepSeek prefix-cache stability diagnostics and warmup correctness by making cache inspection and warmup keys account for real prompt layers, tool schemas, project context packs, and skills.
Motivation
Previous cache diagnostics could report incomplete or misleading cache state because /cache inspect did not include the real tool catalog, warmup keys depended on prior inspection state, and project context pack cache invalidation could miss prompt-relevant changes.
Changes
- Include the real request tool catalog in
/cache inspect. - Add
tool_catalog_hashandstable_prefix_hashto prompt inspection output. - Add a complete
CacheWarmupKeycovering provider, model, base URL, stable prefix, tool catalog, project pack, and skills. - Compute warmup keys from current app/request state instead of
last_cache_inspection. - Make Project Context Pack generation deterministic with sorted entries and sort-before-truncate behavior.
- Improve Project Context Pack cache invalidation with a manifest hash covering included file paths and README excerpt content.
- Skip wire-payload dedup for short tool results and keep dedup strictly wire-only.
- Update memory documentation to describe memory/session goal content as dynamic.
Cache hit improvement rationale
The changes increase probability of prefix cache reuse by stabilizing prompt-layer ordering, tool catalog ordering, and Project Context Pack rendering. They also make cache misses more diagnosable by exposing stable prefix, full reusable prefix, tool catalog, project pack, and skills hashes.
Performance considerations
Project Context Pack generation now walks prompt-relevant entries to compute a reliable manifest hash, while reusing rendered packs when the manifest is unchanged. Short tool results bypass dedup hashing and map lookup entirely. Warmup does not introduce extra catalog/network requests beyond the explicit warmup model call.
Risks and rollback
Risk is limited to cache diagnostics, warmup behavior, project context pack rendering, and wire payload compaction. Rollback can revert the cache inspection/warmup and project pack changes independently if provider behavior differs in production.
Follow-up work
- Optionally allow first-run
/cache inspectto build the current tool catalog before any model turn. - Consider adding config file excerpts to Project Context Pack only if they are intentionally part of the prompt, with matching manifest hash coverage.
Thanks for the contribution. I’m keeping the v0.8.33 branch focused on final release polish and not pulling this PR into that branch right now. Leaving it open for review in the next cycle.
感谢你的分享。我现在把v0.8.33分支放在最终版本的润色上,暂时不把这个PR拉到那个分支。留给下一轮审查。
Excuse me, which version is expected to conduct the review of this PR
This PR was opened before the v0.8.41 rebrand and is now stale. Feel free to rebase onto current main and reopen. 鲸鱼兄弟们等你 🐋