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

Propagating exceptions

Howard Gil48227e7ccec7
diff --git a/agentops/client.py b/agentops/client.py
index dd197df6..b9d9613f 100644
--- a/agentops/client.py
+++ b/agentops/client.py
@@ -157,7 +157,6 @@ class Client(metaclass=MetaClient):
action_type=event_name)
try:
- self.record(event) # REMOVE
returns = func(*args, **kwargs)
# If the function returns multiple values, record them all in the same event
@@ -165,6 +164,10 @@ class Client(metaclass=MetaClient):
returns = list(returns)
event.returns = returns
+
+ # TODO: If we except this will never get called here
+ # the dev loses all the useful stuff they would need for debugging
+ # maybe we could have Error post the supplied event to supabase
self.record(event)
except Exception as e:
@@ -194,8 +197,6 @@ class Client(metaclass=MetaClient):
action_type=event_name)
try:
- self.record(event) # REMOVE
-
returns = await func(*args, **kwargs)
# If the function returns multiple values, record them all in the same event
@@ -203,6 +204,10 @@ class Client(metaclass=MetaClient):
returns = list(returns)
event.returns = returns
+
+ # TODO: If we except this will never get called here
+ # the dev loses all the useful stuff they would need for debugging
+ # maybe we could have Error post the supplied event to supabase
self.record(event)
except Exception as e:
diff --git a/agentops/meta_client.py b/agentops/meta_client.py
index 63c4f574..1de567ee 100644
--- a/agentops/meta_client.py
+++ b/agentops/meta_client.py
@@ -33,8 +33,7 @@ class MetaClient(type):
"host_env": get_host_env()
}
- endpoint = environ.get('AGENTOPS_API_ENDPOINT', 'https://api.agentops.ai') # TODO
- HttpClient.post(endpoint+"/developer_errors",
+ HttpClient.post("https://api.agentops.ai/developer_errors",
safe_serialize(developer_error).encode("utf-8"),
api_key=api_key)
@@ -48,7 +47,7 @@ def handle_exceptions(method):
except Exception as e:
type(self).send_exception_to_server(e, self.config._api_key)
logging.warning(f"AgentOps: Error: {e}")
- # raise e
+ raise e
return wrapper