- 
                Notifications
    You must be signed in to change notification settings 
- Fork 453
feat: implemented pruning conversation manager #766
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
base: main
Are you sure you want to change the base?
Conversation
        
          
                src/strands/agent/conversation_manager/strategies/tool_result_pruning.py
              
                Outdated
          
            Show resolved
            Hide resolved
        
              
          
                src/strands/agent/conversation_manager/strategies/tool_result_pruning.py
              
                Outdated
          
            Show resolved
            Hide resolved
        
      There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the value in pruning tool result messages that exceed some threshold, but there seems to be a lot more going on in this feature, and Im not even sure that the conversation manager is the right place for this logic to live.
A feature like this makes a bit more sense as a hook in my mind: https://strandsagents.com/latest/documentation/docs/user-guide/concepts/agents/hooks/#hook-event-lifecycle
We have some lifecycle events, like AfterModelCallEvent and AfterToolCallEvent, where a hook can intercept the result of the model or tool and prune it to be shorter.
With the current design of conversation managers, they are basically just error handlers and are not well suited to be proactive context managers. We do plan to improve upon this in the future, and update them to use hooks, but until then I think this feature makes more sense as a hook.
| 
 r.e. hooks, they are inappropriate as conversation managers manage the entire context, including older messages. Hooks are focused on specific actions before and after message creation/addition to context. agents are stateful. conversation managers, by default, are not, as they operate solely on the agent based on its state. conversation managers might need state management should their business logic require state tracking, which currently is not the case. | 
| Codecov Report❌ Patch coverage is  
 📢 Thoughts on this report? Let us know! | 
Description
Implement Pruning conversation manager to prune messages in the agent conversation history. Heuristic pruning strategy implemented for tool responses that are too long.
Related Issues
#556
Documentation PR
strands-agents/docs#229
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.