Summary
Make prompt assembly inputs deterministic by sorting discovered skills, prompts, extension files, and plugin tools before rendering or request construction.
Why
Prompt/KV cache reuse depends on exact repeated prefixes, not semantic similarity. Today, filesystem discovery and plugin registration order can drift across runs, which can mutate:
- the
<available_skills> section,
- prompt template listings,
- extension load order,
- plugin tool order,
- final tool definitions sent to providers.
This is a direct cache-breaker.
Scope
Introduce deterministic ordering rules for all semi-static prompt resources.
Required ordering rules
- extension files sorted by normalized path
- skills sorted by
(name, path)
- prompts sorted by
(name, path)
- plugin tools sorted by
(source path, tool name)
- final tool definitions rendered in a stable order
Code touchpoints
crates/cli/src/extensions/discovery.rs
crates/cli/src/extensions.rs
crates/cli/src/session_bootstrap.rs
crates/cli/src/run.rs
- plugin runtime assembly code
Acceptance criteria
- repeated bootstrap in the same repo/settings yields identical skill/prompt rendering
- plugin tool order is stable across runs
- stable prefix hash does not change because of filesystem enumeration order
- tests cover ordering stability
Reference
knowledge/internal/KV_CACHE_REFACTOR_MASTER_PLAN.md
Summary
Make prompt assembly inputs deterministic by sorting discovered skills, prompts, extension files, and plugin tools before rendering or request construction.
Why
Prompt/KV cache reuse depends on exact repeated prefixes, not semantic similarity. Today, filesystem discovery and plugin registration order can drift across runs, which can mutate:
<available_skills>section,This is a direct cache-breaker.
Scope
Introduce deterministic ordering rules for all semi-static prompt resources.
Required ordering rules
(name, path)(name, path)(source path, tool name)Code touchpoints
crates/cli/src/extensions/discovery.rscrates/cli/src/extensions.rscrates/cli/src/session_bootstrap.rscrates/cli/src/run.rsAcceptance criteria
Reference
knowledge/internal/KV_CACHE_REFACTOR_MASTER_PLAN.md