Documentation Index
Fetch the complete documentation index at: https://budecosystem-b7b14df4.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The Python SDK exposes two namespaces for managing the code-interpreter sandbox that backs each agent’sbash and code_interpreter tools:
client.code_interpreter.templates— create, get, update, and delete custom Docker-based sandbox templates.client.agents.add_code_interpreter/get_code_interpreter/remove_code_interpreter— attach, inspect, and detach a template on an agent (= prompt version).
AgentToolBinding.env_id is informational only.
Quick Start
Templates
Create Template
Submit a custom-template build; returns immediately withstatus="pending".
| Parameter | Type | Description |
|---|---|---|
name | str | Slug-safe template id (also the sandbox alias). |
commands | list[str] | Raw Dockerfile instructions appended to the base. See Dockerfile Commands. |
cpu_count | int | vCPU count. |
memory_mb | int | Memory in MiB. |
Template handle with .refresh() and .wait_until_ready()
bound. Status is "pending" until the first workflow activity inserts
the row.
Get Template
Fetch a single template row by id.NotFoundError if the template doesn’t exist or is in another
project.
Update Template
Replace the template’s commands and rebuild the same sandbox image.Delete Template
Hard-delete the template row and its sandbox image.Wait Until Ready
Block until the template build completes; raise on failure.| Parameter | Type | Default | Description |
|---|---|---|---|
timeout | float | 600.0 | Total seconds to wait before raising TimeoutError. |
poll_interval | float | 3.0 | Seconds between successive refresh() calls. |
self once status reaches "ready". Raises BuildFailedError
when the server reports status="failed" — the captured stderr tail is
on error_message.
Refresh
Re-fetch the row from the server; mutateself in place.
self, so callers can chain. Tolerates 404 for a short grace
window after create / update — the row may not exist yet because the
first workflow activity hasn’t run.
Agent Bindings
Attach Code Interpreter
Attach (or update) the code-interpreter tool on an agent version.| Parameter | Type | Default | Description |
|---|---|---|---|
agent_id | str | — | The agent (prompt) id. |
template_id | str | — | A builtin id (e.g. "python-4g") or a custom template id from create(). |
version | int | 1 | Agent version number. |
lifespan_seconds | int | 1200 | Sandbox idle-kill timeout. |
network_policy | NetworkPolicy | dict | None | Egress policy. See NetworkPolicy. |
AgentToolBinding; binding.env_id is the auto-provisioned
sandbox env id (informational only).
Get Binding
Fetch the agent’s current code-interpreter binding.AgentToolBinding, or None if no binding exists for that
agent version.
Remove Code Interpreter
Detach the code-interpreter tool from an agent version.Dockerfile Commands
commands is a list[str] of raw Dockerfile instructions appended
verbatim to the platform’s base Dockerfile. The base ships the systemd
- Jupyter setup that backs the MCP tools.
Allowed Instructions
RUN, ENV, WORKDIR, USER, ARG, LABEL — plus the rest of the
Docker instruction set that doesn’t break the base. Server-side
validation is deny-list, not allow-list, so harmless no-ops like
EXPOSE and SHELL are silently accepted.
Rejected Instructions
The validator hard-rejects five instructions with explicit per-instruction error messages:| Instruction | Why it’s rejected |
|---|---|
FROM | Replaces the base image, killing the systemd + Jupyter setup. |
COPY / ADD | The SDK doesn’t ship a build context. Use a heredoc inside RUN for small files, or RUN curl -fsSL … for already-hosted files. |
CMD / ENTRYPOINT | Overrides systemd as PID 1, so the Jupyter + FastAPI shim never starts. |
Typo Catcher
Each line must start with a recognised Docker instruction keyword. A line like"pip install pydantic-ai" returns a 422 with a
did you forget RUN? hint immediately, instead of failing 30 seconds
into the sandbox build.
Structural Limits
- ≤ 64 commands per template.
- ≤ 4 KB per command line.
- No NUL bytes, no bare CRs.
Response Objects
Template
create(), get(), and update() carry
.refresh() and .wait_until_ready() bound to the originating client.
AgentToolBinding
NetworkPolicy
"disabled"— block all egress (default)."open"— unrestricted egress."filtered"— caller-defined allow / deny lists.
allow_out / deny_out accept IP literals, CIDR ranges, domain names,
wildcard domains ("*.example.com"), and the case-insensitive sentinel
"ALL_TRAFFIC" (which expands to 0.0.0.0/0). Allow takes precedence
over deny.
BuildFailedError
Template.wait_until_ready() when the build workflow reports
status="failed".
Async Client
The same surface exists onAsyncBudClient:
Error Handling
Limits
- No file uploads —
COPY/ADDare rejected. Heredoc inRUNorRUN curlare the documented workarounds. - No template versioning — edits are destructive. To preserve an old recipe, create a new template before editing the old one.
- No template list endpoint in the SDK. Keep the id from
create(). - No environment CRUD in the SDK.
agents.add_code_interpreterdoes it for you; project deletion cascades the cleanup. - Embedded credentials in
RUN pip install --index-url=…are baked into the image. Treat any image you build as you would any artifact: if it contains secrets, do not share it.
Next Steps
Inference
Invoke agents that use your code-interpreter binding
Code Examples
Complete code examples and patterns