Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
fix(dify-agent): adjust local sandbox home paths (#41021)
盐粒 Yanlib034368b3ba9
diff --git a/dify-agent/src/dify_agent/runtime_backend/local.py b/dify-agent/src/dify_agent/runtime_backend/local.pyindex f0a2e5c2e66..4a0cc209b36 100644--- a/dify-agent/src/dify_agent/runtime_backend/local.py+++ b/dify-agent/src/dify_agent/runtime_backend/local.py@@ -45,7 +45,7 @@ logger = logging.getLogger(__name__)class LocalHomeSnapshotBackend:endpoint: strauth_token: str- snapshot_root: str = "/home/dify/.dify-agent-home-snapshots"+ snapshot_root: str = "/home/dify/.snapshots"client_factory: ShellctlClientFactory | None = Noneasync def create_from_runtime(self, *, spec: HomeSnapshotCreateSpec, source: RuntimeLease) -> str:@@ -111,9 +111,9 @@ class LocalHomeSnapshotBackend:class LocalExecutionBindingBackend:endpoint: strauth_token: str- materialized_home_root: str = "/home/dify/.dify-agent-materialized-homes"+ materialized_home_root: str = "/home/dify"workspace_root: str = "/home/dify/.dify-agent-workspaces"- snapshot_root: str = "/home/dify/.dify-agent-home-snapshots"+ snapshot_root: str = "/home/dify/.snapshots"client_factory: ShellctlClientFactory | None = Noneasync def create_binding(self, spec: ExecutionBindingCreateSpec) -> ExecutionBindingAllocation:diff --git a/dify-agent/src/dify_agent/runtime_backend/profile.py b/dify-agent/src/dify_agent/runtime_backend/profile.pyindex 9bbbf3ee3f7..d78dbc00ef1 100644--- a/dify-agent/src/dify_agent/runtime_backend/profile.py+++ b/dify-agent/src/dify_agent/runtime_backend/profile.py@@ -20,9 +20,9 @@ from dify_agent.runtime_backend.local import LocalExecutionBindingBackend, Localfrom dify_agent.runtime_backend.protocols import RuntimeBackendProfileDEFAULT_E2B_TEMPLATE = "difys-default-team/dify-agent-local-sandbox"-DEFAULT_LOCAL_MATERIALIZED_HOME_ROOT = "/home/dify/.dify-agent-materialized-homes"+DEFAULT_LOCAL_MATERIALIZED_HOME_ROOT = "/home/dify"DEFAULT_LOCAL_WORKSPACE_ROOT = "/home/dify/.dify-agent-workspaces"-DEFAULT_LOCAL_HOME_SNAPSHOT_ROOT = "/home/dify/.dify-agent-home-snapshots"+DEFAULT_LOCAL_HOME_SNAPSHOT_ROOT = "/home/dify/.snapshots"class RuntimeBackendSettings(BaseSettings):diff --git a/dify-agent/tests/local/dify_agent/runtime_backend/test_local.py b/dify-agent/tests/local/dify_agent/runtime_backend/test_local.pyindex a2f8190e32f..45ffbcb4bb5 100644--- a/dify-agent/tests/local/dify_agent/runtime_backend/test_local.py+++ b/dify-agent/tests/local/dify_agent/runtime_backend/test_local.py@@ -320,87 +320,6 @@ async def test_local_snapshot_delete_removes_snapshot_directory() -> None:assert ("rm", "-rf", "--", "/snapshots/home-home-2") in factory.commands-async def test_local_backend_materializes_same_agent_twice_in_one_workspace() -> None:- factory = _Factory()- backend = LocalExecutionBindingBackend(- endpoint="http://shellctl",- auth_token="",- client_factory=factory, # pyright: ignore[reportArgumentType]- )-- first = await backend.create_binding(- ExecutionBindingCreateSpec(- tenant_id="tenant-1",- agent_id="agent-1",- binding_id="binding-1",- workspace_id="workspace-1",- existing_workspace_ref=None,- home_snapshot_ref="home-home-1",- )- )- second = await backend.create_binding(- ExecutionBindingCreateSpec(- tenant_id="tenant-1",- agent_id="agent-1",- binding_id="binding-2",- workspace_id="workspace-1",- existing_workspace_ref=first.workspace_ref,- home_snapshot_ref="home-home-1",- )- )-- assert first.binding_ref == "binding-1:workspace-1"- assert second.binding_ref == "binding-2:workspace-1"- assert first.workspace_ref == second.workspace_ref == "workspace-1"- first_lease = await backend.acquire(first.binding_ref)- second_lease = await backend.acquire(second.binding_ref)- assert first_lease.layout.home_dir != second_lease.layout.home_dir- assert first_lease.layout.workspace_dir == second_lease.layout.workspace_dir- await backend.release(first_lease)- await backend.release(second_lease)-- await backend.destroy_binding(- ExecutionBindingDestroySpec(- binding_ref=first.binding_ref,- destroy_workspace=False,- )- )- surviving_lease = await backend.acquire(second.binding_ref)- assert surviving_lease.layout.home_dir == "/home/dify/.dify-agent-materialized-homes/binding-2"- assert surviving_lease.layout.workspace_dir == "/home/dify/.dify-agent-workspaces/workspace-1"- await backend.release(surviving_lease)-- workspace_dir = "/home/dify/.dify-agent-workspaces/workspace-1"- assert ("test", "-d", workspace_dir) in factory.commands- assert factory.commands.count(("mkdir", "-p", workspace_dir)) == 1- assert (- "rm",- "-rf",- "--",- "/home/dify/.dify-agent-materialized-homes/binding-1",- ) in factory.commands- assert (- "rm",- "-rf",- "--",- "/home/dify/.dify-agent-materialized-homes/binding-1",- workspace_dir,- ) not in factory.commands- assert (- "cp",- "-a",- "/home/dify/.dify-agent-home-snapshots/home-home-1/.",- "/home/dify/.dify-agent-materialized-homes/binding-1/",- ) in factory.commands- assert (- "cp",- "-a",- "/home/dify/.dify-agent-home-snapshots/home-home-1/.",- "/home/dify/.dify-agent-materialized-homes/binding-2/",- ) in factory.commands--@pytest.mark.anyioasync def test_local_snapshot_delete_preserves_shellctl_error_when_close_fails() -> None:factory = _FailingFactory()