I’m trying to update session state via tool call from Team leader. But it is not passing team object properly. I’m referring this documentation: Agent Session - Agno. Everytime team parameter has random dictionary, not actual team object that is deriving the conversation.
class TeamToolkit(Toolkit):
name = "team_toolkit"
def __init__(self):
super().__init__(name="team_toolkit")
self.register(self.update_session_state)
def get_current_session_state(self, session_id:str) -> str|None:
"""Retrieves current session state. It can be one of following:
- `completed`.
- `waiting_async_tool`
- `disconnected`
- `running`
Args:
session_id: Session id
Returns:
str: session state
"""
try:
session = Session.objects.get(session_id=session_id)
except Session.DoesNotExist:
return "Session object does not exist as of now."
session_state = session.session_data.get('session_state', {})
state = session_state.get('state', None)
print(session.session_data)
print(session_state)
print(state)
return state
def update_session_state(self, team:Team, current_session_state:str, new_session_state:str) -> str:
"""updates the team's session state based on following rules:
- if goal is not achieved and conversation is still going on, then session state should be `running`.
- if goal is achieved, then session state should be `completed`.
- if async tool call is made, then session state should be `waiting_async_tool`
- if any exception happens, then session state should be `disconnected`
Args:
team: Agent Team
current_session_state: Current session state
new_session_state: session state to be updated
Returns:
session_state: New team session state
"""
# state_dict = {'session_state': {'state': new_session_state}}
#
# session:Session = Session.objects.get(session_id=session_id)
# new_session_data = {**session.session_data, **state_dict}
#
# print(session.session_data)
# session.session_data = new_session_data
# session.save(update_fields=['session_data'])
# session.refresh_from_db()
# print(session.session_data)
team.session_state = {"state": new_session_state}
# print(f"Session state: {new_session_state} saved.")
return f"Session state: {new_session_state} saved."
@Monali @Monali @kausmos @Dirk @ayush could you guys please assist me. I’ll really appreciate your help