Add comprehensive encryption initialization logging to address visibility concerns

Co-authored-by: theCyberTech <84775494+theCyberTech@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-08-13 05:18:15 +00:00
parent 67398db656
commit 09226e34b2
3 changed files with 42 additions and 0 deletions

View File

@@ -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")

View File

@@ -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)

View File

@@ -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"""
@@ -17,6 +20,19 @@ class AgentTools:
"""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,
i18n=self.i18n,