Skip to content

SingletonFactory

autogen.beta.tools.sandbox.factory.SingletonFactory #

SingletonFactory(sandbox)

Wrap a single :class:Sandbox instance as a :class:SandboxFactory.

Every :meth:open call yields the same sandbox. The underlying instance's lifecycle is not driven by this factory — callers own the sandbox and close it themselves. Useful for :class:~autogen.beta.tools.sandbox.LocalSandbox, where the workdir is fixed for the life of the process and there is nothing to resolve per-call.

Source code in autogen/beta/tools/sandbox/factory.py
def __init__(self, sandbox: Sandbox) -> None:
    self._sandbox = sandbox

sandbox property #

sandbox

The wrapped sandbox instance.

open async #

open(context=None)
Source code in autogen/beta/tools/sandbox/factory.py
@asynccontextmanager
async def open(
    self,
    context: "ConversationContext | None" = None,
) -> AsyncIterator[Sandbox]:
    del context
    yield self._sandbox