-
Notifications
You must be signed in to change notification settings - Fork 203
Session persistence #302
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?
Session persistence #302
Conversation
d62b09b
to
74d7ed6
Compare
74d7ed6
to
3b81f1b
Compare
@Unshure @zastrowm Would this feature be available/merged in near future (coming weeks)? I have a use case of this to persist the context/session of an agent where the agent in deployed in a lambda function. I want to keep the context of the previous invocations of the agent based on session_id. |
Hi @azaylamba , planning on getting this feature merged and available by end of this week! |
Hi @azaylamba, if it is a long conversation, would it be better to use fargate(ECS) instead of lambda to avoid potential timeout issue? |
Thanks for the update @Unshure |
Hi @macsir , it is not a long conversation and the agent run time won't be long. But the agent should be aware of past interactions and actions, so that those are not repeated (in case action has been already taken by human) and the agent has the historical context. |
bf92e79
to
358c529
Compare
358c529
to
fad4892
Compare
fad4892
to
26cb42d
Compare
26cb42d
to
a296b83
Compare
a296b83
to
5374537
Compare
5374537
to
90d6ea8
Compare
90d6ea8
to
838ccaa
Compare
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.
No major blockers - a couple call-outs and questions, but otherwise looks good!
c363032
to
0bc4cd0
Compare
Latest changes can be viewed here: https://github.com/strands-agents/sdk-python/compare/8b267d21972f72bc0b4cdd59c132c282852dd9ca..0bc4cd0168fbdcfc973d83405abdd1542a6dfa3f |
Description
This PR introduces a SessionManagement class to the Strands SDK that is in charge of persisting an agent to some datastore, and re-initializing the agent. The SessionManagement feature set includes:
Introduces an agent
id
attribute used as a unique id for differentiating agentsSessionManager: Interface for SessionManagers. This interface introduces a
append_message_to_agent_session
method that is called in the Agent class when adding a message to the agent messages array, as well as aninitialize_agent
class for initializing an agentAgentSessionManager: Implementation of the above interface for persisting a single agent to some datastore. This will also re-initialize the agent's messages and state.
Session models: Three new models to represent different data types for session persistence:
SessionRepository: Repository Interface with create, read, update operations for each of the above new models
FileSessionManager: A implementation of the SessionRepository and AgentSessionManager for storing a session in the local file system. This introduces the following directory and file structure to represent a Session:
S3SessionManager: Same as the above FileSessionDManager, but stores sessions in S3
Things that will be addressed in follow up pr's:
#246
Documentation PR
TODO:
PR coming, here are some initial docs: https://unshure.github.io/docs/latest/user-guide/concepts/agents/state-sessions/#session-management
Type of Change
New feature
Testing
How have you tested the change?
• [x] I ran hatch run prepare
Checklist
• [x] I have read the CONTRIBUTING document
• [x] I have added any necessary tests that prove my fix is effective or my feature works
• [ ] I have updated the documentation accordingly
• [ ] I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
• [x] My changes generate no new warnings
• [x] Any dependent changes have been merged and published
Additional Notes:
N/A
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the
terms of your choice.