fix(prompt): keep plan/build reminders stable#27863
Conversation
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
|
The following comment was made by an LLM, it may be inaccurate: Potential Duplicate FoundPR #26743: fix(session): persist plan mode reminders This PR appears related as it also addresses plan mode reminders. While the current PR (27863) focuses on keeping Plan/Build reminders stable across serializations to preserve prefix-cache stability, PR #26743 addresses persisting plan mode reminders. These may be related efforts around plan mode reminder handling and should be reviewed to ensure they don't conflict or duplicate work. |
|
Closing and recreating with the exact PR template from the start to avoid stale compliance labels. |
Issue for this PR
Closes #26749
Type of change
What does this PR do?
Fixes prompt-history instability where Plan/Build synthetic
<system-reminder>content could move between historical user turns across later request serializations.Root cause: Plan/Build reminders were attached to the latest user turn, and one later path mutated existing message parts in place. This allowed a historical user message to serialize once as
Continueplus a Plan -> Build reminder, then later serialize as onlyContinue.Changes:
This preserves prefix-cache stability for OpenAI-compatible local backends such as llama.cpp, vLLM, and LM Studio because previously seen prompt messages remain byte-stable.
How did you verify your code works?
Ran:
bun test test/session/prompt.test.ts -t "keeps plan/build system reminders anchored to the original user turn across later serializations"bun test test/session/prompt.test.ts -t "static loop consumes queued replies across turns"bun test test/session/prompt.test.tsbun turbo typecheckResult: all passed.
I also ran a source-checkout smoke test using the repository's fake OpenAI-compatible TestLLMServer, without loading a real model.
The smoke test reproduced Plan -> Build -> Continue -> later Build and verified that the historical
Continue + <system-reminder>message stayed byte-stable across later serializations.Observed:
continueIndex: 3firstDiffMsg: 4Screenshots / recordings
Not applicable. This is a prompt serialization / cache stability bug fix with regression tests.
Checklist