fix(test): update session integ test for sliding window conversation manager#2092
Merged
mkmeral merged 1 commit intostrands-agents:mainfrom Apr 8, 2026
Conversation
…forcement The sliding window conversation manager now enforces that the first remaining message after trimming is a user message (strands-agents#2087). This makes window_size=1 unable to trim simple (no-tool) conversations since the sole remaining message would be an assistant message. Update the test to use window_size=2 which still validates: - Session manager persists all messages (including trimmed ones) - Conversation manager trims in-memory messages after exceeding window - Restored agent loads trimmed state correctly - removed_message_count is tracked and restored properly - Full message history is preserved in session across multiple turns
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
JackYPCOnline
approved these changes
Apr 8, 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.
Description
The integration test
test_agent_with_file_session_and_conversation_managerfails after #2087 which enforces that the first remaining message after sliding window trimming must be ausermessage.The test used
window_size=1, which can no longer trim a simple (no-tool) conversation — after one turn the messages are[user, assistant], and trimming to 1 would leave only[assistant], which violates the new user-first rule. The conversation manager now correctly skips trimming in this case, leaving 2 messages instead of the expected 1.This PR updates the test to use
window_size=2and adds a second agent call before the session reload, which still exercises all the same behaviors:removed_message_countis tracked and restored across sessionsWith
window_size=2, two agent calls produce 4 messages which get trimmed to 2[user, assistant]— a valid window starting with a user message. After restoring and calling again, a third trim verifies the state was correctly persisted and restored.Related Issues
Follow-up to #2087
Type of Change
Bug fix
Testing
Ran the integration test suite locally. The updated test passes with the new sliding window behavior.
hatch run prepareChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.