From f5dc745669d0827fb0f3450858f790b9229b71b5 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Sat, 28 Mar 2026 16:55:16 +0000 Subject: [PATCH] fix: set _last_execution_errored in add_image exception handlers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Address Cursor Bugbot review: the add_image exception handlers in use() and ause() were missing the error flag, allowing result_as_answer to be incorrectly honored when those paths errored. Co-Authored-By: João --- lib/crewai/src/crewai/tools/tool_usage.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/crewai/src/crewai/tools/tool_usage.py b/lib/crewai/src/crewai/tools/tool_usage.py index 92271c3d7..9433d7d37 100644 --- a/lib/crewai/src/crewai/tools/tool_usage.py +++ b/lib/crewai/src/crewai/tools/tool_usage.py @@ -158,6 +158,7 @@ class ToolUsage: except Exception as e: error = getattr(e, "message", str(e)) + self._last_execution_errored = True if self.task: self.task.increment_tools_errors() if self.agent and self.agent.verbose: @@ -210,6 +211,7 @@ class ToolUsage: ) except Exception as e: error = getattr(e, "message", str(e)) + self._last_execution_errored = True if self.task: self.task.increment_tools_errors() if self.agent and self.agent.verbose: