sandflare-autogen
AutoGen CodeExecutor that runs agent-generated code in isolated Sandflare Firecracker microVM sandboxes.
Installation
pip install sandflare-autogen
Usage
Basic — SandflareCodeExecutor
Each execute_code_blocks() call runs in the same sandbox. The sandbox is destroyed when stop() is called or the context manager exits.
from sandflare_autogen import SandflareCodeExecutor
from autogen.coding import CodeBlock
with SandflareCodeExecutor(api_key="pa_live_...") as executor:
result = executor.execute_code_blocks([
CodeBlock(code="print('hello from Firecracker!')", language="python")
])
print(result.output)
# hello from Firecracker!
Set SANDFLARE_API_KEY in your environment to omit the api_key argument.
Persistent State — SandflarePersistentExecutor
Variables, imports, and installed packages are preserved between calls via a persistent Jupyter kernel.
from sandflare_autogen import SandflarePersistentExecutor
from autogen.coding import CodeBlock
with SandflarePersistentExecutor() as executor:
executor.execute_code_blocks([
CodeBlock(code="import numpy as np\nx = np.array([1, 2, 3])", language="python")
])
result = executor.execute_code_blocks([
CodeBlock(code="print(x.mean())", language="python")
])
print(result.output) # 2.0
ConversableAgent Example
from sandflare_autogen import SandflareCodeExecutor
from autogen import ConversableAgent
with SandflareCodeExecutor(api_key="pa_live_...") as executor:
agent = ConversableAgent(
name="coder",
llm_config={"model": "gpt-4o", "api_key": "sk-..."},
code_execution_config={"executor": executor},
)
user = ConversableAgent(
name="user",
human_input_mode="NEVER",
is_termination_msg=lambda x: x.get("content", "").rstrip().endswith("TERMINATE"),
)
user.initiate_chat(
agent,
message="Write Python code to find the 50th prime number. Reply TERMINATE when done.",
)
Constructor Options
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key |
str |
env var | Sandflare API key (SANDFLARE_API_KEY) |
template_id |
str |
"" |
Sandbox template: codebox, ai-agent, browser-agent |
timeout |
int |
60 |
Per-execution timeout in seconds |
persistent |
bool |
False |
Preserve sandbox state across restart() calls |
base_url |
str |
None |
Override API base URL (self-hosted deployments) |
env |
dict |
{} |
Environment variables injected into the sandbox |
Docs
Metadata
Release files for sandflare-autogen 0.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sandflare_autogen-0.1.6.tar.gz | 4.4 kB | Without provenance | Details for sandflare_autogen-0.1.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sandflare_autogen-0.1.6-py3-none-any.whl | Python 3 | none | any | Details for sandflare_autogen-0.1.6-py3-none-any.whl |
Total release size: 9.3 kB
Release files / sandflare_autogen-0.1.6.tar.gz
| Download URL | sandflare_autogen-0.1.6.tar.gz |
|---|---|
| Size | 4.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2183be6edc43ef10533a9e6147ba363397a1413f2957bf9e6311765d3c54c513
|
|
BLAKE2b-256 checksum How to use checksums |
a6d1dbb4c0c0469d07d42d32233922c83c875c05eb85e6ae726b31bc9962742a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / sandflare_autogen-0.1.6-py3-none-any.whl
| Download URL | sandflare_autogen-0.1.6-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a80b01ce038125257378bc28bb9ae9188643117f27d061178efd0d05964393d3
|
|
BLAKE2b-256 checksum How to use checksums |
7f15d9b330bb092e1015de929f1bd052c6075879715827359a9f6737c5ab10a3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Security for sandflare-autogen 0.1.6
Provenance
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.
No provenance found
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.