@@ -1396,38 +1396,53 @@ async def _run_terminal_bench_task_durable(
13961396 # is held across the container execution await below.
13971397 await session .commit ()
13981398 with _evaluation_workspace (submission , isolate = True ) as agent_workspace :
1399- spec = DockerRunSpec (
1400- image = runner_image ,
1401- command = (
1402- "bash" ,
1403- "-lc" ,
1404- _terminal_bench_script (job , task , plan = plan , backend = execution_backend ),
1405- ),
1406- mounts = (
1407- DockerMount (
1408- source = agent_workspace ,
1409- target = "/workspace/agent" ,
1410- read_only = False ,
1399+ from agent_challenge .evaluation .no_phala import is_no_phala_enabled as _np
1400+
1401+ if _np () and settings .docker_backend in {"cli" , "docker" }:
1402+ run = await asyncio .to_thread (
1403+ _run_no_phala_host_terminal_bench ,
1404+ job = job ,
1405+ task = task ,
1406+ plan = plan ,
1407+ agent_workspace = agent_workspace ,
1408+ miner_env = miner_env ,
1409+ gateway = gateway ,
1410+ execution_backend = execution_backend ,
1411+ timeout_seconds = settings .evaluation_timeout_seconds ,
1412+ )
1413+ else :
1414+ spec = DockerRunSpec (
1415+ image = runner_image ,
1416+ command = (
1417+ "bash" ,
1418+ "-lc" ,
1419+ _terminal_bench_script (job , task , plan = plan , backend = execution_backend ),
14111420 ),
1412- DockerMount (
1413- source = plan .jobs_dir ,
1414- target = str (plan .jobs_dir ),
1415- read_only = False ,
1421+ mounts = (
1422+ DockerMount (
1423+ source = agent_workspace ,
1424+ target = "/workspace/agent" ,
1425+ read_only = False ,
1426+ ),
1427+ DockerMount (
1428+ source = plan .jobs_dir ,
1429+ target = str (plan .jobs_dir ),
1430+ read_only = False ,
1431+ ),
14161432 ),
1417- ),
1418- workdir = "/workspace" ,
1419- env = {
1420- ** _terminal_bench_env (miner_env , gateway ),
1421- ** _terminal_bench_stream_env (plan .attempt_id ),
1422- },
1423- labels = _labels (job , submission , task ),
1424- limits = _terminal_bench_limits (),
1425- )
1426- run = await asyncio .to_thread (
1427- executor .run ,
1428- spec ,
1429- timeout_seconds = settings .evaluation_timeout_seconds ,
1430- )
1433+ workdir = "/workspace" ,
1434+ env = {
1435+ ** _terminal_bench_env (miner_env , gateway ),
1436+ ** _terminal_bench_stream_env (plan .attempt_id ),
1437+ },
1438+ labels = _labels (job , submission , task ),
1439+ limits = _terminal_bench_limits (),
1440+ )
1441+ run = await asyncio .to_thread (
1442+ executor .run ,
1443+ spec ,
1444+ timeout_seconds = settings .evaluation_timeout_seconds ,
1445+ )
14311446 except Exception as exc :
14321447 # The attempt was committed ``running`` before the container await, so a
14331448 # failure here (executor/broker error, ``database is locked``, unexpected
@@ -1997,6 +2012,106 @@ def _own_runner_script(
19972012""" .strip ()
19982013
19992014
2015+
2016+ def _run_no_phala_host_terminal_bench (
2017+ * ,
2018+ job : EvaluationJob ,
2019+ task : BenchmarkTask ,
2020+ plan : TerminalBenchAttemptPlan ,
2021+ agent_workspace : Path ,
2022+ miner_env : Mapping [str , str ] | None ,
2023+ gateway : GatewayExecutionConfig | None ,
2024+ execution_backend : str ,
2025+ timeout_seconds : int ,
2026+ ) -> DockerRunResult :
2027+ """NO_PHALA host-local path: run own_runner in this process namespace.
2028+
2029+ Avoids nested harbor-runner DooD under master embed (container bind paths are
2030+ not host paths for ``docker -v``). The validator already has docker.sock and
2031+ task images; own_runner spawns sibling task containers directly.
2032+ """
2033+ import subprocess
2034+
2035+ from agent_challenge .evaluation .no_phala import is_no_phala_enabled
2036+
2037+ if not is_no_phala_enabled ():
2038+ raise RuntimeError ("no_phala host runner invoked while NO_PHALA is off" )
2039+ if execution_backend != "own_runner" :
2040+ raise ValueError (f"unsupported backend for no_phala host path: { execution_backend } " )
2041+
2042+ task_id = str (task .metadata .get ("task_id" ) or task .task_id )
2043+ bare = task_id .rsplit ("/" , 1 )[- 1 ]
2044+ cache_root = Path (
2045+ settings .own_runner_cache_root
2046+ or "/app/packages/challenges/agent-challenge/docker/canonical/live-task-cache"
2047+ )
2048+ digest = Path (
2049+ settings .own_runner_digest_manifest or "/app/golden/dataset-digest.json"
2050+ )
2051+ plan .jobs_dir .mkdir (parents = True , exist_ok = True )
2052+ plan .job_dir .mkdir (parents = True , exist_ok = True )
2053+
2054+ cmd = [
2055+ "python" ,
2056+ "-m" ,
2057+ "agent_challenge.evaluation.own_runner_backend" ,
2058+ "run" ,
2059+ "--job-dir" ,
2060+ str (plan .job_dir ),
2061+ "--job-name" ,
2062+ plan .job_name ,
2063+ "--jobs-dir" ,
2064+ str (plan .jobs_dir ),
2065+ "--n-concurrent" ,
2066+ str (max (1 , int (settings .harbor_n_concurrent or 1 ))),
2067+ "--agent-import-path" ,
2068+ settings .harbor_agent_import_path ,
2069+ "--n-attempts" ,
2070+ "1" ,
2071+ "--task" ,
2072+ bare ,
2073+ "--cache-root" ,
2074+ str (cache_root ),
2075+ "--digest-manifest" ,
2076+ str (digest ),
2077+ ]
2078+ env = {
2079+ ** dict (os .environ ),
2080+ ** _terminal_bench_env (miner_env , gateway ),
2081+ "PYTHONPATH" : f"{ agent_workspace } :{ os .environ .get ('PYTHONPATH' , '' )} " .rstrip (":" ),
2082+ "DOCKER_HOST" : os .environ .get ("DOCKER_HOST" ) or "unix:///var/run/docker.sock" ,
2083+ "BASE_AGENT_PATH" : str (agent_workspace ),
2084+ }
2085+ if env ["PYTHONPATH" ].endswith (":" ):
2086+ env ["PYTHONPATH" ] = env ["PYTHONPATH" ][:- 1 ]
2087+
2088+ try :
2089+ proc = subprocess .run (
2090+ cmd ,
2091+ cwd = str (agent_workspace ),
2092+ capture_output = True ,
2093+ text = True ,
2094+ timeout = timeout_seconds ,
2095+ check = False ,
2096+ env = env ,
2097+ )
2098+ return DockerRunResult (
2099+ container_name = f"no-phala-host-{ plan .job_name } " [:120 ],
2100+ stdout = proc .stdout or "" ,
2101+ stderr = proc .stderr or "" ,
2102+ returncode = proc .returncode ,
2103+ timed_out = False ,
2104+ )
2105+ except subprocess .TimeoutExpired as exc :
2106+ return DockerRunResult (
2107+ container_name = f"no-phala-host-{ plan .job_name } " [:120 ],
2108+ stdout = (exc .stdout or "" ) if isinstance (exc .stdout , str ) else "" ,
2109+ stderr = (exc .stderr or "" ) if isinstance (exc .stderr , str ) else "timed_out" ,
2110+ returncode = 124 ,
2111+ timed_out = True ,
2112+ )
2113+
2114+
20002115def _terminal_bench_script (
20012116 job : EvaluationJob ,
20022117 task : BenchmarkTask ,
0 commit comments