Mosaic Sandbox Python SDK
mosaic-sandbox is the Python SDK and CLI for Mosaic Sandbox, a Firecracker-based
runtime for coding agents.
Install:
python -m pip install mosaic-sandbox
Authenticate once with the CLI:
mos auth --token msk_live_...
mos whoami
Run the CLI smoke test:
mos doctor
mos run --template node-20 node -v
mos create --template node-20 --ssh
mos ssh <sandbox-id> --print-command
Or run the one-command first-run check:
mos smoke
Python example:
from mosaic_sandbox import Sandbox
sbx = Sandbox.create(
template="node-20",
endpoint="https://sandbox.mosaicos.com",
api_token="msk_live_...",
enable_ssh=False,
)
try:
result = sbx.run_command("node -v")
print(result.stdout)
print(result.tti_ms)
finally:
sbx.destroy()
LangChain and LlamaIndex tools
Give an agent a sandbox without writing tools for it. Neither framework is a dependency of this SDK; the one you use is imported when you ask for it.
from langchain.agents import create_react_agent
from mosaic_sandbox.integrations.langchain import mosaic_sandbox_tools
agent = create_react_agent(model, mosaic_sandbox_tools(template="python-3.11"))
from llama_index.core.agent import ReActAgent
from mosaic_sandbox.integrations.llamaindex import mosaic_sandbox_tools
agent = ReActAgent.from_tools(mosaic_sandbox_tools(), llm=llm)
The tools — mosaic_run_command, mosaic_run_python, mosaic_run_javascript,
mosaic_read_file, mosaic_write_file, mosaic_list_files and
mosaic_start_server — share one sandbox, created on the first call rather
than when the agent is built. mosaic_start_server returns a public HTTPS
preview URL, so "run the dev server and show me" is a single tool call.
Keyword arguments are Sandbox.create's, so snapshot_id= starts the agent in
an environment you built earlier. Hold the SandboxToolset yourself if you
want to close() it explicitly; close() destroys the sandbox it created but
leaves a sandbox you passed in alone, and the toolset is spent either way — a
later tool call raises rather than quietly starting a second machine.
Release files for mosaic-sandbox 0.11.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mosaic_sandbox-0.11.0.tar.gz | 170.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mosaic_sandbox-0.11.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 296.0 kB
Release files / mosaic_sandbox-0.11.0.tar.gz
| Download URL | mosaic_sandbox-0.11.0.tar.gz |
|---|---|
| Size | 170.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
64633e07a30af2f1b3fd317883c6c990d41878139f47c63a9761736d12220a6a
|
|
BLAKE2b-256 checksum How to use checksums |
3f68c2b0ea1232108e6e074e0c8a8946529dcd9b6abe6107ee4363a6bced1776
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.14
|
Release files / mosaic_sandbox-0.11.0-py3-none-any.whl
| Download URL | mosaic_sandbox-0.11.0-py3-none-any.whl |
|---|---|
| Size | 125.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7efbdc1d19f3aa999681ed293bd5dcb937789434c6deb18854f1eccc258036e0
|
|
BLAKE2b-256 checksum How to use checksums |
553b09844a5400820625583450d220270f0822c086a3821ff375bd83d0981f6d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.14
|