Pre-built tools for LLMs to execute bash commands, edit files, and export results in isolated containers.
| Tool | Description |
|---|
bash_execution_sandbox | Execute bash commands |
text_editor_sandbox | View, create, edit text files |
export_file_sandbox | Export files to disk with download URL |
Sandbox tools support mounting Agent Skills directly into the sandbox filesystem, allowing LLMs to access skill files and execute skill scripts.
Quick Start
import json
import os
from acontext import AcontextClient
from acontext.agent.sandbox import SANDBOX_TOOLS
from openai import OpenAI
client = AcontextClient(api_key=os.getenv("ACONTEXT_API_KEY"))
openai_client = OpenAI()
# Create sandbox and disk
sandbox = client.sandboxes.create()
disk = client.disks.create()
# Create context (optionally mount skills)
ctx = SANDBOX_TOOLS.format_context(
client,
sandbox_id=sandbox.sandbox_id,
disk_id=disk.id,
# mount_skills=["skill-uuid"]
)
tools = SANDBOX_TOOLS.to_openai_tool_schema()
context_prompt = ctx.get_context_prompt()
messages = [
{"role": "system", "content": f"You have sandbox access.\n\n{context_prompt}"},
{"role": "user", "content": "Create and run a Python hello world script"}
]
# Agent loop
while True:
response = openai_client.chat.completions.create(
model="gpt-4.1", messages=messages, tools=tools
)
message = response.choices[0].message
messages.append(message)
if not message.tool_calls:
print(f"Assistant: {message.content}")
break
for tc in message.tool_calls:
result = SANDBOX_TOOLS.execute_tool(ctx, tc.function.name, json.loads(tc.function.arguments))
messages.append({"role": "tool", "tool_call_id": tc.id, "content": result})
client.sandboxes.kill(sandbox.sandbox_id)
Mounting Agent Skills
Mount Agent Skills into sandbox at /skills/{skill_name}/:
ctx = SANDBOX_TOOLS.format_context(
client,
sandbox_id=sandbox.sandbox_id,
disk_id=disk.id,
mount_skills=["skill-uuid-1", "skill-uuid-2"]
)
# Or mount after creation
ctx.mount_skills(["skill-uuid-3"])
Mounting skills modifies the context prompt. Always call get_context_prompt() after mounting to include the updated skill information in your system message.
bash_execution_sandbox
{"command": "python3 script.py", "timeout": 30}
Returns: {"stdout": "...", "stderr": "...", "exit_code": 0}
text_editor_sandbox
| Command | Parameters | Description |
|---|
view | path, view_range (optional) | Read file |
create | path, file_text | Create/overwrite file |
str_replace | path, old_str, new_str | Find and replace |
export_file_sandbox
{"sandbox_path": "/workspace/", "sandbox_filename": "output.txt"}
Returns: {"message": "...", "public_url": "https://..."}
Sandbox Environment
Pre-installed: Python 3, ripgrep, fd, sqlite3, jq, imagemagick, standard Unix tools.
Limitations: No blocking calls (plt.show(), input()), expires after 30 minutes.
Next Steps