Skip to content

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

Adding session_id to developer_errors (#210)

Howard Gil7fd7d106ca0e
diff --git a/agentops/meta_client.py b/agentops/meta_client.py
index b95973fa..68b84060 100644
--- a/agentops/meta_client.py
+++ b/agentops/meta_client.py
@@ -19,7 +19,7 @@ class MetaClient(type):
return super().__new__(cls, name, bases, dct)
- def send_exception_to_server(cls, exception, api_key):
+ def send_exception_to_server(cls, exception, api_key, session):
"""Class method to send exception to server."""
if api_key:
exception_type = type(exception).__name__
@@ -33,6 +33,9 @@ class MetaClient(type):
"host_env": get_host_env()
}
+ if session:
+ developer_error["session_id"] = session.session_id
+
HttpClient.post("https://api.agentops.ai/developer_errors",
safe_serialize(developer_error).encode("utf-8"),
api_key=api_key)
@@ -48,7 +51,7 @@ def handle_exceptions(method):
logger.warning(f"🖇 AgentOps: Error: {e}")
config = getattr(self, 'config', None)
if config is not None:
- type(self).send_exception_to_server(e, self.config._api_key)
+ type(self).send_exception_to_server(e, self.config._api_key, self._session)
raise e
return wrapper