Skip to content

The agent that grows with you

fix: fail soft to guards-on when the terminal env registry lookup raises

teknium11a1b114343b7
diff --git a/tests/tools/test_modal_sandbox_fixes.py b/tests/tools/test_modal_sandbox_fixes.py
index e28e86fd631..925c4ef1d49 100644
--- a/tests/tools/test_modal_sandbox_fixes.py
+++ b/tests/tools/test_modal_sandbox_fixes.py
@@ -384,6 +384,18 @@ class TestDockerHostBindApproval:
assert A._should_skip_container_guards("daytona") is True
assert A._should_skip_container_guards("local") is False
+ def test_raising_registry_lookup_keeps_container_guards_on(self, monkeypatch):
+ """A registry that raises during the provider lookup must fail soft to guards-on,
+ not propagate out of the approval predicate."""
+ from agent import terminal_env_registry as R
+ import tools.approval as A
+
+ def boom(*_a, **_k):
+ raise RuntimeError("registry down")
+
+ monkeypatch.setattr(R._registry, "get_provider", boom)
+ assert A._should_skip_container_guards("p_disposable") 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
diff --git a/tools/approval.py b/tools/approval.py
index 021b917d567..c22d304fa7c 100644
--- a/tools/approval.py
+++ b/tools/approval.py
@@ -1005,9 +1005,13 @@ def _should_skip_container_guards(env_type: str, has_host_access: bool = False)
if env_type in ("singularity", "modal", "daytona", "vercel_sandbox"):
return True
# Plugin backends declare the same classification through the provider ABI (#94400);
- # fail-soft to False so an unknown or raising backend keeps the guards on.
- from agent.terminal_env_registry import provider_flag
- return bool(provider_flag(env_type, "skip_container_guards", False))
+ # fail-soft to False so an unknown or raising backend — or a raising registry
+ # lookup — keeps the guards on rather than propagating out of the approval predicate.
+ try:
+ from agent.terminal_env_registry import provider_flag
+ return bool(provider_flag(env_type, "skip_container_guards", False))
+ except Exception:
+ return False
def _user_deny_block(command: str) -> dict | None: