generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 579
feat: add per_turn parameter to SlidingWindowConversationManager #1374
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
zastrowm
merged 6 commits into
strands-agents:main
from
zastrowm:enable_conversation_manager_elsewhere
Dec 26, 2025
Merged
feat: add per_turn parameter to SlidingWindowConversationManager #1374
zastrowm
merged 6 commits into
strands-agents:main
from
zastrowm:enable_conversation_manager_elsewhere
Dec 26, 2025
+297
−3
Conversation
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
Allow conversation managers to act as hook providers and add an option to built-in conversation managers to proactively apply message management during the agent loop execution. Use that functionality to add an option to SlidingWindowConversationManager to allow per_turn management application Fixes strands-agents#509
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
src/strands/agent/conversation_manager/sliding_window_conversation_manager.py
Outdated
Show resolved
Hide resolved
src/strands/agent/conversation_manager/sliding_window_conversation_manager.py
Outdated
Show resolved
Hide resolved
Long term plan is to allow every ConversationManager to add hooks as needed
zastrowm
added a commit
to zastrowm/docs
that referenced
this pull request
Dec 26, 2025
Per strands-agents/sdk-python/pull/1374 update docs with the latest information on being conversation-managers.
6 tasks
dbschmigelski
previously approved these changes
Dec 26, 2025
src/strands/agent/conversation_manager/sliding_window_conversation_manager.py
Outdated
Show resolved
Hide resolved
zastrowm
added a commit
to zastrowm/docs
that referenced
this pull request
Dec 26, 2025
Per strands-agents/sdk-python/pull/1374 update docs with the latest information on being conversation-managers.
General stance is that we don't do validation - will remove for now
dbschmigelski
approved these changes
Dec 26, 2025
JackYPCOnline
approved these changes
Dec 26, 2025
zastrowm
added a commit
to strands-agents/docs
that referenced
this pull request
Dec 26, 2025
Per strands-agents/sdk-python/pull/1374 update docs with the latest information on being conversation-managers. --------- Co-authored-by: Mackenzie Zastrow <zastrowm@users.noreply.github.com>
This was referenced Dec 26, 2025
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
Allow conversation managers to act as hook providers and add an option to built-in conversation managers to proactively apply message management during the agent loop execution.
Use that functionality to add an option to SlidingWindowConversationManager to allow per_turn management application
Addresses #509
Public API Changes
Default
per_turn=Falsemaintains current behaviorParameter Options
per_turn=False(default): Current behavior - management only at endper_turn=True: Apply management before every model callper_turn=N(int): Apply management before every N model callsConversationManager as HookProviders
ConversationManagernow provides aregister_hooks()method that subclasses can override to integrate with the agent's event lifecycle and at initialization time, it will have it's hook subscribed to.SlidingWindowConversationManagerleverages this underneath the hood.Added
@runtime_checkabletoHookProviderprotocol to enable proper isinstance checks.Before:
After:
We guide folks to call
super().register_hooks(registry, **kwargs)because in the future I'd like to re-implement the default conversation-management behavior (where apply_management and reduce_context is called) using hooks - if we do that and folks aren't callingsuper().register_hooks(registry, **kwargs)then once we migrate to hooks then derived classes that do not callsuper().register_hookswould lose the default behavior which would be a breaking change.Related Issues
Type of Change
New feature
Testing
How have you tested the change? Verify that the changes do not break functionality or introduce warnings in consuming repositories: agents-docs, agents-tools, agents-cli
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.