From 118485a7cb0242623937600200957247b5383a87 Mon Sep 17 00:00:00 2001 From: SHIYAO ZHANG <834247613@qq.com> Date: Sun, 29 Mar 2026 17:21:04 +0800 Subject: [PATCH] fix(sandbox): fall back to config.configurable for thread_id in lazy sandbox init (#1529) * fix(sandbox): fall back to config.configurable for thread_id in lazy sandbox init LangGraph Server injects thread_id via config["configurable"]["thread_id"], not always via context["thread_id"]. Without the fallback, lazy sandbox acquisition fails when context is empty. Co-Authored-By: Claude Sonnet 4.6 * fix(sandbox): align configurable fallback style with task_tool.py Co-Authored-By: Claude Sonnet 4.6 * fix(sandbox): guard runtime.config None check for thread_id fallback Co-Authored-By: Claude Sonnet 4.6 --------- Co-authored-by: Claude Sonnet 4.6 --- backend/packages/harness/deerflow/sandbox/tools.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/backend/packages/harness/deerflow/sandbox/tools.py b/backend/packages/harness/deerflow/sandbox/tools.py index 81ddc1018..ce91e8634 100644 --- a/backend/packages/harness/deerflow/sandbox/tools.py +++ b/backend/packages/harness/deerflow/sandbox/tools.py @@ -678,6 +678,8 @@ def ensure_sandbox_initialized(runtime: ToolRuntime[ContextT, ThreadState] | Non # Lazy acquisition: get thread_id and acquire sandbox thread_id = runtime.context.get("thread_id") if runtime.context else None + if thread_id is None: + thread_id = runtime.config.get("configurable", {}).get("thread_id") if runtime.config else None if thread_id is None: raise SandboxRuntimeError("Thread ID not available in runtime context")