Skip to content

The agent that grows with you

test: match plugin opens by path component, not a POSIX substring

Tekniumf5c0b99ebf61
diff --git a/tests/agent/test_safe_worker_policy.py b/tests/agent/test_safe_worker_policy.py
index 68f107d01b9..985b421fdc9 100644
--- a/tests/agent/test_safe_worker_policy.py
+++ b/tests/agent/test_safe_worker_policy.py
@@ -132,7 +132,7 @@ def test_safe_worker_never_discovers_or_invokes_customizations(tmp_path, mode):
_bind_safe_worker_policy(safe_mode=mode == "safe", ignore_user_config=True, config={"plugins": {"enabled": ["sentinel"]}})
reads = []
def audit(event, args):
- if event == "open" and "/plugins/" in str(args[0]) and args[1] != "w":
+ if event == "open" and "plugins" in Path(str(args[0])).parts and args[1] != "w":
reads.append(str(args[0]))
sys.addaudithook(audit)
import providers
diff --git a/tests/tools/test_safe_worker_tools.py b/tests/tools/test_safe_worker_tools.py
index add590fae0b..28e3f8b2e27 100644
--- a/tests/tools/test_safe_worker_tools.py
+++ b/tests/tools/test_safe_worker_tools.py
@@ -46,14 +46,14 @@ def test_actual_agent_tool_round_never_loads_plugins_in_safe_worker(tmp_path, mo
_bind_safe_worker_policy(safe_mode=mode == 'safe', ignore_user_config=True, config=config)
reads, executions = [], []
def audit(event, args):
- if event == 'open' and '/plugins/' in str(args[0]) and args[1] != 'w':
+ if event == 'open' and 'plugins' in Path(str(args[0])).parts and args[1] != 'w':
frame = sys._getframe(); stack = []
while frame:
if 'importlib' not in frame.f_code.co_filename:
stack.append((frame.f_code.co_filename, frame.f_lineno))
frame = frame.f_back
reads.append((str(args[0]), stack))
- if event == 'exec' and '/plugins/' in str(getattr(args[0], 'co_filename', '')):
+ if event == 'exec' and 'plugins' in Path(str(getattr(args[0], 'co_filename', ''))).parts:
executions.append(args[0].co_filename)
sys.addaudithook(audit)
from run_agent import AIAgent