mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-06-10 09:25:57 +00:00
ae9e8bc0bf
In Docker production deployments, LocalSandboxProvider runs inside the
deer-flow-gateway container, so any `sandbox.mounts[].host_path` from
config.yaml is resolved against the gateway container's filesystem — not
the host machine. When the path isn't also bind-mounted into the gateway
service, the mount was silently dropped with only a WARNING log, leaving
agents reading an empty directory in production while the same config
worked under `make dev`.
Escalate the missing-host_path branch to logger.error with explicit
guidance about Docker bind mounts and docker-compose, so the failure is
hard to miss in default log configurations. Skip behaviour is preserved
to avoid breaking existing deployments.
Also clarify the misleading `VolumeMountConfig.host_path` field
description so it documents reality for both providers:
- LocalSandboxProvider checks host_path from inside the gateway process
(host in `make dev`, container in `make up`).
- AioSandboxProvider (DooD) passes host_path straight to `docker -v`
for the sandbox container, where the host Docker daemon resolves it
from the host machine's perspective.
config.example.yaml's `sandbox.mounts` comment gets a Note: block
pointing operators at the docker-compose bind-mount requirement so the
Docker-mode gotcha is discoverable from the canonical template.
Adds a regression test that:
- confirms missing host_path is still skipped (no behaviour break);
- asserts an ERROR record is emitted referencing the offending paths;
- asserts the message contains actionable Docker/gateway/docker-compose
keywords so future refactors can't quietly downgrade it.
Refs: https://github.com/bytedance/deer-flow/issues/3244
97 lines
4.5 KiB
Python
97 lines
4.5 KiB
Python
from pydantic import BaseModel, ConfigDict, Field
|
|
|
|
|
|
class VolumeMountConfig(BaseModel):
|
|
"""Configuration for a volume mount."""
|
|
|
|
host_path: str = Field(
|
|
...,
|
|
description=(
|
|
"Source path for the mount. Resolution depends on the active provider: "
|
|
"``LocalSandboxProvider`` checks this path from the gateway process — in "
|
|
"``make dev`` that is the host machine, but in Docker deployments "
|
|
"(``make up`` / docker-compose) it is the path *inside* the "
|
|
"``deer-flow-gateway`` container, so the host directory must also be "
|
|
"bind-mounted into the gateway service for the mount to take effect. "
|
|
"``AioSandboxProvider`` (DooD) passes this value straight to ``docker -v`` "
|
|
"for the sandbox container, where it is resolved by the host Docker daemon "
|
|
"from the host machine's perspective."
|
|
),
|
|
)
|
|
container_path: str = Field(..., description="Path inside the container")
|
|
read_only: bool = Field(default=False, description="Whether the mount is read-only")
|
|
|
|
|
|
class SandboxConfig(BaseModel):
|
|
"""Config section for a sandbox.
|
|
|
|
Common options:
|
|
use: Class path of the sandbox provider (required)
|
|
allow_host_bash: Enable host-side bash execution for LocalSandboxProvider.
|
|
Dangerous and intended only for fully trusted local workflows.
|
|
|
|
AioSandboxProvider specific options:
|
|
image: Docker image to use (default: enterprise-public-cn-beijing.cr.volces.com/vefaas-public/all-in-one-sandbox:latest)
|
|
port: Base port for sandbox containers (default: 8080)
|
|
replicas: Maximum number of concurrent sandbox containers (default: 3). When the limit is reached the least-recently-used sandbox is evicted to make room.
|
|
container_prefix: Prefix for container names (default: deer-flow-sandbox)
|
|
idle_timeout: Idle timeout in seconds before sandbox is released (default: 600 = 10 minutes). Set to 0 to disable.
|
|
mounts: List of volume mounts to share directories with the container
|
|
environment: Environment variables to inject into the container (values starting with $ are resolved from host env)
|
|
"""
|
|
|
|
use: str = Field(
|
|
...,
|
|
description="Class path of the sandbox provider (e.g. deerflow.sandbox.local:LocalSandboxProvider)",
|
|
)
|
|
allow_host_bash: bool = Field(
|
|
default=False,
|
|
description="Allow the bash tool to execute directly on the host when using LocalSandboxProvider. Dangerous; intended only for fully trusted local environments.",
|
|
)
|
|
image: str | None = Field(
|
|
default=None,
|
|
description="Docker image to use for the sandbox container",
|
|
)
|
|
port: int | None = Field(
|
|
default=None,
|
|
description="Base port for sandbox containers",
|
|
)
|
|
replicas: int | None = Field(
|
|
default=None,
|
|
description="Maximum number of concurrent sandbox containers (default: 3). When the limit is reached the least-recently-used sandbox is evicted to make room.",
|
|
)
|
|
container_prefix: str | None = Field(
|
|
default=None,
|
|
description="Prefix for container names",
|
|
)
|
|
idle_timeout: int | None = Field(
|
|
default=None,
|
|
description="Idle timeout in seconds before sandbox is released (default: 600 = 10 minutes). Set to 0 to disable.",
|
|
)
|
|
mounts: list[VolumeMountConfig] = Field(
|
|
default_factory=list,
|
|
description="List of volume mounts to share directories between host and container",
|
|
)
|
|
environment: dict[str, str] = Field(
|
|
default_factory=dict,
|
|
description="Environment variables to inject into the sandbox container. Values starting with $ will be resolved from host environment variables.",
|
|
)
|
|
|
|
bash_output_max_chars: int = Field(
|
|
default=20000,
|
|
ge=0,
|
|
description="Maximum characters to keep from bash tool output. Output exceeding this limit is middle-truncated (head + tail), preserving the first and last half. Set to 0 to disable truncation.",
|
|
)
|
|
read_file_output_max_chars: int = Field(
|
|
default=50000,
|
|
ge=0,
|
|
description="Maximum characters to keep from read_file tool output. Output exceeding this limit is head-truncated. Set to 0 to disable truncation.",
|
|
)
|
|
ls_output_max_chars: int = Field(
|
|
default=20000,
|
|
ge=0,
|
|
description="Maximum characters to keep from ls tool output. Output exceeding this limit is head-truncated. Set to 0 to disable truncation.",
|
|
)
|
|
|
|
model_config = ConfigDict(extra="allow")
|