diff --git a/api/core/workflow/nodes/agent/agent_node.py b/api/core/workflow/nodes/agent/agent_node.py index 5ab17661b7..ee1b1e1dd2 100644 --- a/api/core/workflow/nodes/agent/agent_node.py +++ b/api/core/workflow/nodes/agent/agent_node.py @@ -299,22 +299,7 @@ class AgentNode(ToolNode): ) if uses_sys_files_for_node: - - def _strip_files_from_history(messages: list[dict[str, Any]]) -> list[dict[str, Any]]: - stripped: list[dict[str, Any]] = [] - for m in messages: - if m.get("role") == "user" and isinstance(m.get("content"), list): - contents = [ - c - for c in m["content"] - if not (isinstance(c, dict) and c.get("type") and c.get("type") != "text") - ] - if not contents: - contents = [] - m = {**m, "content": contents} - stripped.append(m) - return stripped - + # History already stripped once above; ensure it's stripped (idempotent call) history_prompt_messages = _strip_files_from_history(history_prompt_messages) if model_schema: