From 996bbad0d3d383dca5219deea5e36de4f730f0d1 Mon Sep 17 00:00:00 2001 From: Lorenze Jay Date: Mon, 31 Mar 2025 09:36:30 -0700 Subject: [PATCH] fix fingerprinting issues --- src/crewai/agent.py | 3 +++ src/crewai/utilities/tool_utils.py | 11 ++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/crewai/agent.py b/src/crewai/agent.py index 39c3c5d10..8c3efe464 100644 --- a/src/crewai/agent.py +++ b/src/crewai/agent.py @@ -445,3 +445,6 @@ class Agent(BaseAgent): Fingerprint: The agent's fingerprint """ return self.security_config.fingerprint + + def set_fingerprint(self, fingerprint: Fingerprint): + self.security_config.fingerprint = fingerprint diff --git a/src/crewai/utilities/tool_utils.py b/src/crewai/utilities/tool_utils.py index 542444416..2b26ca83b 100644 --- a/src/crewai/utilities/tool_utils.py +++ b/src/crewai/utilities/tool_utils.py @@ -1,6 +1,7 @@ from typing import Any, Dict, List, Optional from crewai.agents.parser import AgentAction +from crewai.security import Fingerprint from crewai.tools.structured_tool import CrewStructuredTool from crewai.tools.tool_types import ToolResult from crewai.tools.tool_usage import ToolUsage, ToolUsageErrorException @@ -48,7 +49,15 @@ def execute_tool_and_check_finality( if agent_key and agent_role and agent: fingerprint_context = fingerprint_context or {} if agent: - agent.fingerprint = fingerprint_context + if hasattr(agent, "set_fingerprint") and callable( + agent.set_fingerprint + ): + if isinstance(fingerprint_context, dict): + try: + fingerprint_obj = Fingerprint.from_dict(fingerprint_context) + agent.set_fingerprint(fingerprint_obj) + except Exception as e: + raise ValueError(f"Failed to set fingerprint: {e}") event_data = { "agent_key": agent_key,