mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-15 11:08:33 +00:00
Fix issues
This commit is contained in:
@@ -175,10 +175,8 @@ class Agent(BaseAgent):
|
||||
Returns:
|
||||
Output of the agent
|
||||
"""
|
||||
# The RPM controller is now managed by the Crew, so no need to set it here.
|
||||
if self.tools_handler:
|
||||
self.tools_handler.last_used_tool = {} # type: ignore # Incompatible types in assignment (expression has type "dict[Never, Never]", variable has type "ToolCalli
|
||||
|
||||
task_prompt = task.prompt()
|
||||
|
||||
# If the task requires output in JSON or Pydantic format,
|
||||
|
||||
@@ -380,5 +380,6 @@ class BaseAgent(ABC, BaseModel):
|
||||
"""
|
||||
if self.cache:
|
||||
self.set_cache_handler(cache_handler)
|
||||
if self.max_rpm:
|
||||
self.set_rpm_controller()
|
||||
# Use the injected RPM controller rather than auto-creating one
|
||||
if rpm_controller:
|
||||
self.set_rpm_controller(rpm_controller)
|
||||
|
||||
@@ -255,6 +255,29 @@ class Crew(BaseModel):
|
||||
self._telemetry.set_tracer()
|
||||
return self
|
||||
|
||||
@model_validator(mode="after")
|
||||
def initialize_dependencies(self) -> "Crew":
|
||||
# Create a cache handler if caching is enabled
|
||||
if self.cache:
|
||||
self._cache_handler = CacheHandler()
|
||||
else:
|
||||
self._cache_handler = None
|
||||
|
||||
# Create the Crew-level RPM controller if a max RPM is specified
|
||||
if self.max_rpm is not None:
|
||||
self._rpm_controller = RPMController(
|
||||
max_rpm=self.max_rpm, logger=Logger(verbose=self.verbose)
|
||||
)
|
||||
else:
|
||||
self._rpm_controller = None
|
||||
|
||||
# Now inject these external dependencies into each agent
|
||||
for agent in self.agents:
|
||||
agent.crew = self # ensure the agent's crew reference is set
|
||||
agent.configure_executor(self._cache_handler, self._rpm_controller)
|
||||
|
||||
return self
|
||||
|
||||
@model_validator(mode="after")
|
||||
def create_crew_memory(self) -> "Crew":
|
||||
"""Set private attributes."""
|
||||
|
||||
@@ -9,7 +9,6 @@ from unittest.mock import MagicMock, patch
|
||||
import instructor
|
||||
import pydantic_core
|
||||
import pytest
|
||||
|
||||
from crewai.agent import Agent
|
||||
from crewai.agents.cache import CacheHandler
|
||||
from crewai.crew import Crew
|
||||
@@ -541,9 +540,8 @@ def test_crew_with_delegating_agents():
|
||||
def test_crew_with_delegating_agents_should_not_override_task_tools():
|
||||
from typing import Type
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from crewai.tools import BaseTool
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
class TestToolInput(BaseModel):
|
||||
"""Input schema for TestTool."""
|
||||
@@ -603,9 +601,8 @@ def test_crew_with_delegating_agents_should_not_override_task_tools():
|
||||
def test_crew_with_delegating_agents_should_not_override_agent_tools():
|
||||
from typing import Type
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from crewai.tools import BaseTool
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
class TestToolInput(BaseModel):
|
||||
"""Input schema for TestTool."""
|
||||
@@ -667,9 +664,8 @@ def test_crew_with_delegating_agents_should_not_override_agent_tools():
|
||||
def test_task_tools_override_agent_tools():
|
||||
from typing import Type
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from crewai.tools import BaseTool
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
class TestToolInput(BaseModel):
|
||||
"""Input schema for TestTool."""
|
||||
@@ -725,9 +721,8 @@ def test_task_tools_override_agent_tools_with_allow_delegation():
|
||||
"""
|
||||
from typing import Type
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from crewai.tools import BaseTool
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
class TestToolInput(BaseModel):
|
||||
query: str = Field(..., description="Query to process")
|
||||
@@ -3429,11 +3424,10 @@ def test_task_tools_preserve_code_execution_tools():
|
||||
"""
|
||||
from typing import Type
|
||||
|
||||
from crewai.tools import BaseTool
|
||||
from crewai_tools import CodeInterpreterTool
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from crewai.tools import BaseTool
|
||||
|
||||
class TestToolInput(BaseModel):
|
||||
"""Input schema for TestTool."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user