feat(ai-red-teaming): tear down provisioned environments on assessment completion - #137
Merged
Conversation
…t completion Hosted sandboxes bill for their whole lifetime, but the capability provisioned them and never tore them down: provision_environment created a TaskEnvironment, returned its URL, and dropped the handle. A TUI session would leak a sandbox that billed until the platform TTL reaped it (~30 min). Add an environment lifecycle to the capability: - A file-based session registry records every provisioned environment. - provision_environment registers the sandbox and surfaces its id. - teardown_environment(id?, older_than_sec) reaps one or all; idempotent (already-gone counts as torn down); an older_than_sec grace window protects an in-flight attack. - update_assessment_status reaps the whole session registry when it marks the assessment complete (best-effort - never breaks status recording), with an AIRT_ENV_TEARDOWN_GRACE_SEC guard so a trailing attack still finishes. - The sandbox timeout_sec remains the backstop if completion never fires. Bumps capability 1.11.0 -> 1.12.0 (immutable content requires a version bump). 17 new unit tests cover the registry, teardown (all/single/missing/error/grace), the session helper's no-network short-circuit, and the completion hook wiring.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Hosted sandboxes bill for their whole lifetime, but the
ai-red-teamingcapability provisioned them and never tore them down.provision_environmentcreated aTaskEnvironment, returned its/attackURL, and dropped the handle - nothing ever calledteardown(), and it did not even surface the environmentid. A TUI red-teaming session would leak its sandbox, which kept billing until the platform TTL reaped it (~30 min after the attack finished).This is capability-only (no SDK/platform changes).
What changed
Added an environment lifecycle to the capability:
tools/environments.py) - a file-based record (AIRT_ENV_REGISTRY_PATH, default/tmp/airt_environments.json) of every provisioned environment, so teardown works across separate tool invocations in one session.provision_environmentnow registers the sandbox and returns itsid.teardown_environment(environment_id?, older_than_sec)- new tool. Reaps one env or the whole session. Idempotent (an already-gone env counts as torn down).older_than_secis a grace window so a still-running attack is not killed.update_assessment_statusreaps the session registry the moment it flips the assessment tocompleted. Best-effort: teardown failure never breaks status recording.AIRT_ENV_TEARDOWN_GRACE_SEC(default 0) keeps very recently provisioned sandboxes alive so a trailing attack finishes.timeout_secstill reaps if completion never fires.Bumps capability 1.11.0 -> 1.12.0 (immutable content requires a version bump).
Tests
tests/test_environments_teardown.py- 17 new unit tests (all pure, no network):Validation
pytest tests/test_environments_teardown.py tests/test_assessment_tracker.py-> 24 passed.test_attack_runner.py::TestGenerateMultimodalAttack::test_generates_compiling_script_with_image) confirmed failing onorigin/main, unrelated to this change.