Repository navigation
fix(events): drop rewound turns when rewind target is outside the window - #7860
Open
ninglinLiu wants to merge 14 commits into
Open
ninglinLiu wants to merge 14 commits into
ninglinLiu wants to merge 14 commits into
Conversation
_apply_rewinds only jumped when the rewind target invocation was present in the loaded list. A GetSessionConfig.num_recent_events / after_timestamp window that starts after the target left the rewind marker without a match, so later (rewound) turns leaked back into the LLM prompt. When the target is missing, stop the backward walk so every earlier event in the list stays out of the active history. Fixes google#7859
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.
Description
_apply_rewindsonly removed a rewound span when the target invocation was present in the loaded event list. WithRunConfig.get_session_config=GetSessionConfig(num_recent_events=…)(orafter_timestamp) the window can start after the rewind target, so the marker matched nothing and rewound turns leaked back into the LLM prompt.When the target is missing from the list, stop the backward walk so every earlier event stays out of the active history. That covers truncated windows and unknown rewind targets.
Fixes #7859
Test plan
tests/unittests/events/test_rewind_events.pywith a window-style case (inv-1target omitted;inv-2events before the marker are dropped)AI assistance
Prepared with Cursor assistance; I verified the
_apply_rewindswalk and the new unit tests.