Test the CrewAI < 0.105.0 pattern where end_session is called with only kwargs. In versions < 0.105.0, CrewAI directly calls: agentops.end_session( end_state="Success", end_state_reason="Finished Execution", is_auto_end=True )
(mock_tracing_core, mock_api_client, mock_trace_context, reset_client)
| 538 | |
| 539 | |
| 540 | def test_crewai_kwargs_pattern(mock_tracing_core, mock_api_client, mock_trace_context, reset_client): |
| 541 | """ |
| 542 | Test the CrewAI < 0.105.0 pattern where end_session is called with only kwargs. |
| 543 | |
| 544 | In versions < 0.105.0, CrewAI directly calls: |
| 545 | agentops.end_session( |
| 546 | end_state="Success", |
| 547 | end_state_reason="Finished Execution", |
| 548 | is_auto_end=True |
| 549 | ) |
| 550 | """ |
| 551 | import agentops |
| 552 | from agentops.legacy import Session |
| 553 | |
| 554 | # Configure mocks |
| 555 | mock_tracing_core.start_trace.return_value = mock_trace_context |
| 556 | |
| 557 | # Initialize with test API key |
| 558 | agentops.init(api_key="test-api-key") |
| 559 | |
| 560 | # Create a session |
| 561 | session = agentops.start_session(tags=["test", "crewai-kwargs"]) |
| 562 | assert isinstance(session, Session) |
| 563 | |
| 564 | # Test the CrewAI < 0.105.0 pattern - calling end_session with only kwargs |
| 565 | agentops.end_session(end_state="Success", end_state_reason="Finished Execution", is_auto_end=True) |
| 566 | |
| 567 | # After calling end_session, creating a new session should work correctly |
| 568 | # (this implicitly tests that the internal state is reset properly) |
| 569 | new_session = agentops.start_session(tags=["test", "post-end"]) |
| 570 | assert isinstance(new_session, Session) |
| 571 | |
| 572 | |
| 573 | def test_crewai_kwargs_pattern_no_session(mock_tracing_core, mock_api_client, reset_client): |
nothing calls this directly
no test coverage detected
searching dependent graphs…