agentops icon indicating copy to clipboard operation
agentops copied to clipboard

[Bug]: Recording Events in Multi-Crew Sync/Async Workflows

Open areibman opened this issue 11 months ago • 0 comments

Contact Details

No response

📦 Package Version

0.3.27

🎞️ Framework Version

crewai>=0.100.0

🔎 Describe the Bug

When running a complex agentic workflow that involves multiple crews, some of which execute asynchronously, I am encountering errors related to event recording. Despite calling agentops.start_session() at the beginning of the flow, the following error messages appear intermittently during execution:

2025-02-05 16:16:46,429 - ERROR - Could not record event. Start a session by calling agentops.start_session().
2025-02-05 16:16:53,666 - ERROR - Could not record event. Start a session by calling agentops.start_session().

Steps to Reproduce: 1. Create a multi-crew asynchronous workflow. 2. Start the session using agentops.start_session(). 3. Execute the workflow which calls multiple crews (e.g., AnalysisOutlineCrew, ResearchApproachCrew, etc.) that run asynchronously. 4. Observe the error messages during the workflow execution.

Expected Behavior: All event recordings should work seamlessly once the session is started. The workflow should record every action without issuing errors about the session.

Actual Behavior: The system intermittently reports that no session exists for recording events, even though the session is initialized at the beginning. This seems to occur specifically when handling multiple asynchronous crews.

Additional Context: • The error might be related to how the asynchronous tasks or crew calls interact with the global session. • It appears that once the flow begins processing asynchronous tasks, some of the event records are attempted before the session context is properly passed.

🤝 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.

areibman avatar Feb 05 '25 21:02 areibman