Add SandboxToolset for isolated agent code execution in common.ai - #68847
Add SandboxToolset for isolated agent code execution in common.ai#68847zozo123 wants to merge 9 commits into
Conversation
|
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide
|
|
Converted to draft to ensure, this is discussed on the mailing list first. My first main concern (without looking into much details) is how would this integrate with Common AI Provider and why should it be separate provider instead of part of |
|
Agrees with @kaxil - we also need to know that we have real person behind who is comitted to maintain it - not only drop AI generatad code, so discussion on devlist is a minimum, ideally some good discussion about why this is a good idea - and explaining (in human words) some rationale behind it, and choice of the sandbox "providers" (which cannot be named providers due to obvious conflict) - ideally you should present your idea, how it is already used and what actual real-use problems it solves at our dev call. |
|
Thanks @kaxil @potiuk — pivoted per your feedback. It's no longer a separate provider: it's now a Not single-vendor: the same per-session-microVM primitive now exists in AWS Lambda microVMs (Firecracker, shipped 2026-06-22 for "user or AI-generated code"), Daytona, E2B, Modal, and islo. The local backend needs no credentials. On maintenance: I'll own it — I'm at Incredibuild and islo (islo.dev) is our product, so there's a committed maintainer and real usage behind it, not a drive-by AI PR. The reference backend I commit to is islo. It already works end to end: a real agent's |
You will need to elaborate on that. Since you are new to the community we need to make sure there is a long term promise/ownership. Check out guidelines for adding new providers |
|
Thanks @eladkal, that's a fair bar and I appreciate you spelling it out. Two named maintainers at Incredibuild will own this long term: myself (@zozo123, yossi.eliaz@incredibuild.com) and Yuval Raz (yuval.r@incredibuild.com). support@incredibuild.com is our team alias, also committed and monitored by the islo team for issues and escalations. Incredibuild builds islo (islo.dev), a commercial product, so we have a direct reason to keep this alive. We'll land the first commit and maintain both the The backend interface is pluggable so any vendor can own its own. We plan to invite E2B, AWS (Lambda microVMs), Daytona, and Tensorlake; whether they pick it up is on them. We're not asking the community to carry single-vendor code. We'll answer issues and PRs, and meet the incubation and governance commitments in ACCEPTING_PROVIDERS. One scope note: this is a I'm new here, so who's the right committer to approach as a sponsor? I'll start the |
Should there be a need for this new provider I am happy to be the sponsor but lets take it one step at a time. The item in #68847 (comment) must be answered first. |
55cf22b to
64dde2d
Compare
Add the apache-airflow-providers-sandbox provider whose SandboxExecutor runs each task instance in an ephemeral cloud sandbox behind a pluggable backend layer (local subprocess reference backend plus Daytona, E2B, Modal, islo). It implements the public BaseExecutor interface only, with no core changes (AIP-51), and follows the Airflow 3 Task SDK / EdgeExecutor topology: the in-sandbox supervisor heartbeats and ships logs to the api-server while the executor reconciles terminal exit state from a polling watcher that distinguishes a transient UNKNOWN from a confirmed GONE, so a single failed poll never kills a healthy task. remote_logging is enforced at start(); get_task_log is a documented best-effort fallback. Adoption uses deterministic, labelled sandbox names where the backend supports reattach. Includes provider.yaml (executors registration), get_provider_info, unit tests for the backend contract and the watcher logic, docs, and the boring-cyborg label mapping. Relates to: apache#68845 Generated-by: Claude (Anthropic) Signed-off-by: zozo123 <yossi.eliaz@incredibuild.com>
Add a SandboxOperator and a @task.sandbox TaskFlow decorator (mirroring @task.bash) that run a command in an ephemeral sandbox from a normal task — the executor-free way to adopt sandboxes, verified end-to-end on Airflow 3. Register the decorator via the provider's task-decorators. Switch the e2b backend to the Sandbox.create() classmethod and rewrite the islo backend against the real islo SDK (sandboxes resource: create_sandbox/ exec_in_sandbox/get_exec_result/delete_sandbox, name-keyed, pause/resume). Add operator and islo unit tests. Generated-by: Claude (Anthropic) Signed-off-by: zozo123 <yossi.eliaz@incredibuild.com>
…ests Replace the SandboxExecutor's stubbed command rendering with the real Airflow 3 path: serialize the ExecuteTask workload (incl. its JWT) into the sandbox via env and run an in-sandbox entrypoint (execution_time.run_workload) that calls the Task SDK supervise() against the Execution API server, as Celery/Edge do. Carrying the workload via env (not upload) also covers upload-less backends. Add unit tests for the runner and command/env rendering, and a tests/system/ suite (local backend always-on; SaaS backends gated on their API keys) as the continuous validation plan. Generated-by: Claude (Anthropic) Signed-off-by: zozo123 <yossi.eliaz@incredibuild.com>
Generated-by: Claude (Anthropic) Signed-off-by: zozo123 <yossi.eliaz@incredibuild.com>
Make the sandbox provider conform to apache/airflow provider requirements found by a completeness audit: - provider.yaml: fix invalid 'lifecycle: development' -> 'incubation' (schema enum) - add version_compat.py (per-provider convention) and route the operator's BaseOperator import through it - remove the orphaned, untested SandboxHook (executor + operator + @task.sandbox are the shipping surface); no connection-types needed - docs: add conf.py, security.rst, installing-providers-from-sources.rst, commits.rst, an operators guide (operators/index.rst + sandbox.rst covering SandboxOperator and @task.sandbox), and wire the index.rst toctree - system tests: keep the conforming example_sandbox.py (get_test_run) and drop the non-conforming pytest-style system test (its cases are covered by unit tests) - register the provider in root pyproject.toml (uv workspace members, uv sources, mypy paths) and add Daytona/E2B/islo to docs/spelling_wordlist.txt - add providers/sandbox/.gitignore; satisfy the monorepo ruff config (all checks pass) NOTE: generated/provider_dependencies.json and generated/provider_metadata.json are produced by `breeze`/`prek` codegen (their checksum is over provider.yaml inputs) and must be regenerated by a committer running `prek run --all-files` / `breeze` — they cannot be correctly hand-authored. 22 unit/system tests pass; ruff clean under the monorepo config. Generated-by: Claude (Anthropic) Signed-off-by: zozo123 <yossi.eliaz@incredibuild.com>
Run apache's own generators (scripts/ci/prek/update_providers_dependencies.py and update_airflow_pyproject_toml.py) so the new provider is registered authoritatively rather than by hand: add the sandbox entry to generated/provider_dependencies.json, recompute its breeze checksum, and add the sandbox extra / workspace member / uv source / mypy paths / exclude-newer entries in the root pyproject.toml. provider_metadata.json is unchanged by design (it is release history; the provider is unreleased). Generated-by: Claude (Anthropic) Signed-off-by: zozo123 <yossi.eliaz@incredibuild.com>
Sandbox backends need a local Docker path and must not requeue work until the executor can prove the previous generation is fully fenced. This also aligns the Islo driver with the generation-based common sandbox engine.
64dde2d to
9205f00
Compare
Summary
Adds a
SandboxToolsetto the Common AI provider. It gives an agent a code-execution tool that runs model-generated Python in a separate sandbox with a full Python runtime and the dependencies supplied by that environment.This complements the restricted Monty code mode added by #68407; it is not an Airflow executor and does not implement the future whole-task execution tracked by #68845.
Placement in Airflow's sandboxed-execution model
These are separate execution boundaries, not one progressively stronger API:
SandboxOperator, tracked by #69862ExecuteTaskworkloadSandboxExecutor, tracked by #68845Non-goals
This PR does not:
AgentOperator, LLM calls, or the complete Airflow task off the worker;The
SandboxBackendintroduced here is a narrow agent code-execution adapter. A future executor should use Airflow's existingBaseExecutorandExecuteTaskcontracts.Relationship to Monty code mode
Monty code mode is deny-by-default: generated Monty code cannot directly access the worker filesystem, environment, or network. It can invoke only registered tools, which continue to run on the worker with the capabilities explicitly granted by the DAG author.
SandboxToolsetaddresses a different use case: generated code that needs full Python, third-party packages, a filesystem, or heavier computation in a separate execution boundary. It is an alternative code-execution surface, not evidence that Monty directly exposes worker credentials.Design and hardening
SandboxBackendcontract providescreate,run, anddestroy.timeoutexpiry and SIGKILL escalation, without misclassifying an immediate exit 137.KeyErrorfailures.Initial backends
sbxCLI, as a host-local microVM backend.The abstraction is open to independently maintained Daytona, Tensorlake, E2B, and other adapters, but this PR does not claim uniform provider behavior beyond its tested contract.
Prerequisites
sbxCLI on a supported worker host. Linux workers require KVM/nested-virtualization support.apache-airflow-providers-common-ai[sandbox-islo]and configure an Airflow connection or the supported SDK environment credentials.Verification
Live end-to-end checks against both initial backends covered basic execution, nonzero exits, stderr, file persistence across calls, timeouts, and teardown.
The final rebased branch was also validated with:
uv lock --checkandgit diff --check.Continuous live service conformance can be expanded separately without widening this PR into the future operator/executor work.
Maintenance
Maintained by Yossi Eliaz (@zozo123) and Yuval Raz at Incredibuild/islo, with the islo team providing direct ownership of the hosted adapter. Other hosted adapters should preferably have explicit vendor or third-party ownership.
Related work
SandboxExecutortracker.Was generative AI tooling used to co-author this PR?
Generated with generative AI assistance following the project guidelines.