Skip to main content
The Sandbox tools let your agent run bash commands and manipulate files in an isolated environment. Each conversation gets its own sandbox with a persistent workspace. The agent uses the execute_bash_commands tool to run shell commands and receive stdout, stderr, and exit code, plus optional file tools to read, write, and delete files.

Overview

When you attach the Sandbox tools to an agent:
  • The agent can call execute_bash_commands with a code parameter (the bash command to run).
  • The sandbox is provisioned through a sandbox manager (sandbox.Manager). The SDK ships an HTTP-backed manager, obtained from (&hastekitgateway.Config{...}).NewSandboxClient(), which talks to the HasteKit sandbox service. That service provisions one sandbox per session.
  • The workspace is rooted at /workspace. The bash tool persists its working directory across calls, so a cd in one command carries over to the next.

Example: Agent with Sandbox

The following example uses the HasteKit SDK to create an agent with the bash tool, backed by the HTTP sandbox manager. It runs a single turn asking for the current time; the agent will use execute_bash_commands to run e.g. date.

Key pieces

  • LLM clienthastekit.NewLLMClient with provider configs (e.g. OpenAI). Bind a model with client.Model("Provider/model").
  • Sandbox manager(&hastekitgateway.Config{Endpoint: ..., HttpClient: ...}).NewSandboxClient() returns an HTTP client that implements sandbox.Manager (CreateSandbox, GetSandbox, DeleteSandbox). It talks to the HasteKit sandbox service, which provisions one sandbox per session.
  • Sandbox image – The image name passed to the tool (e.g. hastekit-ai-sandbox:v7). The sandbox service uses it when provisioning the sandbox for the session.
  • Environment variables – The env map[string]string argument is forwarded into the sandbox. Its values are run-context templated, so you can reference run-context fields when constructing env values.
  • Tool registrationtools.NewBashTool(svc, image, env) returns an agents.Tool that exposes execute_bash_commands to the LLM. Pass it in AgentConfig.Tools along with any other tools.

File tools

Alongside the bash tool, the SDK exposes file tools that share the same (svc sandbox.Manager, image string, env map[string]string) signature and operate on the same per-session sandbox:

Tool: execute_bash_commands

The bash tool exposes a single function to the LLM: The working directory is persisted across calls: after each command the tool records the resulting cwd via state updates (sandbox_cwd) and restores it on the next call, defaulting to /workspace.

Response format

The sandbox returns a JSON object with: Timeouts are enforced by the daemon (default 60 seconds). On timeout, the response may indicate failure and the process is killed.

Summary