fix(prompt): freeze static system prompt per session to stop mid-session KV-cache flushes
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 19.9k
- Forks
- 2.3k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 30
Description
Problem
The static system prompt is re-read from disk on every API call. When the file changes mid-session (e.g. an external writer appends to a global AGENTS.md), the entire static prompt changes, which invalidates the provider KV/prefix cache and forces a full ~160k token re-upload on every call until the writer stops. This makes sessions unusable under concurrent writers.
Fix (ready to merge)
Branch fix/static-prompt-freeze on fork GroepOnline/jcode (rebased on current master): https://github.com/GroepOnline/jcode/tree/fix/static-prompt-freeze
Diff: https://github.com/1jehuang/jcode/compare/master...GroepOnline:fix/static-prompt-freeze.diff
Three commits:
- cc051d5de
fix(prompt): freeze static system prompt per session (KV-cache)— introducesStaticPromptLock, frozen once per session (same philosophy as locked tools); busts only on skills-fingerprint / canary / working-dir change. Dynamic parts still update per call viaappend_dynamic_prompt_parts. - d26551714
fix: Bust frozen prompts on config reload - 16f081167
fix(tests): PromptLockProvider stub mist Provider::fork
Verification
- app-core regression tests 3/3 green (incl. new test asserting the prompt stays stable when the underlying file mutates mid-session)
- clippy 0 warnings, tui check ok
- Fork PR #1 in GroepOnline/jcode was reviewed and merged there first
Note
Fork PRs are not accepted on this repo, so please cherry-pick from the branch above or open a branch here. Happy to adjust based on maintainer preference.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the fix/static-prompt-freeze branch and the three listed commits, especially the StaticPromptLock changes and app-core regression tests. Run the reported 3/3 app-core tests and verify that the static prompt remains stable when its underlying file changes during a session, while dynamic prompt updates and config-reload busting still behave as described.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- ai, cli, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100