Skip to content

Commit f7f263d

Browse files
SecAI-Hubclaude
andcommitted
Fix CI: standardize Python import paths + fix llama.cpp cmake fallback
Python tests: test_adversarial.py and test_m5_acceptance.py used sys.path pointing to services/agent/ with `from agent.models` imports, conflicting with test_agent.py which adds services/ with `from agent.agent.models`. Standardize all three files to use the same services/ root path and agent.agent.* import convention so pytest can collect all test files without import collisions. CI: add PYTHONPATH=services to the Python test step so agent package resolution works in GitHub Actions. Build: fix llama.cpp cmake fallback chain — the first attempt with -DGGML_CUDA=ON caches CUDA settings in build/CMakeCache.txt, causing all fallback attempts to also try CUDA. Clear the build directory (rm -rf build) between fallback attempts so each starts clean. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f44e0db commit f7f263d

4 files changed

Lines changed: 24 additions & 15 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ jobs:
7777
python -m py_compile services/agent/agent/sandbox.py
7878
7979
- name: Test
80+
env:
81+
PYTHONPATH: services
8082
run: python -m pytest tests/ -v
8183

8284
shellcheck:

files/scripts/build-services.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,10 @@ curl -fsSL "https://github.com/ggml-org/llama.cpp/archive/refs/tags/${LLAMA_CPP_
185185
cd "llama.cpp-${LLAMA_CPP_VERSION}"
186186
cmake -B build -DGGML_CUDA=ON -DGGML_VULKAN=ON -DBUILD_SHARED_LIBS=OFF \
187187
-DCMAKE_BUILD_TYPE=Release 2>/dev/null || \
188-
cmake -B build -DGGML_VULKAN=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release 2>/dev/null || \
189-
cmake -B build -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release
188+
{ rm -rf build && cmake -B build -DGGML_VULKAN=ON -DBUILD_SHARED_LIBS=OFF \
189+
-DCMAKE_BUILD_TYPE=Release 2>/dev/null; } || \
190+
{ rm -rf build && cmake -B build -DBUILD_SHARED_LIBS=OFF \
191+
-DCMAKE_BUILD_TYPE=Release; }
190192
cmake --build build --target llama-server -j"$(nproc)"
191193
install -m 755 build/bin/llama-server /usr/bin/llama-server
192194
echo " -> /usr/bin/llama-server"

tests/test_adversarial.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@
2121
from pathlib import Path
2222
from unittest.mock import MagicMock, patch
2323

24-
# Add services directory to path
25-
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "services", "agent"))
24+
# Add services/ to path (same convention as test_agent.py)
25+
_services_root = str(Path(__file__).resolve().parent.parent / "services")
26+
if _services_root not in sys.path:
27+
sys.path.insert(0, _services_root)
2628

27-
from agent.models import (
29+
from agent.agent.models import (
2830
Budgets,
2931
CapabilityToken,
3032
PolicyDecision,
@@ -38,16 +40,16 @@
3840
TaskStatus,
3941
TWO_PHASE_ACTIONS,
4042
)
41-
from agent.policy import PolicyEngine, classify_risk
42-
from agent.storage import StorageGateway
43-
from agent.capabilities import (
43+
from agent.agent.policy import PolicyEngine, classify_risk
44+
from agent.agent.storage import StorageGateway
45+
from agent.agent.capabilities import (
4446
clear_nonce_cache,
4547
create_token,
4648
sign_token,
4749
verify_token,
4850
_reset_signing_key,
4951
)
50-
from agent.sandbox import (
52+
from agent.agent.sandbox import (
5153
WorkspaceGuard,
5254
SubprocessIsolator,
5355
sign_step,

tests/test_m5_acceptance.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@
2626
import unittest
2727
from pathlib import Path
2828

29-
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "services", "agent"))
29+
# Add services/ to path (same convention as test_agent.py)
30+
_services_root = str(Path(__file__).resolve().parent.parent / "services")
31+
if _services_root not in sys.path:
32+
sys.path.insert(0, _services_root)
3033

31-
from agent.models import (
34+
from agent.agent.models import (
3235
Budgets,
3336
CapabilityToken,
3437
PolicyDecision,
@@ -40,16 +43,16 @@
4043
StepStatus,
4144
TWO_PHASE_ACTIONS,
4245
)
43-
from agent.policy import PolicyEngine, classify_risk
44-
from agent.storage import StorageGateway
45-
from agent.capabilities import (
46+
from agent.agent.policy import PolicyEngine, classify_risk
47+
from agent.agent.storage import StorageGateway
48+
from agent.agent.capabilities import (
4649
clear_nonce_cache,
4750
create_token,
4851
sign_token,
4952
verify_token,
5053
_reset_signing_key,
5154
)
52-
from agent.sandbox import (
55+
from agent.agent.sandbox import (
5356
WorkspaceGuard,
5457
SubprocessIsolator,
5558
sign_step,

0 commit comments

Comments
 (0)