From 1e8e0728622914977617de56420452b9a359857b Mon Sep 17 00:00:00 2001 From: "claude[bot]" <41898282+claude[bot]@users.noreply.github.com> Date: Thu, 25 Sep 2025 23:38:31 +0000 Subject: [PATCH] fix(blocks): Update AIConditionBlock error output to follow system pattern - Changed field name from 'error_message' to 'error' exactly - Removed default value from error field (system behavior) - Modified run method to yield 'error' only when errors occur - Updated test_output to match new behavior This aligns with the standard error handling pattern used by other blocks in the platform where error outputs have no default and are yielded conditionally. Co-authored-by: Nicholas Tindle --- .../backend/backend/blocks/ai_condition.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/autogpt_platform/backend/backend/blocks/ai_condition.py b/autogpt_platform/backend/backend/blocks/ai_condition.py index 6cd9ba7a37..18f9046a57 100644 --- a/autogpt_platform/backend/backend/blocks/ai_condition.py +++ b/autogpt_platform/backend/backend/blocks/ai_condition.py @@ -60,9 +60,8 @@ class AIConditionBlock(AIBlockBase): no_output: Any = SchemaField( description="The output value if the condition is false" ) - error_message: str = SchemaField( - description="Error message if the AI evaluation is uncertain or fails", - default="", + error: str = SchemaField( + description="Error message if the AI evaluation is uncertain or fails" ) def __init__(self): @@ -84,7 +83,6 @@ class AIConditionBlock(AIBlockBase): test_output=[ ("result", True), ("yes_output", "Valid email"), - ("error_message", ""), ], test_mock={ "llm_call": lambda *args, **kwargs: LLMResponse( @@ -135,7 +133,6 @@ class AIConditionBlock(AIBlockBase): # Convert input_value to string for AI evaluation input_str = str(input_data.input_value) - error_message = "" # Track error messages # Create the prompt for AI evaluation prompt = [ @@ -185,9 +182,9 @@ class AIConditionBlock(AIBlockBase): elif tokens == {"false"} or tokens == {"no"} or tokens == {"0"}: result = False else: - # Unclear or conflicting response - default to False and set error + # Unclear or conflicting response - default to False and yield error result = False - error_message = f"Unclear AI response: '{response.response}'" + yield "error", f"Unclear AI response: '{response.response}'" # Update internal stats self.merge_stats( @@ -201,12 +198,12 @@ class AIConditionBlock(AIBlockBase): except Exception as e: # In case of any error, default to False to be safe result = False - error_message = f"AI evaluation failed: {str(e)}" # Log the error but don't fail the block execution import logging logger = logging.getLogger(__name__) logger.error(f"AI condition evaluation failed: {str(e)}") + yield "error", f"AI evaluation failed: {str(e)}" # Yield results yield "result", result @@ -215,6 +212,3 @@ class AIConditionBlock(AIBlockBase): yield "yes_output", yes_value else: yield "no_output", no_value - - # Always yield error_message (empty string if no error) - yield "error_message", error_message