diff --git a/src/crewai/agents/agent_builder/base_agent.py b/src/crewai/agents/agent_builder/base_agent.py index ba2596f63..d8bb7bf14 100644 --- a/src/crewai/agents/agent_builder/base_agent.py +++ b/src/crewai/agents/agent_builder/base_agent.py @@ -1,3 +1,4 @@ +import logging import uuid from abc import ABC, abstractmethod from copy import copy as shallow_copy @@ -30,6 +31,8 @@ from crewai.utilities.string_utils import interpolate_only T = TypeVar("T", bound="BaseAgent") +logger = logging.getLogger(__name__) + class BaseAgent(ABC, BaseModel): """Abstract Base Class for all third party agents compatible with CrewAI. @@ -217,6 +220,12 @@ class BaseAgent(ABC, BaseModel): if self.security_config is None: self.security_config = SecurityConfig() + # Log encryption status for agent initialization + if hasattr(self.security_config, 'encrypted_communication') and self.security_config.encrypted_communication: + logger.info(f"Agent '{self.role}' initialized with encrypted communication enabled (fingerprint: {self.security_config.fingerprint.uuid_str[:8]}...)") + else: + logger.debug(f"Agent '{self.role}' initialized with encrypted communication disabled") + return self @field_validator("id", mode="before") diff --git a/src/crewai/crew.py b/src/crewai/crew.py index 5e654463c..63bbdbd52 100644 --- a/src/crewai/crew.py +++ b/src/crewai/crew.py @@ -1,5 +1,6 @@ import asyncio import json +import logging import re import uuid import warnings @@ -89,6 +90,8 @@ from crewai.utilities.training_handler import CrewTrainingHandler warnings.filterwarnings("ignore", category=SyntaxWarning, module="pysbd") +logger = logging.getLogger(__name__) + class Crew(FlowTrackable, BaseModel): """ @@ -381,6 +384,20 @@ class Crew(FlowTrackable, BaseModel): self._setup_from_config() if self.agents: + # Count agents with encryption enabled + encryption_enabled_agents = [ + agent for agent in self.agents + if hasattr(agent, 'security_config') + and agent.security_config + and getattr(agent.security_config, 'encrypted_communication', False) + ] + + if encryption_enabled_agents: + logger.info(f"Crew initialized with {len(encryption_enabled_agents)} agent(s) having encrypted communication enabled: {[agent.role for agent in encryption_enabled_agents]}") + logger.info("Agent-to-agent communication will be automatically encrypted when using delegation tools") + else: + logger.debug(f"Crew initialized with {len(self.agents)} agent(s) - encrypted communication disabled for all agents") + for agent in self.agents: if self.cache: agent.set_cache_handler(self._cache_handler) diff --git a/src/crewai/tools/agent_tools/agent_tools.py b/src/crewai/tools/agent_tools/agent_tools.py index 77d3c2d89..cc441babe 100644 --- a/src/crewai/tools/agent_tools/agent_tools.py +++ b/src/crewai/tools/agent_tools/agent_tools.py @@ -1,10 +1,13 @@ from crewai.agents.agent_builder.base_agent import BaseAgent from crewai.tools.base_tool import BaseTool from crewai.utilities import I18N +import logging from .ask_question_tool import AskQuestionTool from .delegate_work_tool import DelegateWorkTool +logger = logging.getLogger(__name__) + class AgentTools: """Manager class for agent-related tools""" @@ -16,6 +19,19 @@ class AgentTools: def tools(self) -> list[BaseTool]: """Get all available agent tools""" coworkers = ", ".join([f"{agent.role}" for agent in self.agents]) + + # Check encryption capabilities of agents + encryption_enabled_agents = [ + agent for agent in self.agents + if hasattr(agent, 'security_config') + and agent.security_config + and getattr(agent.security_config, 'encrypted_communication', False) + ] + + if encryption_enabled_agents: + logger.info(f"Creating agent communication tools with encryption support for {len(encryption_enabled_agents)} agent(s): {[agent.role for agent in encryption_enabled_agents]}") + else: + logger.debug(f"Creating agent communication tools without encryption (no agents have encrypted_communication enabled)") delegate_tool = DelegateWorkTool( agents=self.agents,