Repository navigation
Conversation
This was referenced Nov 26, 2026
This branch has not been deployed
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.
Fixes #518
Summary
Fix queued Agent turns receiving future queued messages or the active empty assistant placeholder as part of their prompt.
The context boundary is now determined by the identity of the user message being dispatched, rather than by assuming the active streaming placeholder is the final item in the persisted conversation message array.
Root cause
For directly submitted turns,
begin()appends the user message and streaming assistant placeholder at the end, so tail-relative slicing happens to work.For queued turns,
dispatch()inserts the placeholder immediately after the selected queued user message while later queued user messages remain after it. The oldsaved['messages'][:-1]/[:-2]logic and last-message preference attachment therefore used the wrong boundary. In a multi-message queue, the current turn could see a future user message, or an empty assistant placeholder, and attach the current preference instruction to the wrong message.Change
Tests and evidence
test_assistant_queued_context.py.2e5cb380.test_creation_storage...[in_place]failure also occurs on clean main and is treated as a pre-existing flaky failure.lint-imports: all four contracts preserved.Scope
This PR fixes queued-turn context boundaries only. It does not change what happens to queued messages after a runtime/persistence failure, or the treatment of queued messages cancelled by Stop; those require separate lifecycle/product decisions.
Related: #379, #502, #509, #476.