MCPcopy Create free account
hub / github.com/AgentOps-AI/agentops / test_crewai_kwargs_pattern

Function test_crewai_kwargs_pattern

tests/unit/test_session.py:540–570  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

538
539
540def 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
573def test_crewai_kwargs_pattern_no_session(mock_tracing_core, mock_api_client, reset_client):

Callers

nothing calls this directly

Calls 3

initMethod · 0.80
start_sessionMethod · 0.45
end_sessionMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…