The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(approval): honor plugin container guard classification
KoNit-K3fc1a184f8c0
diff --git a/tests/tools/test_modal_sandbox_fixes.py b/tests/tools/test_modal_sandbox_fixes.pyindex ab0be172878..e28e86fd631 100644--- a/tests/tools/test_modal_sandbox_fixes.py+++ b/tests/tools/test_modal_sandbox_fixes.py@@ -384,6 +384,45 @@ class TestDockerHostBindApproval:assert A._should_skip_container_guards("daytona") is Trueassert A._should_skip_container_guards("local") is False+ def test_registered_disposable_plugin_skips_container_guards(self):+ """Plugin classification uses its registered provider, not built-in names only."""+ from agent import terminal_env_registry+ from agent.terminal_env_provider import TerminalEnvironmentProvider+ import tools.approval as A++ class DisposablePlugin(TerminalEnvironmentProvider):+ name = "approval_disposable_plugin"+ display_name = "Approval disposable plugin"++ def is_available(self):+ return True++ def create_environment(self, **kwargs):+ raise NotImplementedError++ provider = DisposablePlugin()+ previous = terminal_env_registry.get_provider(provider.name)+ terminal_env_registry.register_provider(provider)+ try:+ assert A._should_skip_container_guards(provider.name) is True+ assert A._should_skip_container_guards("unknown_plugin_backend") is False+ finally:+ terminal_env_registry.restore_registration(provider.name, provider, previous)++ class BrokenDisposablePlugin(DisposablePlugin):+ name = "broken_approval_disposable_plugin"++ @property+ def skip_container_guards(self):+ raise RuntimeError("broken plugin classification")++ broken_provider = BrokenDisposablePlugin()+ terminal_env_registry.register_provider(broken_provider)+ try:+ assert A._should_skip_container_guards(broken_provider.name) is False+ finally:+ terminal_env_registry.restore_registration(broken_provider.name, broken_provider, None)+def test_isolated_docker_keeps_fast_path(self, monkeypatch):"""Isolated Docker still bypasses dangerous-command approval."""import tools.approval as Adiff --git a/tools/approval.py b/tools/approval.pyindex 062cd78c035..24330d20894 100644--- a/tools/approval.py+++ b/tools/approval.py@@ -19,6 +19,7 @@ import osimport threadingfrom typing import Optional+from agent import terminal_env_registryfrom utils import env_var_enabled, is_truthy_valuefrom tools import approval_contextfrom tools.approval_context import (@@ -1002,7 +1003,9 @@ def _should_skip_container_guards(env_type: str, has_host_access: bool = False)exception once host paths are bind-mounted: ``rm -rf /workspace`` then reaches host files."""if env_type == "docker":return not has_host_access- return env_type in ("singularity", "modal", "daytona", "vercel_sandbox")+ if env_type in ("singularity", "modal", "daytona", "vercel_sandbox"):+ return True+ return terminal_env_registry.provider_flag(env_type, "skip_container_guards", False)def _user_deny_block(command: str) -> dict | None: