Bugfix/kickoff hangs when llm call fails (#1943)

* Wip to address https://github.com/crewAIInc/crewAI/issues/1934

* implement proper try / except

* clean up PR

* add tests

* Fix tests and code that was broken

* mnore clean up

* Fixing tests

* fix stop type errors]

* more fixes
This commit is contained in:
Brandon Hancock (bhancock_ai)
2025-01-22 14:24:00 -05:00
committed by GitHub
parent c642ebf97e
commit 67f0de1f90
6 changed files with 273 additions and 95 deletions

View File

@@ -3,6 +3,7 @@ import shutil
import subprocess
from typing import Any, Dict, List, Literal, Optional, Union
from litellm import AuthenticationError as LiteLLMAuthenticationError
from pydantic import Field, InstanceOf, PrivateAttr, model_validator
from crewai.agents import CacheHandler
@@ -261,6 +262,9 @@ class Agent(BaseAgent):
}
)["output"]
except Exception as e:
if isinstance(e, LiteLLMAuthenticationError):
# Do not retry on authentication errors
raise e
self._times_executed += 1
if self._times_executed > self.max_retry_limit:
raise e