agentskit.js
Packages

@agentskit/sandbox

Secure code execution (E2B / WebContainer) + mandatory-sandbox policy wrapper.

@agentskit/sandbox is the package for the moment when your agent needs to execute code or touch risky tools and “please be careful” is no longer enough. It adds a policy layer between the model and dangerous capabilities.

#When to reach for it

  • You want the model to run code safely.
  • You want a policy layer over every tool (allow / deny / require-sandbox / validators).

#Best fit

  • Add this before enabling shell, code execution, or broad filesystem access.
  • Pair with @agentskit/tools to wrap risky tool surfaces.
  • Pair with @agentskit/runtime when autonomous agents can take meaningful actions.
  • Pair with production security guidance before public rollout.

#Install

npm install @agentskit/sandbox

#Hello world

import { sandboxTool, createMandatorySandbox } from '@agentskit/sandbox'
import { shell, filesystem, webSearch } from '@agentskit/tools'

const policy = createMandatorySandbox({
  sandbox: sandboxTool(),
  policy: { requireSandbox: ['shell'], deny: ['filesystem'] },
})
const safeTools = [shell(), filesystem({ basePath }), webSearch()].map(t => policy.wrap(t))

This is one of the clearest boundaries between a capable agent demo and a production-safe agent system.

#Surface

  • createSandbox(config?) — default backend probes E2B.
  • sandboxTool() — ready-made code_execution tool (js / python).
  • createE2BBackend(config) — BYO E2B.
  • createMandatorySandbox({ sandbox, policy }).

#Recipes

#Stability

  • Version: 0.3.1
  • Tier: alpha
  • Contract: evolving
  • Roadmap: see packages roadmap for what this package needs to reach v1.0.

#Source

npm: @agentskit/sandbox · repo: packages/sandbox

Explore nearby

✎ Edit this page on GitHub·Found a problem? Open an issue →·How to contribute →

On this page