Skip to content

LocalRuntime

autogen.beta.tools.runtime.local.LocalRuntime dataclass #

LocalRuntime(dir=None, cleanup=False, timeout=60, max_output=100000, blocked=list(), extra_paths=None)

Local filesystem storage and subprocess execution.

PARAMETER DESCRIPTION
dir

Directory where skills are installed. None.agents/skills (default).

TYPE: str | Path | None DEFAULT: None

cleanup

If True, the install directory is deleted at process exit.

TYPE: bool DEFAULT: False

timeout

Per-command timeout in seconds. Defaults to 60.

TYPE: float DEFAULT: 60

max_output

Maximum characters returned from a script run. Defaults to 100,000.

TYPE: int DEFAULT: 100000

blocked

Command prefixes that are not allowed to run. Empty list → nothing blocked.

TYPE: list[str] DEFAULT: list()

extra_paths

Additional read-only directories to scan for skills. Installed skills always go to dir; these paths are only used for discovery.

TYPE: Sequence[str | Path] | None DEFAULT: None

Example::

# Default — installs to .agents/skills
LocalRuntime()

# Custom install directory
LocalRuntime("./my-skills")

# Full control
LocalRuntime("./my-skills", timeout=30, cleanup=True, blocked=["rm -rf"])

# Extra read-only search paths
LocalRuntime("./my-skills", extra_paths=["./shared-skills"])

dir class-attribute instance-attribute #

dir = None

cleanup class-attribute instance-attribute #

cleanup = False

timeout class-attribute instance-attribute #

timeout = 60

max_output class-attribute instance-attribute #

max_output = 100000

blocked class-attribute instance-attribute #

blocked = field(default_factory=list)

extra_paths class-attribute instance-attribute #

extra_paths = None

install_dir property #

install_dir

Resolved install directory.

lock_dir property #

lock_dir

discover #

discover()
Source code in autogen/beta/tools/runtime/local.py
def discover(self) -> list[SkillMetadata]:
    return self._loader.discover()

load #

load(name)
Source code in autogen/beta/tools/runtime/local.py
def load(self, name: str) -> str:
    return self._loader.load(name)

get_path #

get_path(name)
Source code in autogen/beta/tools/runtime/local.py
def get_path(self, name: str) -> Path:
    return self._loader.get_path(name)

invalidate #

invalidate()
Source code in autogen/beta/tools/runtime/local.py
def invalidate(self) -> None:
    self._loader.invalidate()

ensure_storage #

ensure_storage()
Source code in autogen/beta/tools/runtime/local.py
def ensure_storage(self) -> None:
    self._install_dir.mkdir(parents=True, exist_ok=True)

install #

install(source, name)
Source code in autogen/beta/tools/runtime/local.py
def install(self, source: Path, name: str) -> None:
    dest = self._install_dir / name
    if dest.exists():
        shutil.rmtree(dest)
    shutil.copytree(source, dest)

remove #

remove(name)
Source code in autogen/beta/tools/runtime/local.py
def remove(self, name: str) -> None:
    target = (self._install_dir / name).resolve()
    if not target.is_relative_to(self._install_dir.resolve()):
        raise ValueError(f"Cannot remove '{name}': path traversal detected")
    if not target.exists():
        raise FileNotFoundError(f"Cannot remove '{name}': skill not found in {self._install_dir}")
    shutil.rmtree(target)

shell #

shell(scripts_dir)
Source code in autogen/beta/tools/runtime/local.py
def shell(self, scripts_dir: Path) -> ShellEnvironment:

    return LocalShellEnvironment(
        path=scripts_dir,
        cleanup=False,
        timeout=self.timeout,
        max_output=self.max_output,
        blocked=self.blocked or None,
    )