Create an async factory function that creates a new Deno Sandbox per invocation.
Each call to the factory will create and initialize a new sandbox. This is useful when you want fresh, isolated environments for each agent invocation.
Important: This returns an async factory. For use with middleware that
requires synchronous BackendFactory, use createDenoSandboxFactoryFromSandbox()
with a pre-created sandbox instead.
createDenoSandboxFactory(options: DenoSandboxOptions): AsyncDenoSandboxFactory| Name | Type | Description |
|---|---|---|
options | DenoSandboxOptions | Optional configuration for sandbox creation |
import { DenoSandbox, createDenoSandboxFactory } from "@langchain/deno";
// Create a factory for new sandboxes
const factory = createDenoSandboxFactory({ memory: "1GiB" });
// Each call creates a new sandbox
const sandbox1 = await factory();
const sandbox2 = await factory();
try {
// Use sandboxes...
} finally {
await sandbox1.close();
await sandbox2.close();
}