Overview
When you attach the Sandbox tools to an agent:- The agent can call execute_bash_commands with a
codeparameter (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 acdin 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 client –
hastekit.NewLLMClientwith provider configs (e.g. OpenAI). Bind a model withclient.Model("Provider/model"). - Sandbox manager –
(&hastekitgateway.Config{Endpoint: ..., HttpClient: ...}).NewSandboxClient()returns an HTTP client that implementssandbox.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]stringargument is forwarded into the sandbox. Its values are run-context templated, so you can reference run-context fields when constructing env values. - Tool registration –
tools.NewBashTool(svc, image, env)returns anagents.Toolthat exposes execute_bash_commands to the LLM. Pass it inAgentConfig.Toolsalong 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.