Repository navigation
SWF(bug): stop instructions carrying over via previous_response_id - #60
Merged
maplepaladin73 merged 3 commits intoNov 22, 2026
Merged
Conversation
…e_id Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Devin Review found 1 finding. Devin automatically fixed it.
Fixed by Devin (1)
- Conversation appends silently lose user input — Valid: appenders skipped the stored item count, not the filtered replay prefix. Both paths now skip conversation_prefix.len(); blocking+streaming regression tests added.
4 of 5 tasks
This was referenced Nov 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On
/v1/responses, a turn resumed withprevious_response_idnow uses only its owninstructions: before, the previous turn's instructions were replayed too, so they stayed in effect and new ones were added as a second system message. OpenAI documents thatinstructionsare not carried over.Root cause:
lower_responses_to_chatinsertsinstructionsas a synthetic system message at position 0 of the lowered messages. Both the blocking (api/responses.rs) and streaming (api/responses_stream.rs) handlers then savedchat_req.messagesas-is as the stored transcript. The next turn replayed that transcript, request-scoped instructions included.Fix: both handlers save the transcript through one helper,
response_input_transcript, which drops only that instructions message (placed after anyconversationprefix). Explicit system messages ininputor the conversation stay in the transcript.Conversation appends: the blocking and streaming appenders worked out which items were new by skipping the stored conversation's item count. The replayed prefix (
from_conversation_item) drops non-message items, so it can be shorter than that count. Once the instructions message no longer filled the gap, that skip would have dropped the new user message. Both appenders now skipconversation_prefix.len(), the length of the prefix that was actually replayed.Test plan
New
api/responses_instructions_tests.rscalls the real Responses handlers withstore=trueand the realResponseStore/ConversationStore. Only the scheduler replies are stubbed. The tests cover blocking and streaming, withprevious_response_idand withconversation. Turn A sets instructions"X". Turn B either replaces them with"Y"or sends none. Each test checks that A's stored transcript has no"X", that B's prompt to the model has"Y"exactly once (or no system message when B sends none), and that explicit conversation system messages are kept. Two more tests start from a conversation holding one item the replay drops; they check that the new user input is appended and the instructions are not.Instructions tests fail before the fix (new tests run against the old
responses.rs/responses_stream.rs):Filtered-prefix tests fail before the append fix:
All pass after both fixes:
Full
sparkbin suite:test result: ok. 3225 passed; 0 failed; 14 ignored.Try it:
cargo fmt --all -- --checkATLAS_SKIP_BUILD=1 CUDARC_CUDA_VERSION=13000 cargo clippy --workspace --tests(exit 0)bash scripts/check-license-headers.sh(4264 valid, 0 invalid)typos(clean)Notes for reviewers
conversation_prefix.len(). That depends on lowering inserting instructions at position 0, which the comment inresponses_lowering.rsnow notes.CLA
Implemented in session Stop instructions carrying over via previous_response_id
Review with Devin · Open in Devin Desktop