[Bug]: CrewAI session handling not working
Contact Details
No response
📦 Package Version
0.3.24
🎞️ Framework Version
CrewAI
🔎 Describe the Bug
There are issues with session management when implementing AgentOps for a CrewAI flow loop. The use case involves running a server that executes a CrewAI flow loop. Within this flow, there are two different crews, each of which can run multiple times within a single iteration.
All agents’ information for one iteration of the loop should be grouped into a single session for review purposes.
The following approach was used to manage sessions:
print(SESSION_ID)
if SESSION_ID is None:
SESSION_ID = str(agentops.start_session().session_id)
else:
try:
agentops.start_session(inherited_session_id=SESSION_ID)
except Exception as e:
print("Error in starting session", e)
SESSION_ID = agentops.start_session().session_id
Observed Behavior
This approach has resulted in the following issues: • Session ID does not exist or is returned as None. • Errors such as “Error in replacing UUID.” • Inability to initialize new sessions using existing session IDs.
Another implementation using the following code also encountered problems:
for message in list:
agentops.init(auto_start_session=False, skip_auto_end_session=True, default_tags=RUN_TAGS)
agentops.start_session()
result = (
CrewAiCrew()
.crew()
.kickoff(inputs={})
)
agentops.end_session(end_state="Success")
🤝 Contribution
- [ ] Yes, I'd be happy to submit a pull request with these changes.
- [ ] I need some guidance on how to contribute.
- [x] I'd prefer the AgentOps team to handle this update.
Couldn't reproduce the issue.
Flow works when using skip_auto_end_session=True in the session initialization.