2121
2222class Session :
2323 """
24- A session object that holds a span and token for OpenTelemetry tracing.
25-
2624 This class provides compatibility with CrewAI >= 0.105.0, which uses an event-based
2725 integration pattern where it calls methods directly on the Session object:
2826
@@ -67,7 +65,6 @@ def end_session(self, **kwargs):
6765 - end_state="Success"
6866 - end_state_reason="Finished Execution"
6967
70- This implementation properly ends the OpenTelemetry span and
7168 forces a flush to ensure the span is exported immediately.
7269 """
7370 _set_span_attributes (self .span , kwargs )
@@ -80,7 +77,6 @@ def _create_session_span(tags: Union[Dict[str, Any], List[str], None] = None) ->
8077 Helper function to create a session span with tags.
8178
8279 This is an internal function used by start_session() to create the
83- OpenTelemetry span for the session. It uses the _make_span utility
8480 from the SDK to create a span with kind=SpanKind.SESSION.
8581
8682 Args:
@@ -89,7 +85,6 @@ def _create_session_span(tags: Union[Dict[str, Any], List[str], None] = None) ->
8985
9086 Returns:
9187 A tuple of (span, context, token) where:
92- - span is the OpenTelemetry span object
9388 - context is the span context
9489 - token is the context token needed for detaching
9590 """
@@ -105,6 +100,7 @@ def start_session(
105100 tags : Union [Dict [str , Any ], List [str ], None ] = None ,
106101) -> Session :
107102 """
103+ @deprecated
108104 Start a new AgentOps session manually.
109105
110106 This function creates and starts a new session span, which can be used to group
@@ -160,12 +156,8 @@ def _set_span_attributes(span: Any, attributes: Dict[str, Any]) -> None:
160156def _flush_span_processors () -> None :
161157 """
162158 Helper to force flush all span processors.
163-
164- Returns:
165- True if flush was successful, False otherwise
166159 """
167160 try :
168- # Use OpenTelemetry API directly to force flush
169161 from opentelemetry .trace import get_tracer_provider
170162 tracer_provider = get_tracer_provider ()
171163 tracer_provider .force_flush ()
@@ -175,6 +167,7 @@ def _flush_span_processors() -> None:
175167
176168def end_session (session_or_status : Any = None , ** kwargs ) -> None :
177169 """
170+ @deprecated
178171 End a previously started AgentOps session.
179172
180173 This function ends the session span and detaches the context token,
@@ -219,15 +212,11 @@ def end_session(session_or_status: Any = None, **kwargs) -> None:
219212 if session_or_status is None and kwargs :
220213 global _current_session
221214
222- # Use the globally stored session if available
223215 if _current_session is not None :
224216 _set_span_attributes (_current_session .span , kwargs )
225217 _finalize_span (_current_session .span , _current_session .token )
226218 _flush_span_processors ()
227219 _current_session = None
228- else :
229- logger .warning ("CrewAI called end_session with kwargs, but no global session was found" )
230-
231220 return
232221
233222 # Handle the standard pattern and CrewAI >= 0.105.0 pattern where a Session object is passed.
@@ -240,7 +229,12 @@ def end_session(session_or_status: Any = None, **kwargs) -> None:
240229
241230
242231def end_all_sessions ():
243- pass
232+ """
233+ @deprecated
234+ We don't automatically track more than one session, so just end the session
235+ that we are tracking.
236+ """
237+ end_session ()
244238
245239
246240def ToolEvent (* args , ** kwargs ) -> None :
@@ -306,8 +300,13 @@ def noop(f):
306300
307301
308302def track_tool (* args , ** kwargs ):
309- """@deprecated"""
310- pass
303+ """
304+ @deprecated
305+ Decorator for marking tools and legacy projects.
306+ """
307+ def noop (f ):
308+ return f
309+ return noop
311310
312311
313312__all__ = [
0 commit comments