fabricatio_sandbox.capabilities.sandbox
Sandbox capability — provides VFS-based isolated file operations for LLM agents.
Classes
Capability mixin that gives a Role sandboxed file operations. |
Module Contents
- class fabricatio_sandbox.capabilities.sandbox.Sandbox(/, **data: Any)
Bases:
fabricatio_core.capabilities.usages.UseLLM,abc.ABCCapability mixin that gives a Role sandboxed file operations.
Typical usage:
class MyRole(Role, Sandbox): async def do_work(self): session = self.create_session(mounts={"/src": "/real/src"}) # ... use session.read_text / write_text etc. diff = session.diff() session.apply() # or discard by not calling apply
- create_session(mounts: dict[str, str] | None = None) fabricatio_sandbox.rust.SandboxSession
Create a new sandbox session, optionally with real-dir mounts.
- Parameters:
mounts –
{"/virtual": "/real/path", ...}mapping. Falls back tosandbox_config.mountswhen None.- Returns:
A fresh
SandboxSession.
- async sandbox(source: str, requirement: str, mounts: dict[str, str] | None = None, **kwargs: Unpack[fabricatio_core.models.kwargs_types.ValidateKwargs[fabricatio_sandbox.models.sandbox.SandboxResult]]) fabricatio_sandbox.models.sandbox.SandboxResult
Run a sandboxed edit operation driven by the LLM.
Creates a session, writes source into the VFS, asks the LLM to modify it according to requirement, and returns the result including diffs.
- Parameters:
source – Initial file content to place in the sandbox.
requirement – Natural-language description of the desired change.
mounts – Optional real-dir mounts for context.
**kwargs – Forwarded to
aask_validate.
- Returns:
A
SandboxResultwith the session, diffs, and applied flag.