From 7fb57a190339783e60cd657746520d85ad51bfb9 Mon Sep 17 00:00:00 2001 From: uid7860 Date: Thu, 29 May 2025 15:26:05 +0900 Subject: [PATCH] fix: handle Agent Node raising Attribute Error --- api/core/workflow/nodes/agent/agent_node.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/api/core/workflow/nodes/agent/agent_node.py b/api/core/workflow/nodes/agent/agent_node.py index 9bed8862fc..6d20c28c72 100644 --- a/api/core/workflow/nodes/agent/agent_node.py +++ b/api/core/workflow/nodes/agent/agent_node.py @@ -159,7 +159,15 @@ class AgentNode(ToolNode): # variable_pool.convert_template returns a string, # so we need to convert it back to a dictionary try: - parameter_value = json.loads(parameter_value) + import re + + def sanitize_json_string(s): + # Replace smart quotes, sanitize control characters if needed + s = s.replace("\x00", "") # Null byte + s = re.sub(r"[\x01-\x1F]+", "", s) # Strip most control characters + return s + + parameter_value = json.loads(sanitize_json_string(parameter_value)) except json.JSONDecodeError: parameter_value = parameter_value else: