open-swe/agent/integrations/local.py
Ramon Nogueira ae04b72b41
feat: publish plans from sandbox files (#1635)
* feat: publish plans from sandbox files

Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>

* fix: avoid fixed plan filenames

Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>

* fix: virtualize local sandbox file paths

Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>

* fix: preserve plan_file_path across set_plan_status

set_plan_status was rewriting the content record with only markdown
and status, dropping plan_file_path. After a reject, the owner's
dashboard edit would mirror to a different file than the agent's
original, and the next save_plan could republish the stale file.
Preserve plan_file_path when updating status.

---------

Co-authored-by: Ramon Nogueira <270434257+ramon-langchain@users.noreply.github.com>
Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
2026-06-29 13:02:55 -07:00

29 lines
931 B
Python

import os
from deepagents.backends import LocalShellBackend
def create_local_sandbox(sandbox_id: str | None = None):
"""Create a local shell sandbox with no isolation.
WARNING: This runs commands directly on the host machine with no sandboxing.
Only use for local development with human-in-the-loop enabled.
The root directory defaults to the current working directory and can be
overridden via the LOCAL_SANDBOX_ROOT_DIR environment variable. It is
created if it does not already exist.
Args:
sandbox_id: Ignored for local sandboxes; accepted for interface compatibility.
Returns:
LocalShellBackend instance implementing SandboxBackendProtocol.
"""
root_dir = os.getenv("LOCAL_SANDBOX_ROOT_DIR", os.getcwd())
os.makedirs(root_dir, exist_ok=True)
return LocalShellBackend(
root_dir=root_dir,
virtual_mode=True,
inherit_env=True,
)