From c2f7be37b3104d3248b3203fc7d0fd920d128346 Mon Sep 17 00:00:00 2001 From: SHIYAO ZHANG <834247613@qq.com> Date: Tue, 31 Mar 2026 22:05:23 +0800 Subject: [PATCH] fix(tools): move sandbox.tools import in view_image_tool to break circular import (#1674) view_image_tool.py had a top-level import of deerflow.sandbox.tools, which created a circular dependency chain: sandbox.tools -> deerflow.agents.thread_state (triggers agents/__init__.py) -> agents/factory.py -> tools/builtins/__init__.py -> view_image_tool.py -> deerflow.sandbox.tools <-- circular! This caused ImportError when any test directly imported sandbox.tools, making test_sandbox_tools_security.py fail to collect since #1522. Fix: move the sandbox.tools import inside the view_image_tool function body. Co-authored-by: Claude Sonnet 4.6 --- .../harness/deerflow/tools/builtins/view_image_tool.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/packages/harness/deerflow/tools/builtins/view_image_tool.py b/backend/packages/harness/deerflow/tools/builtins/view_image_tool.py index 21d662373..e47ab1938 100644 --- a/backend/packages/harness/deerflow/tools/builtins/view_image_tool.py +++ b/backend/packages/harness/deerflow/tools/builtins/view_image_tool.py @@ -9,7 +9,6 @@ from langgraph.types import Command from langgraph.typing import ContextT from deerflow.agents.thread_state import ThreadState -from deerflow.sandbox.tools import get_thread_data, replace_virtual_path @tool("view_image", parse_docstring=True) @@ -32,6 +31,8 @@ def view_image_tool( Args: image_path: Absolute path to the image file. Common formats supported: jpg, jpeg, png, webp. """ + from deerflow.sandbox.tools import get_thread_data, replace_virtual_path + # Replace virtual path with actual path # /mnt/user-data/* paths are mapped to thread-specific directories thread_data = get_thread_data(runtime)