AgentOps-AI / agentops

Python SDK for agent monitoring, LLM cost tracking, benchmarking, and more. Integrates with most LLMs and agent frameworks like CrewAI, Langchain, and Autogen
https://agentops.ai
MIT License
1.18k stars 93 forks source link

instrument_llm_calls=False + stop_instrumenting() will raise on missing llm_tracker #256

Open mbarnathan opened 2 weeks ago

mbarnathan commented 2 weeks ago

🐛 Bug Report

🔎 Describe the Bug If you start up an agentops client with instrument_llm_calls false and stop_instrumenting() gets called, whether implicitly via Crew/Autogen or explicitly by the caller, client.py will try to reference an undefined self.llm_tracker member and throw. (Even though it is checked for truthiness, only getattr/hasattr will work when the value isn't set at all)

The fix is to explicitly set llm_tracker to None in the constructor, which will make the check later work properly with a falsy value. I will submit a fix.