From 48604f567b3e588a779ffa88cd4494ba2c1526d6 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Wed, 12 Feb 2025 06:27:56 +0000 Subject: [PATCH] fix: Improve agentops initialization with better validation and logging Co-Authored-By: Joe Moura --- src/crewai/crew.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/crewai/crew.py b/src/crewai/crew.py index f72fac30e..8f918bee3 100644 --- a/src/crewai/crew.py +++ b/src/crewai/crew.py @@ -253,10 +253,15 @@ class Crew(BaseModel): # Initialize agentops if available and API key is present if agentops: api_key = os.getenv("AGENTOPS_API_KEY") - if api_key: + if api_key and api_key.strip(): # Validate API key try: agentops.init(api_key) - except Exception as e: + self._logger.log( + "info", + "Successfully initialized agentops", + color="green" + ) + except (ConnectionError, ValueError) as e: self._logger.log( "warning", f"Failed to initialize agentops: {e}",