Skip to main content Switch to mobile version adk-kosa8 0.1.0 kosa8 Cloud microVM sandboxes for Google's Agent Development Kit: a code executor and an MCP toolset
pip install adk-kosa8 Copy PIP instructions
Run the code a Google Agent Development Kit (ADK) agent writes in a kosa8 Cloud sandbox instead of on your machine.
Kosa8CodeExecutor is an ADK code executor (BaseCodeExecutor). Give it to an LlmAgent as code_executor=, and each Python block the model writes runs in a kosa8 sandbox. You get stdout, stderr, the exit code and output files (saved as ADK artifacts).
kosa8_mcp_toolset() gives an agent kosa8's sandbox tools (run, sandbox_create, sandbox_exec, file_read, file_write, sandbox_delete and more) from kosa8's remote MCP server, through ADK's McpToolset.
adk-kosa8 is not on PyPI yet. Until it is, install it from GitHub:
pip install "adk-kosa8 @ git+https://github.com/kosa8ai/adk-kosa8" Once it is published, this becomes pip install adk-kosa8.
It needs Python 3.11 or newer and installs google-adk[mcp] 2.x and the kosa8 SDK.
Set KOSA8_API_KEY to a kosa8 Cloud API key (create one at app.kosa8.com), or run kosa8 login once. The Starter plan is free with no card and includes $10 of one-time kosa8 Cloud usage. Paid plans start at $29 a month (pricing).
Quick start: a code executor
from google.adk.agents import LlmAgent from adk_kosa8 import Kosa8CodeExecutor root_agent = LlmAgent( name="python_coder", model="gemini-flash-latest", instruction="Solve problems by writing Python in ```python blocks. Answer from the output.", code_executor=Kosa8CodeExecutor(), ) Run it with adk web, adk run or a Runner as usual. By default each ADK session gets one sandbox (the python template). The sandbox is created on the session's first code block and reused for later blocks, so files the code writes are still there next time. Call close() on the executor when you are done to delete its sandboxes. Each sandbox also has a one-hour lifetime (ttl_s), after which kosa8 deletes it anyway.
stdout, stderr and exit_code. An exception in the code is a traceback in stderr and exit code 1. ADK shows these to the model, and its error_retry_attempts applies.
A block that runs past timeout_seconds is stopped in the sandbox. It returns exit code 124, any output so far, and Code execution timed out after N seconds. in stderr.
Every file the code writes under output_dir (also in $ADK_OUTPUT_DIR) is returned as an output file, and ADK saves it as an artifact. Input files from CodeExecutorContext.add_input_files() are written to input_dir ($ADK_INPUT_DIR). Both folders are emptied before each block. At most 100 files and 32 MiB are returned per block.
Problems with kosa8 itself raise kosa8 exceptions rather than returning output to the model: a bad key (Kosa8AuthError), no plan or credit (Kosa8PaymentRequiredError, with upgrade_url) or a rate limit (Kosa8RateLimitError). If a session's sandbox was deleted, for example by its ttl_s, the executor starts a new one and runs the block again.
Kosa8CodeExecutor(stateful=True) With stateful=True, variables, imports and functions stay from one code block to the next, as in a notebook. Each block runs in kosa8's code interpreter in a persistent sandbox, with one context per ADK session. The value of a block's last expression is added to stdout, and charts it draws come back as PNG output files. A cell takes at most 80 seconds. When the time limit stops a cell, the context keeps what the cell had set up to that point.
Lock the network to one host
Kosa8CodeExecutor(allow_hosts=["pypi.org"]) The sandbox then reaches pypi.org and nothing else. A request to another host fails at DNS, and an address the code already knows gets nowhere. kosa8 enforces the policy on the host, outside the sandbox, and nothing inside the sandbox can change it. Entries can be exact names, *.domain wildcards, IPv4 addresses or CIDRs. With no policy set, a sandbox gets your organization's policy. That is kosa8's default allow-list (package registries, GitHub, Hugging Face and the main AI APIs) unless your organization changed it. See egress controls.
Use the code executor when the model writes code for you to run. Use the toolset when the model should manage sandboxes itself: start one, run shell commands, read and write files, and delete it.
examples/ holds three agents for adk web examples, plus a runner:
python_coder: writes Python and runs it with Kosa8CodeExecutor.
egress_locked: the sandbox can reach pypi.org only, so a request to example.com is blocked.
mcp_tools: kosa8's MCP sandbox tools.
export KOSA8_API_KEY=k8c_live_... GOOGLE_API_KEY=... # or ADK_MODEL=anthropic/claude-haiku-4-5 with ANTHROPIC_API_KEY python examples/run.py egress_locked "Fetch https://pypi.org/simple/ and https://example.com and report the status of each." python examples/executor_only.py # the executor on its own, no model needed Security notes
The code runs in a sandbox, not on your machine. Each kosa8 Cloud sandbox is a microVM with its own Linux kernel on a kosa8 host. One exception: when kosa8's hosts are full, a plain sandbox may run on kosa8's overflow capacity (Cloudflare Containers, same API), which is not a kosa8 microVM. Persistent sandbox (stateful=True), egress-policy (allow_hosts, egress) and named-region (region=) sandboxes always wait for a kosa8 host. See kosa8 Cloud.
Limit what the code can reach. Model-written code can be steered by what the model reads. kosa8 limits what that code can do, through the sandbox, its egress policy and its lifetime. kosa8 does not stop prompt injection itself. Use allow_hosts for code that needs no general internet access.
Keep keys out of the sandbox. Do not put API keys in env. Store them as kosa8 secrets: the sandbox then holds a placeholder, and kosa8 adds the real key on the way out, only to the named host.
Clean up. Call close() (or use with Kosa8CodeExecutor(...) as ex:) to delete sandboxes. The ttl_s lifetime is the backstop if a process dies first.
Compliance. kosa8's SOC 2 Type II audit is in progress, with the report expected in January 2027. kosa8 has no SOC 2 report or external pen test yet. See kosa8.com/trust.
uv venv && uv pip install -e . pytest pytest-asyncio ruff mypy pytest # unit tests against a local fake kosa8 API (no network) ruff check . && ruff format --check . && mypy KOSA8_API_KEY=k8c_live_... pytest -m kosa8_live # the live tier, against kosa8 Cloud The live tier creates sandboxes (each labelled and given a 15-minute lifetime as a backstop), covers create, running code, files across calls, error passthrough, timeouts, input and output files, stateful variables, an egress allow-list, a whole ADK run with a scripted model, and the MCP tool list. Its last test checks that none of its sandboxes are left.
adk agents code-executor google-adk kosa8 mcp microvm sandbox
Intended Audience Developers
License OSI Approved :: MIT License
Programming Language Python :: 3
Topic Scientific/Engineering :: Artificial Intelligence
Release files for adk-kosa8 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
Built distribution (wheel)
Total release size: 40.5 kB
Release files / adk_kosa8-0.1.0.tar.gz
Release files / adk_kosa8-0.1.0-py3-none-any.whl
Security for adk-kosa8 0.1.0
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.
Release history Release notifications | RSS feed
Nov 26, 2026 2 release files No provenance
"PyPI", "Python Package Index", and the blocks logos are registered trademarks of the Python Software Foundation.
© 2026 Python Software Foundation




