fix(prompt): keep plan/build reminders stable#27845
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. |
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
Updated the PR description to use the required template sections and added Fixes #26749. |
|
The PR body now follows the required template and includes Fixes #26749, but the needs:issue / needs:compliance labels are still present. Could you re-run or clear the compliance check? |
|
All PR checks are now passing, including pr-standards/check-compliance. The stale needs:compliance label still appears to be present; could a maintainer clear it or re-run the label cleanup? |
|
This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window. Feel free to open a new pull request that follows our guidelines. |
What does this PR do?
Fixes #26749.
This 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: 4This means the first changed message was at the new append boundary, while the previous
Continuemessage containing the Plan -> Build reminder stayed identical.Screenshots / recordings
Not applicable. This is a prompt serialization / cache stability bug fix with regression tests.