diff --git a/agentops/session.py b/agentops/session.py index cb9359d3..cd75fa53 100644 --- a/agentops/session.py +++ b/agentops/session.py @@ -248,7 +248,7 @@ def __init__( "errors": 0, "apis": 0, } - self.session_url: Optional[str] = None + # self.session_url: Optional[str] = None # Start session first to get JWT self.is_running = self._start_session() @@ -530,14 +530,9 @@ def _start_session(self): if jwt is None: return False - session_url = res.body.get( - "session_url", - f"https://app.agentops.ai/drilldown?session_id={self.session_id}", - ) - logger.info( colored( - f"\x1b[34mSession Replay: {session_url}\x1b[0m", + f"\x1b[34mSession Replay: {self.session_url}\x1b[0m", "blue", ) ) @@ -656,11 +651,6 @@ def get_analytics(self) -> Optional[Dict[str, Any]]: self.token_cost = self._get_token_cost(response) formatted_cost = self._format_token_cost(self.token_cost) - self.session_url = response.body.get( - "session_url", - f"https://app.agentops.ai/drilldown?session_id={self.session_id}", - ) - return { "LLM calls": self.event_counts["llms"], "Tool calls": self.event_counts["tools"], @@ -670,5 +660,15 @@ def get_analytics(self) -> Optional[Dict[str, Any]]: "Cost": formatted_cost, } + @property + def session_url(self) -> str: + """Returns the URL for this session in the AgentOps dashboard.""" + assert self.session_id, "Session ID is required to generate a session URL" + return f"https://app.agentops.ai/drilldown?session_id={self.session_id}" + + # @session_url.setter + # def session_url(self, url: str): + # pass + active_sessions: List[Session] = []