mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-07-27 16:37:55 +00:00
* feat: add boxlite SDK as harness dependency * test: add fake SimpleBox fixtures for BoxLite warm pool tests * feat: add deterministic sandbox_id and warm pool fields to BoxliteProvider * feat: pass deterministic sandbox_id to SimpleBox name * feat: warm pool lifecycle — park on release, reclaim on acquire - release(): parks VMs in _warm_pool with timestamp instead of closing - _reclaim_warm_pool(): health checks warm boxes via echo ok - acquire(): tries warm pool reclaim before creating new boxes - Deterministic sandbox_id ensures thread isolation * feat(boxlite): idle reaper, replica enforcement, warm-pool shutdown/reset - Task 6: idle reaper daemon thread destroys expired warm-pool boxes - Task 7: replica enforcement evicts oldest warm-pool box when at capacity - Task 8: shutdown() stops idle checker first, destroys all boxes (active+warm); reset() clears warm pool Tests: 17 passed (4 new: idle reaper, replica enforcement, shutdown, reset) * fix(boxlite): harden warm pool lifecycle races * docs(boxlite): document warm pool configuration * fix(sandbox): log warning when evicting oldest warm box is failed Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * fix(boxlite): stop provider lifecycle on reset * fix(boxlite): make runtime an optional dependency * test(boxlite): remove unused warm pool lookup * docs(boxlite): clarify optional runtime support * refactor: extract shared WarmPoolLifecycleMixin for sandbox warm-pool lifecycle Introduce deerflow.community.warm_pool_lifecycle.WarmPoolLifecycleMixin owning idle-checker loop, warm-pool expiry, oldest-warm eviction, replica counting, and soft-cap logging. Move AioSandboxProvider and BoxliteProvider onto the mixin; keep AIO active-idle cleanup local and delegate only warm-pool expiry to the shared helper. BoxliteProvider also gains: - Prefixed box names (deer-flow-boxlite-*) for startup orphan reconciliation - _reconcile_orphans() adopting surviving boxes from a prior process - Pinned timeout forwarding: command timeout now bounds both BoxLite SDK exec(timeout=...) and the loop bridge .result(timeout) - reset() reworked as lightweight registry clear (boxes -> warm pool, no close, no idle-reaper stop, no loop close) so reset_sandbox_provider() config switches are safe; shutdown() remains the teardown path Backward-compatible: AIO DEFAULT_IDLE_TIMEOUT/DEFAULT_REPLICAS/ IDLE_CHECK_INTERVAL stay importable; Boxlite IDLE_CHECK_INTERVAL stays monkeypatchable. --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
41 lines
1.6 KiB
Python
41 lines
1.6 KiB
Python
"""BoxLite micro-VM backend for DeerFlow sandboxes.
|
|
|
|
Integrates `BoxLite <https://github.com/boxlite-ai/boxlite>`_ — a daemonless,
|
|
OCI-native micro-VM runtime (libkrun/KVM on Linux, Hypervisor.framework on
|
|
macOS) — behind DeerFlow's :class:`Sandbox` / :class:`SandboxProvider` contract.
|
|
Each sandbox is a hardware-isolated VM with its own kernel that runs any OCI
|
|
image unchanged. See https://github.com/bytedance/deer-flow/issues/3936.
|
|
|
|
The full contract is implemented: ``execute_command`` plus ``read_file`` /
|
|
``write_file`` / ``update_file`` / ``download_file`` / ``list_dir`` / ``glob`` /
|
|
``grep`` (file ops run as shell commands inside the box).
|
|
|
|
Configuration example (``config.yaml``)::
|
|
|
|
sandbox:
|
|
use: deerflow.community.boxlite:BoxliteProvider
|
|
image: python:3.12-slim # any OCI image; runs unchanged
|
|
memory_mib: 1024 # per-box memory cap (optional)
|
|
cpus: 2 # per-box vCPUs (optional)
|
|
replicas: 3 # active + warm VM cap per gateway process
|
|
idle_timeout: 600 # warm VM idle seconds before stop; 0 disables
|
|
environment: # injected into every command
|
|
PYTHONUNBUFFERED: "1"
|
|
|
|
Install the optional runtime before selecting this provider::
|
|
|
|
pip install "deerflow-harness[boxlite]"
|
|
|
|
Host requirement: BoxLite boots micro-VMs, so a Linux host needs KVM (nested
|
|
virtualization when DeerFlow itself runs inside a cloud VM); macOS uses
|
|
Hypervisor.framework.
|
|
"""
|
|
|
|
from .box import BoxliteBox
|
|
from .provider import BoxliteProvider
|
|
|
|
__all__ = [
|
|
"BoxliteBox",
|
|
"BoxliteProvider",
|
|
]
|