Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions evaluators/contrib/galileo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@ set `threshold` and `operator` as needed. If you still need the legacy Luna2
evaluator, pin
`agent-control-evaluator-galileo <8`.

Luna requests are sent to the Luna runtime service. Decision Models (Jev) and
LLM-as-judge requests are sent to the external runtime service configured by
`GALILEO_EXTERNAL_INVOKE_URL`. Runtime service-root URLs are expanded to
`/api/v1/scorers/invoke/runtime`; legacy Luna requests continue to use
`/api/v1/scorers/invoke` when the runtime feature flag is disabled. The external
URL is required for Jev and LLM-as-judge and never falls back to the Luna service.

The optional evaluator `config` mirrors Orbit's allowlisted scorer-invoke
configuration. Supported keys are `threshold`, `score_threshold`, and
`request_timeout_seconds`; unsupported keys are rejected locally before an HTTP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

DEFAULT_TIMEOUT_SECS = 10.0
DEFAULT_INTERNAL_TOKEN_TTL_SECS = 3600
DEFAULT_INVOKE_PATH = "/api/v1/scorers/invoke/runtime"
EXTERNAL_INVOKE_URL_ENV = "GALILEO_EXTERNAL_INVOKE_URL"
DEFAULT_INVOKE_PATH = "/api/v1/scorers/invoke"
LUNA_INVOKE_URL_ENV = "GALILEO_LUNA_INVOKE_URL"
AUTH_UPSTREAM_CA_FILE_ENV = "AGENT_CONTROL_AUTH_UPSTREAM_CA_FILE"
DEFAULT_KEEPALIVE_EXPIRY_SECS = 1.0
DEFAULT_MAX_CONNECTIONS = 100
Expand Down Expand Up @@ -185,9 +185,9 @@ def __init__(
"GALILEO_API_SECRET_KEY or GALILEO_API_SECRET is required for "
"galileo.decision_models"
)
resolved_url = invoke_url or os.getenv(EXTERNAL_INVOKE_URL_ENV)
resolved_url = invoke_url or os.getenv(LUNA_INVOKE_URL_ENV)
if not resolved_url or not resolved_url.strip():
raise ValueError(f"{EXTERNAL_INVOKE_URL_ENV} is required for galileo.decision_models")
raise ValueError(f"{LUNA_INVOKE_URL_ENV} is required for galileo.decision_models")
self.api_secret = resolved_secret
self.invoke_url = _normalize_invoke_url(resolved_url)
self.runtime_enabled = scorer_invoke_runtime_enabled()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
DEFAULT_TIMEOUT_SECS = 10.0
SERVER_TIMEOUT_RATIO = 0.8
DEFAULT_INTERNAL_TOKEN_TTL_SECS = 3600
DEFAULT_LLM_SCORER_INVOKE_PATH = "/api/v1/scorers/invoke/runtime"
LLM_INVOKE_URL_ENV = "GALILEO_EXTERNAL_INVOKE_URL"
DEFAULT_LLM_SCORER_INVOKE_PATH = "/api/v1/scorers/invoke"
LLM_INVOKE_URL_ENV = "GALILEO_LUNA_INVOKE_URL"
LLM_INVOKE_CA_FILE_ENV = "GALILEO_LUNA_INVOKE_CA_FILE"
AUTH_UPSTREAM_CA_FILE_ENV = "AGENT_CONTROL_AUTH_UPSTREAM_CA_FILE"

Expand Down Expand Up @@ -354,7 +354,7 @@ class GalileoLLMClient:
GALILEO_FEATURE_FLAG_LLM_EVALUATOR: Set to ``enabled`` to activate the evaluator.
Required; the evaluator is unavailable until this flag is set.
GALILEO_API_SECRET_KEY or GALILEO_API_SECRET: JWT signing secret for internal auth.
GALILEO_EXTERNAL_INVOKE_URL: LLM scorer invoke URL or service root (required).
GALILEO_LUNA_INVOKE_URL: LLM scorer invoke URL or service root (required).
GALILEO_LUNA_INVOKE_CA_FILE: CA bundle used to verify invoke TLS.
AGENT_CONTROL_AUTH_UPSTREAM_CA_FILE: Shared internal CA fallback.
GALILEO_LUNA_KEEPALIVE_EXPIRY_SECONDS: HTTP pooled connection expiry.
Expand All @@ -375,7 +375,7 @@ def __init__(
api_secret: Internal JWT signing secret. If not provided, reads from
GALILEO_API_SECRET_KEY or GALILEO_API_SECRET.
llm_invoke_url: LLM scorer invoke URL or service root. If not provided,
reads from GALILEO_EXTERNAL_INVOKE_URL.
reads from GALILEO_LUNA_INVOKE_URL.
llm_invoke_ca_file: Optional CA bundle used to verify invoke TLS. If not
provided, reads from GALILEO_LUNA_INVOKE_CA_FILE, then
AGENT_CONTROL_AUTH_UPSTREAM_CA_FILE.
Expand All @@ -397,7 +397,7 @@ def __init__(
resolved_llm_invoke_url = llm_invoke_url or os.getenv(LLM_INVOKE_URL_ENV)
if resolved_llm_invoke_url is None or resolved_llm_invoke_url.strip() == "":
raise ValueError(
"GALILEO_EXTERNAL_INVOKE_URL is required for LLM scorer invocation. "
"GALILEO_LUNA_INVOKE_URL is required for LLM scorer invocation. "
"Set it as an environment variable or pass it to the constructor."
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
SERVER_TIMEOUT_RATIO = 0.8
DEFAULT_INTERNAL_TOKEN_TTL_SECS = 3600
DEFAULT_LUNA_SCORER_INVOKE_PATH = "/api/v1/scorers/invoke"
DEFAULT_LUNA_RUNTIME_SCORER_INVOKE_PATH = "/api/v1/scorers/invoke/runtime"
LUNA_INVOKE_URL_ENV = "GALILEO_LUNA_INVOKE_URL"
LUNA_INVOKE_CA_FILE_ENV = "GALILEO_LUNA_INVOKE_CA_FILE"
AUTH_UPSTREAM_CA_FILE_ENV = "AGENT_CONTROL_AUTH_UPSTREAM_CA_FILE"
Expand Down Expand Up @@ -89,18 +88,13 @@ def _internal_auth_token(
return f"{signing_input}.{_b64url(signature)}"


def _normalize_luna_invoke_url(raw_url: str, *, runtime_enabled: bool) -> str:
"""Use full invoke URLs as-is and append the active path to bare service roots."""
def _normalize_luna_invoke_url(raw_url: str) -> str:
"""Use full invoke URLs as-is and append the default path to bare service roots."""
url = raw_url.strip().rstrip("/")
parsed = urlsplit(url)
if parsed.path not in ("", "/") or parsed.query or parsed.fragment:
return url
invoke_path = (
DEFAULT_LUNA_RUNTIME_SCORER_INVOKE_PATH
if runtime_enabled
else DEFAULT_LUNA_SCORER_INVOKE_PATH
)
return f"{url}{invoke_path}"
return f"{url}{DEFAULT_LUNA_SCORER_INVOKE_PATH}"


def _load_float_env(env_name: str, default: float) -> float:
Expand Down Expand Up @@ -423,10 +417,7 @@ def __init__(

self.api_secret = resolved_api_secret
self.runtime_enabled = scorer_invoke_runtime_enabled()
self.luna_invoke_url = _normalize_luna_invoke_url(
resolved_luna_invoke_url,
runtime_enabled=self.runtime_enabled,
)
self.luna_invoke_url = _normalize_luna_invoke_url(resolved_luna_invoke_url)
self.luna_invoke_ca_file = (
luna_invoke_ca_file
or os.getenv(LUNA_INVOKE_CA_FILE_ENV)
Expand Down
22 changes: 10 additions & 12 deletions evaluators/contrib/galileo/tests/test_decision_models_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def _decode_jwt_segment(segment: str) -> dict[str, Any]:

def _evaluator(monkeypatch: pytest.MonkeyPatch, **config: Any) -> DecisionModelsEvaluator:
monkeypatch.setenv("GALILEO_API_SECRET_KEY", "test-secret")
monkeypatch.setenv("GALILEO_EXTERNAL_INVOKE_URL", "http://runners-external:8090")
monkeypatch.setenv("GALILEO_LUNA_INVOKE_URL", "http://runners:8090")
monkeypatch.setenv("GALILEO_FEATURE_FLAG_SCORER_INVOKE_RUNTIME", "enabled")
monkeypatch.setenv("GALILEO_FEATURE_FLAG_DECISION_MODELS_EVALUATOR", "enabled")
evaluator = DecisionModelsEvaluator(
Expand Down Expand Up @@ -156,31 +156,29 @@ def test_config_allows_missing_threshold_for_any_operator() -> None:


@pytest.mark.asyncio
async def test_client_url_resolution_prefers_explicit_url_then_external_environment(
async def test_client_url_resolution_prefers_explicit_url_then_luna_environment(
monkeypatch: pytest.MonkeyPatch,
) -> None:
monkeypatch.setenv("GALILEO_API_SECRET_KEY", "test-secret")
monkeypatch.setenv("GALILEO_LUNA_INVOKE_URL", "http://luna:8090")
monkeypatch.setenv("GALILEO_EXTERNAL_INVOKE_URL", "http://external:8090")

explicit_client = GalileoDecisionModelsClient(invoke_url="http://explicit:8090")
environment_client = GalileoDecisionModelsClient()

expected_path = "/api/v1/scorers/invoke/runtime"
expected_path = "/api/v1/scorers/invoke"
assert explicit_client.invoke_url == f"http://explicit:8090{expected_path}"
assert environment_client.invoke_url == f"http://external:8090{expected_path}"
assert environment_client.invoke_url == f"http://luna:8090{expected_path}"
await explicit_client.close()
await environment_client.close()


def test_client_requires_external_invoke_url_when_no_explicit_url_is_given(
def test_client_requires_luna_invoke_url_when_no_explicit_url_is_given(
monkeypatch: pytest.MonkeyPatch,
) -> None:
monkeypatch.setenv("GALILEO_API_SECRET_KEY", "test-secret")
monkeypatch.setenv("GALILEO_LUNA_INVOKE_URL", "http://luna:8090")
monkeypatch.delenv("GALILEO_EXTERNAL_INVOKE_URL", raising=False)
monkeypatch.delenv("GALILEO_LUNA_INVOKE_URL", raising=False)

with pytest.raises(ValueError, match="GALILEO_EXTERNAL_INVOKE_URL"):
with pytest.raises(ValueError, match="GALILEO_LUNA_INVOKE_URL"):
GalileoDecisionModelsClient()


Expand Down Expand Up @@ -441,7 +439,7 @@ async def test_client_serializes_full_record_context_and_uses_timeout(
monkeypatch: pytest.MonkeyPatch, record_type: str
) -> None:
monkeypatch.setenv("GALILEO_API_SECRET_KEY", "test-secret")
monkeypatch.setenv("GALILEO_EXTERNAL_INVOKE_URL", "http://runners-external:8090")
monkeypatch.setenv("GALILEO_LUNA_INVOKE_URL", "http://runners:8090")
monkeypatch.setenv("GALILEO_FEATURE_FLAG_SCORER_INVOKE_RUNTIME", "enabled")
client = GalileoDecisionModelsClient()
seen: dict[str, Any] = {}
Expand Down Expand Up @@ -520,7 +518,7 @@ async def handler(request: httpx.Request) -> httpx.Response:
timeout=5.0,
)
assert response.score == 0.9
assert seen["url"] == "http://runners-external:8090/api/v1/scorers/invoke/runtime"
assert seen["url"] == "http://runners:8090/api/v1/scorers/invoke"
payload = json.loads(seen["payload"])
assert payload["scorer_version_id"] == "version-a"
assert payload["execution_context"]["user_id"] == "user-7"
Expand Down Expand Up @@ -812,7 +810,7 @@ def test_numeric_comparison_rejects_non_numeric_threshold_from_unvalidated_confi
monkeypatch: pytest.MonkeyPatch,
) -> None:
monkeypatch.setenv("GALILEO_API_SECRET_KEY", "test-secret")
monkeypatch.setenv("GALILEO_EXTERNAL_INVOKE_URL", "http://runners-external:8090")
monkeypatch.setenv("GALILEO_LUNA_INVOKE_URL", "http://runners:8090")
config = DecisionModelsEvaluatorConfig.model_construct(
scorer_id="scorer-a",
scorer_version_id="version-a",
Expand Down
15 changes: 7 additions & 8 deletions evaluators/contrib/galileo/tests/test_llm_coverage_gaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

LLM_ENV = {
"GALILEO_API_SECRET_KEY": "test-secret",
"GALILEO_EXTERNAL_INVOKE_URL": "http://external-invoke:8090",
"GALILEO_LUNA_INVOKE_URL": "http://luna-invoke:8090",
"GALILEO_FEATURE_FLAG_LLM_EVALUATOR": "enabled",
}

Expand Down Expand Up @@ -661,21 +661,20 @@ def test_client_raises_when_no_api_secret(monkeypatch):
"""The client requires GALILEO_API_SECRET_KEY or GALILEO_API_SECRET."""
for name in ("GALILEO_API_SECRET_KEY", "GALILEO_API_SECRET"):
monkeypatch.delenv(name, raising=False)
monkeypatch.setenv("GALILEO_EXTERNAL_INVOKE_URL", "http://external-invoke:8090")
monkeypatch.setenv("GALILEO_LUNA_INVOKE_URL", "http://luna-invoke:8090")
from agent_control_evaluator_galileo.llm.client import GalileoLLMClient

with pytest.raises(ValueError, match="GALILEO_API_SECRET_KEY or GALILEO_API_SECRET"):
GalileoLLMClient()


def test_client_raises_when_no_llm_invoke_url(monkeypatch):
"""The client requires GALILEO_EXTERNAL_INVOKE_URL."""
"""The client requires GALILEO_LUNA_INVOKE_URL."""
monkeypatch.setenv("GALILEO_API_SECRET_KEY", "test-secret")
monkeypatch.setenv("GALILEO_LUNA_INVOKE_URL", "http://luna-invoke:8090")
monkeypatch.delenv("GALILEO_EXTERNAL_INVOKE_URL", raising=False)
monkeypatch.delenv("GALILEO_LUNA_INVOKE_URL", raising=False)
from agent_control_evaluator_galileo.llm.client import GalileoLLMClient

with pytest.raises(ValueError, match="GALILEO_EXTERNAL_INVOKE_URL"):
with pytest.raises(ValueError, match="GALILEO_LUNA_INVOKE_URL"):
GalileoLLMClient()


Expand Down Expand Up @@ -703,7 +702,7 @@ def test_client_posts_to_correct_llm_invoke_endpoint(monkeypatch):
client = GalileoLLMClient()
endpoint, _ = client._endpoint_and_auth_header()

assert endpoint == "http://external-invoke:8090/api/v1/scorers/invoke/runtime"
assert endpoint == "http://luna-invoke:8090/api/v1/scorers/invoke"


def test_client_does_not_use_old_api_paths(monkeypatch):
Expand All @@ -716,7 +715,7 @@ def test_client_does_not_use_old_api_paths(monkeypatch):
endpoint, _ = client._endpoint_and_auth_header()

assert "/scorers/invoke" in endpoint
assert endpoint.startswith("http://external-invoke:8090/api/v1/")
assert endpoint.startswith("http://luna-invoke:8090/api/v1/")
assert "/internal/scorers/invoke" not in endpoint


Expand Down
2 changes: 1 addition & 1 deletion evaluators/contrib/galileo/tests/test_llm_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

LLM_ENV = {
"GALILEO_API_SECRET_KEY": "test-secret",
"GALILEO_EXTERNAL_INVOKE_URL": "http://external-invoke:8090",
"GALILEO_LUNA_INVOKE_URL": "http://luna-invoke:8090",
"GALILEO_FEATURE_FLAG_LLM_EVALUATOR": "enabled",
}

Expand Down
3 changes: 1 addition & 2 deletions evaluators/contrib/galileo/tests/test_luna_coverage_gaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,13 +459,12 @@ def test_client_posts_to_correct_luna_invoke_endpoint(monkeypatch):
"""_endpoint_and_auth_header must return the Luna invoke endpoint path."""
for key, value in LUNA_ENV.items():
monkeypatch.setenv(key, value)
monkeypatch.setenv("GALILEO_FEATURE_FLAG_SCORER_INVOKE_RUNTIME", "enabled")
from agent_control_evaluator_galileo.luna.client import GalileoLunaClient

client = GalileoLunaClient()
endpoint, _ = client._endpoint_and_auth_header()

assert endpoint == "http://luna-invoke:8090/api/v1/scorers/invoke/runtime"
assert endpoint == "http://luna-invoke:8090/api/v1/scorers/invoke"


def test_client_does_not_use_old_api_paths(monkeypatch):
Expand Down
12 changes: 3 additions & 9 deletions evaluators/contrib/galileo/tests/test_luna_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,7 @@ def test_client_normalizes_luna_invoke_service_root(self) -> None:
):
client = GalileoLunaClient()

assert client.luna_invoke_url == (
"http://luna-invoke:8090/api/v1/scorers/invoke/runtime"
)
assert client.luna_invoke_url == "http://luna-invoke:8090/api/v1/scorers/invoke"

def test_client_uses_full_luna_invoke_url_as_configured(self) -> None:
from agent_control_evaluator_galileo.luna import GalileoLunaClient
Expand Down Expand Up @@ -695,11 +693,9 @@ def handler(request: httpx.Request) -> httpx.Response:
finally:
await client.close()

# Then: posts to the Luna runtime endpoint with JWT and no Galileo-API-Key
# Then: posts to luna invoke endpoint /api/v1/scorers/invoke with JWT, no Galileo-API-Key
assert response.score == 0.82
assert captured["url"] == (
"http://luna-invoke:8090/api/v1/scorers/invoke/runtime"
)
assert captured["url"] == "http://luna-invoke:8090/api/v1/scorers/invoke"
expected_body = {
"scorer_id": SCORER_ID,
"execution_context": {
Expand Down Expand Up @@ -905,7 +901,6 @@ async def test_client_uses_legacy_request_without_runtime_flag(
captured: dict[str, object] = {}

def handler(request: httpx.Request) -> httpx.Response:
captured["url"] = str(request.url)
captured["body"] = json.loads(request.content.decode())
return httpx.Response(200, json={"score": 0.8, "status": "success"})

Expand Down Expand Up @@ -938,7 +933,6 @@ def handler(request: httpx.Request) -> httpx.Response:

body = captured["body"]
assert isinstance(body, dict)
assert captured["url"] == "http://luna-invoke:8090/api/v1/scorers/invoke"
assert body["scorer_id"] == SCORER_ID
assert body["scorer_version_id"] == SCORER_VERSION_ID
assert body["inputs"] == {
Expand Down
Loading