Skip to content

Commit 51bc5cd

Browse files
committed
fix(ai-red-teaming): comprehensive Python executable path resolution
Version bump to 1.2.1 and complete fix for sys.executable issues across ALL files in the ai-red-teaming capability. Fixed 5 total files: - ✅ tools/workflows.py (already committed) - ✅ tools/attacks.py - ✅ scripts/workflow_helper.py - ✅ scripts/attack_runner.py - ✅ tests/test_attack_runner.py - ✅ capability.yaml (version: 1.2.0 → 1.2.1) All subprocess calls now use resolve_python_executable() instead of sys.executable to ensure proper UV tool Python environment execution. This comprehensive fix ensures that every part of the ai-red-teaming capability uses the correct Python executable with full SDK dependencies.
1 parent 1c095a5 commit 51bc5cd

5 files changed

Lines changed: 16 additions & 5 deletions

File tree

‎capabilities/ai-red-teaming/capability.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
schema: 1
22
name: ai-red-teaming
3-
version: "1.2.0"
3+
version: "1.2.1"
44
description: >
55
Probe the security and safety of AI applications, agents, and foundation models.
66
Orchestrates adversarial attack workflows to discover vulnerabilities in LLMs,

‎capabilities/ai-red-teaming/scripts/attack_runner.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import time
2121
from pathlib import Path
2222

23+
from dreadnode.app.env import resolve_python_executable
24+
2325
WORKFLOWS_DIR = Path(
2426
os.environ.get(
2527
"AIRT_WORKFLOWS_DIR",
@@ -79,8 +81,9 @@ def _auto_execute_workflow(filename: str, timeout: int = 540) -> str:
7981
return "\n[AUTO-EXECUTE] Syntax error in generated script: {} (line {})".format(e.msg, e.lineno)
8082

8183
try:
84+
python_executable = resolve_python_executable()
8285
result = subprocess.run(
83-
[sys.executable, str(filepath)],
86+
[python_executable, str(filepath)],
8487
cwd=str(WORKFLOWS_DIR.parent),
8588
capture_output=True,
8689
text=True,

‎capabilities/ai-red-teaming/scripts/workflow_helper.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
import time
1414
from pathlib import Path
1515

16+
from dreadnode.app.env import resolve_python_executable
17+
1618
WORKFLOWS_DIR = Path(
1719
os.environ.get(
1820
"AIRT_WORKFLOWS_DIR",
@@ -118,8 +120,9 @@ def execute_workflow(params: dict) -> dict:
118120
timeout = min(timeout, 600) # Max 10 minutes
119121

120122
try:
123+
python_executable = resolve_python_executable()
121124
result = subprocess.run(
122-
[sys.executable, str(filepath)],
125+
[python_executable, str(filepath)],
123126
cwd=str(WORKFLOWS_DIR.parent),
124127
capture_output=True,
125128
text=True,

‎capabilities/ai-red-teaming/tests/test_attack_runner.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
import pytest
1818

19+
from dreadnode.app.env import resolve_python_executable
20+
1921
# ---------------------------------------------------------------------------
2022
# Load attack_runner as a module (it's not a package, just a script)
2123
# ---------------------------------------------------------------------------
@@ -39,8 +41,9 @@ def _generate(params: dict) -> dict:
3941
"""Call attack_runner via subprocess and return JSON result."""
4042
payload = json.dumps({"name": "generate_attack", "parameters": params})
4143
env = {**os.environ, "DREADNODE_WORKSPACE_DIR": "/tmp/airt_test"}
44+
python_executable = resolve_python_executable()
4245
result = subprocess.run(
43-
[sys.executable, str(RUNNER_PATH)],
46+
[python_executable, str(RUNNER_PATH)],
4447
input=payload,
4548
capture_output=True,
4649
text=True,

‎capabilities/ai-red-teaming/tools/attacks.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from pathlib import Path
1919

2020
from dreadnode.agents.tools import tool
21+
from dreadnode.app.env import resolve_python_executable
2122

2223
_RUNNER_SCRIPT = Path(__file__).parent.parent / "scripts" / "attack_runner.py"
2324

@@ -26,8 +27,9 @@ def _call_runner(name: str, params: dict) -> str:
2627
"""Call attack_runner.py via subprocess with JSON dispatch."""
2728
payload = json.dumps({"name": name, "parameters": params})
2829
try:
30+
python_executable = resolve_python_executable()
2931
result = subprocess.run(
30-
[sys.executable, str(_RUNNER_SCRIPT)],
32+
[python_executable, str(_RUNNER_SCRIPT)],
3133
input=payload,
3234
capture_output=True,
3335
text=True,

0 commit comments

Comments
 (0)