|
17 | 17 | LUNA_ENV = { |
18 | 18 | "GALILEO_API_SECRET_KEY": "test-secret", |
19 | 19 | "GALILEO_LUNA_INVOKE_URL": "http://luna-invoke:8090", |
| 20 | + "GALILEO_FEATURE_FLAG_SCORER_INVOKE_RUNTIME": "enabled", |
| 21 | +} |
| 22 | +LEGACY_LUNA_ENV = { |
| 23 | + "GALILEO_API_SECRET_KEY": "test-secret", |
| 24 | + "GALILEO_LUNA_INVOKE_URL": "http://luna-invoke:8090", |
20 | 25 | } |
21 | 26 | SCORER_ID = "3d45ef0d-5f14-4f1a-a8f1-8ab758da18b4" |
22 | 27 | SCORER_VERSION_ID = "07fb9c96-9752-4cf5-a253-1a396100e9d2" |
@@ -885,6 +890,60 @@ def handler(request: httpx.Request) -> httpx.Response: |
885 | 890 | "config": {"request_timeout_seconds": 8.0}, |
886 | 891 | } |
887 | 892 |
|
| 893 | + @pytest.mark.asyncio |
| 894 | + @pytest.mark.parametrize("flag_value", [None, "disabled", "Enabled"]) |
| 895 | + async def test_client_uses_legacy_request_without_runtime_flag( |
| 896 | + self, flag_value: str | None |
| 897 | + ) -> None: |
| 898 | + from agent_control_evaluator_galileo.luna import GalileoLunaClient |
| 899 | + from agent_control_evaluator_galileo.luna.client import GalileoExecutionContext |
| 900 | + |
| 901 | + captured: dict[str, object] = {} |
| 902 | + |
| 903 | + def handler(request: httpx.Request) -> httpx.Response: |
| 904 | + captured["body"] = json.loads(request.content.decode()) |
| 905 | + return httpx.Response(200, json={"score": 0.8, "status": "success"}) |
| 906 | + |
| 907 | + step = Step( |
| 908 | + type="llm", |
| 909 | + name="answer", |
| 910 | + input="step input", |
| 911 | + output="step output", |
| 912 | + ground_truth={"expected": "answer"}, |
| 913 | + tools=[{"name": "search", "input_schema": {}}], |
| 914 | + ) |
| 915 | + env = LEGACY_LUNA_ENV.copy() |
| 916 | + if flag_value is not None: |
| 917 | + env["GALILEO_FEATURE_FLAG_SCORER_INVOKE_RUNTIME"] = flag_value |
| 918 | + with patch.dict(os.environ, env, clear=True): |
| 919 | + client = GalileoLunaClient() |
| 920 | + client._client = httpx.AsyncClient(transport=httpx.MockTransport(handler)) |
| 921 | + |
| 922 | + try: |
| 923 | + await client.invoke( |
| 924 | + scorer_id=SCORER_ID, |
| 925 | + scorer_version_id=SCORER_VERSION_ID, |
| 926 | + input="selected input", |
| 927 | + output="selected output", |
| 928 | + step=step, |
| 929 | + execution_context=GalileoExecutionContext(organization_id="org-1"), |
| 930 | + ) |
| 931 | + finally: |
| 932 | + await client.close() |
| 933 | + |
| 934 | + body = captured["body"] |
| 935 | + assert isinstance(body, dict) |
| 936 | + assert body["scorer_id"] == SCORER_ID |
| 937 | + assert body["scorer_version_id"] == SCORER_VERSION_ID |
| 938 | + assert body["inputs"] == { |
| 939 | + "query": "selected input", |
| 940 | + "response": "selected output", |
| 941 | + "ground_truth": {"expected": "answer"}, |
| 942 | + "tools": [{"name": "search", "input_schema": {}}], |
| 943 | + } |
| 944 | + assert "record" not in body |
| 945 | + assert "execution_context" not in body |
| 946 | + |
888 | 947 | @pytest.mark.asyncio |
889 | 948 | async def test_client_omits_record_when_step_has_no_pinned_version(self) -> None: |
890 | 949 | from agent_control_evaluator_galileo.luna import GalileoLunaClient |
|
0 commit comments