Python SDK for AI agent monitoring, LLM cost tracking, benchmarking, and more. Integrates with most LLMs and agent frameworks including CrewAI, Agno, OpenAI Agents SDK, Langchain, Autogen, AG2, and CamelAI
Python agentagentopsagents-sdkaianthropicautogencost-estimationcrewaievalsevaluation-metricsgroqlangchainllmmistralollamaopenaiopenai-agents
Setting session to none if server does not return 200 for /sessions (#142)
Howard Gila30837aeab83
diff --git a/agentops/client.py b/agentops/client.pyindex a124a2d4..cbb78337 100644--- a/agentops/client.py+++ b/agentops/client.py@@ -212,7 +212,11 @@ class Client(metaclass=MetaClient):self._session = Session(uuid4(), tags or self._tags, host_env=get_host_env())self._worker = Worker(config or self.config)- self._worker.start_session(self._session)+ start_session_result = self._worker.start_session(self._session)+ if not start_session_result:+ self._session = None+ return logging.warning("AgentOps: Cannot start session")+logging.info('View info on this session at https://app.agentops.ai/drilldown?session_id={}'.format(self._session.session_id))diff --git a/agentops/worker.py b/agentops/worker.pyindex d409ee10..6b7320ef 100644--- a/agentops/worker.py+++ b/agentops/worker.py@@ -49,10 +49,15 @@ class Worker:"session": session.__dict__}serialized_payload = json.dumps(filter_unjsonable(payload)).encode("utf-8")- HttpClient.post(f'{self.config.endpoint}/sessions',- serialized_payload,- self.config.api_key,- self.config.parent_key)+ res = HttpClient.post(f'{self.config.endpoint}/sessions',+ serialized_payload,+ self.config.api_key,+ self.config.parent_key)++ if res.code != 200:+ return False++ return Truedef end_session(self, session: Session) -> None:self.stop_flag.set()