Skip to content

Commit 09226e3

Browse files
CopilottheCyberTech
andcommitted
Add comprehensive encryption initialization logging to address visibility concerns
Co-authored-by: theCyberTech <84775494+theCyberTech@users.noreply.github.com>
1 parent 67398db commit 09226e3

3 files changed

Lines changed: 42 additions & 0 deletions

File tree

src/crewai/agents/agent_builder/base_agent.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import logging
12
import uuid
23
from abc import ABC, abstractmethod
34
from copy import copy as shallow_copy
@@ -30,6 +31,8 @@
3031

3132
T = TypeVar("T", bound="BaseAgent")
3233

34+
logger = logging.getLogger(__name__)
35+
3336

3437
class BaseAgent(ABC, BaseModel):
3538
"""Abstract Base Class for all third party agents compatible with CrewAI.
@@ -217,6 +220,12 @@ def validate_and_set_attributes(self):
217220
if self.security_config is None:
218221
self.security_config = SecurityConfig()
219222

223+
# Log encryption status for agent initialization
224+
if hasattr(self.security_config, 'encrypted_communication') and self.security_config.encrypted_communication:
225+
logger.info(f"Agent '{self.role}' initialized with encrypted communication enabled (fingerprint: {self.security_config.fingerprint.uuid_str[:8]}...)")
226+
else:
227+
logger.debug(f"Agent '{self.role}' initialized with encrypted communication disabled")
228+
220229
return self
221230

222231
@field_validator("id", mode="before")

src/crewai/crew.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import asyncio
22
import json
3+
import logging
34
import re
45
import uuid
56
import warnings
@@ -89,6 +90,8 @@
8990

9091
warnings.filterwarnings("ignore", category=SyntaxWarning, module="pysbd")
9192

93+
logger = logging.getLogger(__name__)
94+
9295

9396
class Crew(FlowTrackable, BaseModel):
9497
"""
@@ -381,6 +384,20 @@ def check_config(self):
381384
self._setup_from_config()
382385

383386
if self.agents:
387+
# Count agents with encryption enabled
388+
encryption_enabled_agents = [
389+
agent for agent in self.agents
390+
if hasattr(agent, 'security_config')
391+
and agent.security_config
392+
and getattr(agent.security_config, 'encrypted_communication', False)
393+
]
394+
395+
if encryption_enabled_agents:
396+
logger.info(f"Crew initialized with {len(encryption_enabled_agents)} agent(s) having encrypted communication enabled: {[agent.role for agent in encryption_enabled_agents]}")
397+
logger.info("Agent-to-agent communication will be automatically encrypted when using delegation tools")
398+
else:
399+
logger.debug(f"Crew initialized with {len(self.agents)} agent(s) - encrypted communication disabled for all agents")
400+
384401
for agent in self.agents:
385402
if self.cache:
386403
agent.set_cache_handler(self._cache_handler)

src/crewai/tools/agent_tools/agent_tools.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
from crewai.agents.agent_builder.base_agent import BaseAgent
22
from crewai.tools.base_tool import BaseTool
33
from crewai.utilities import I18N
4+
import logging
45

56
from .ask_question_tool import AskQuestionTool
67
from .delegate_work_tool import DelegateWorkTool
78

9+
logger = logging.getLogger(__name__)
10+
811

912
class AgentTools:
1013
"""Manager class for agent-related tools"""
@@ -16,6 +19,19 @@ def __init__(self, agents: list[BaseAgent], i18n: I18N = I18N()):
1619
def tools(self) -> list[BaseTool]:
1720
"""Get all available agent tools"""
1821
coworkers = ", ".join([f"{agent.role}" for agent in self.agents])
22+
23+
# Check encryption capabilities of agents
24+
encryption_enabled_agents = [
25+
agent for agent in self.agents
26+
if hasattr(agent, 'security_config')
27+
and agent.security_config
28+
and getattr(agent.security_config, 'encrypted_communication', False)
29+
]
30+
31+
if encryption_enabled_agents:
32+
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]}")
33+
else:
34+
logger.debug(f"Creating agent communication tools without encryption (no agents have encrypted_communication enabled)")
1935

2036
delegate_tool = DelegateWorkTool(
2137
agents=self.agents,

0 commit comments

Comments
 (0)