Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks.
fix: refactor use_stop_words to property, add check for stop words
Greyson LaLonde2e9eb8c32dc7
diff --git a/lib/crewai/src/crewai/agents/crew_agent_executor.py b/lib/crewai/src/crewai/agents/crew_agent_executor.pyindex 07db1de0a..d2ae7fd00 100644--- a/lib/crewai/src/crewai/agents/crew_agent_executor.py+++ b/lib/crewai/src/crewai/agents/crew_agent_executor.py@@ -119,7 +119,6 @@ class CrewAgentExecutor(CrewAgentExecutorMixin):self.tools_handler = tools_handlerself.original_tools = original_tools or []self.step_callback = step_callback- self.use_stop_words = self.llm.supports_stop_words()self.tools_description = tools_descriptionself.function_calling_llm = function_calling_llmself.respect_context_window = respect_context_window@@ -128,14 +127,25 @@ class CrewAgentExecutor(CrewAgentExecutorMixin):self.messages: list[LLMMessage] = []self.iterations = 0self.log_error_after = 3- existing_stop = getattr(self.llm, "stop", [])- self.llm.stop = list(- set(- existing_stop + self.stop- if isinstance(existing_stop, list)- else self.stop+ if self.llm:+ # This may be mutating the shared llm object and needs further evaluation+ existing_stop = getattr(self.llm, "stop", [])+ self.llm.stop = list(+ set(+ existing_stop + self.stop+ if isinstance(existing_stop, list)+ else self.stop+ ))- )++ @property+ def use_stop_words(self) -> bool:+ """Check to determine if stop words are being used.++ Returns:+ bool: True if tool should be used or not.+ """+ return self.llm.supports_stop_words() if self.llm else Falsedef invoke(self, inputs: dict[str, Any]) -> dict[str, Any]:"""Execute the agent with given inputs.