From a0f19c21084e49ac2674269188010fe0be15ad2e Mon Sep 17 00:00:00 2001
From: OpenClaw <openclaw@proton.me>
Date: Wed, 4 Feb 2026 02:45:11 +0100
Subject: [PATCH] fix: handle ConverterError in long-term memory evaluation

The isinstance(evaluation, ConverterError) check was unreachable because
Converter.to_pydantic() raises ConverterError rather than returning it.

This caused the 'str' object has no attribute 'quality' error reported
in issue #1222 - when the LLM output couldn't be parsed into a
TaskEvaluation model, the exception propagated up as an AttributeError
instead of being caught cleanly.

Fix: Catch ConverterError explicitly in the exception handler.

Fixes #1222
---
 .../agents/agent_builder/base_agent_executor_mixin.py     | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lib/crewai/src/crewai/agents/agent_builder/base_agent_executor_mixin.py b/lib/crewai/src/crewai/agents/agent_builder/base_agent_executor_mixin.py
index c9dceaa..ddfcc19 100644
--- a/lib/crewai/src/crewai/agents/agent_builder/base_agent_executor_mixin.py
+++ b/lib/crewai/src/crewai/agents/agent_builder/base_agent_executor_mixin.py
@@ -91,9 +91,6 @@ class CrewAgentExecutorMixin:
                 ltm_agent = TaskEvaluator(self.agent)
                 evaluation = ltm_agent.evaluate(self.task, output.text)
 
-                if isinstance(evaluation, ConverterError):
-                    return
-
                 long_term_memory = LongTermMemoryItem(
                     task=self.task.description,
                     agent=self.agent.role,
@@ -120,6 +117,11 @@ class CrewAgentExecutorMixin:
                 ]
                 if entity_memories:
                     self.crew._entity_memory.save(entity_memories)
+            except ConverterError as e:
+                # LLM failed to parse evaluation into TaskEvaluation model
+                self.agent._logger.log(
+                    "debug", f"Could not evaluate task for long term memory: {e}"
+                )
             except AttributeError as e:
                 self.agent._logger.log(
                     "error", f"Missing attributes for long term memory: {e}"
-- 
2.43.0

