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
allow host env opt out (#174)
Braelyn Boyntonc229b70f73e2
diff --git a/agentops/client.py b/agentops/client.pyindex cca33753..57a80df8 100644--- a/agentops/client.py+++ b/agentops/client.py@@ -4,7 +4,7 @@Classes:Client: Provides methods to interact with the AgentOps service."""-+import osfrom .event import ActionEvent, ErrorEvent, Eventfrom .enums import EndStatefrom .helpers import get_ISO_time, singleton, check_call_stack_for_agent_id@@ -76,6 +76,8 @@ class Client(metaclass=MetaClient):self._session = Noneself._worker = None+ self._env_data_opt_out = os.getenv('AGENTOPS_ENV_DATA_OPT_OUT') and os.getenv('AGENTOPS_ENV_DATA_OPT_OUT').lower() == 'true'+try:self.config = Configuration(api_key=api_key,parent_key=parent_key,@@ -236,7 +238,7 @@ class Client(metaclass=MetaClient):if not config and not self.config:return logger.warning("🖇 AgentOps: Cannot start session - missing configuration")- self._session = Session(inherited_session_id or uuid4(), tags or self._tags_for_future_session, host_env=get_host_env())+ self._session = Session(inherited_session_id or uuid4(), tags or self._tags_for_future_session, host_env=get_host_env(self._env_data_opt_out))self._worker = Worker(config or self.config)start_session_result = self._worker.start_session(self._session)if not start_session_result:diff --git a/agentops/host_env.py b/agentops/host_env.pyindex 42974a43..3b289033 100644--- a/agentops/host_env.py+++ b/agentops/host_env.py@@ -54,11 +54,17 @@ def get_disk_details():return disk_info-def get_host_env():- return {- "SDK": get_sdk_details(),- "OS": get_os_details(),- "CPU": get_cpu_details(),- "RAM": get_ram_details(),- "Disk": get_disk_details(),- }+def get_host_env(opt_out: bool = False):+ if opt_out:+ return {+ "SDK": get_sdk_details(),+ "OS": get_os_details()+ }+ else:+ return {+ "SDK": get_sdk_details(),+ "OS": get_os_details(),+ "CPU": get_cpu_details(),+ "RAM": get_ram_details(),+ "Disk": get_disk_details(),+ }