From 1fd7c5ed8a3de14baf5a4e0e2707a91d51e70d95 Mon Sep 17 00:00:00 2001 From: d41sys <57945677+d41sys@users.noreply.github.com> Date: Sat, 5 Dec 2026 01:14:09 +0100 Subject: [PATCH] evals/cli: wait for ACP session, skip omp ready banner, disable claude startup hooks --- agentcore/src/cli.rs | 8 ++++++++ evals/driver.py | 38 +++++++++++++++++++++++++++++--------- evals/gateway.py | 43 +++++++++++++++++++++++++++++++------------ 3 files changed, 68 insertions(+), 21 deletions(-) diff --git a/agentcore/src/cli.rs b/agentcore/src/cli.rs index 8cfd5dc..0c7061c 100644 --- a/agentcore/src/cli.rs +++ b/agentcore/src/cli.rs @@ -644,6 +644,14 @@ fn spawn_cli_turn(p: &TurnParams) -> io::Result { "--permission-mode", "bypassPermissions", ]); + if !p + .extra_args + .iter() + .any(|a| a == "--setting-sources" || a.starts_with("--setting-sources=")) + { + // Avoid blocking headless turns on user-installed interactive SessionStart hooks. + cmd.args(["--setting-sources", ""]); + } if let Some(m) = &p.model { cmd.args(["--model", m]); } diff --git a/evals/driver.py b/evals/driver.py index 081ba7a..ec4eb86 100644 --- a/evals/driver.py +++ b/evals/driver.py @@ -201,9 +201,23 @@ def watch_timeout() -> None: timer.start() turn_idx = 0 + pending_prompt_idx: int | None = None + start_req_id: str | None = None mcp_script = Path(__file__).resolve().parent / "mock_mcp.py" + def send_prompt(idx: int) -> None: + turn = task.turns[idx] + prompt_op: dict[str, Any] = { + "type": "prompt", + "nonce": f"n{idx + 1}", + "text": turn.prompt, + } + if check: + prompt_op["check"] = True + send(prompt_op) + def start_session_and_prompt(idx: int) -> None: + nonlocal pending_prompt_idx, start_req_id turn = task.turns[idx] if idx == 0 or turn.new_session: if task.needs_mcp: @@ -223,7 +237,6 @@ def start_session_and_prompt(idx: int) -> None: ], } ) - send({"type": "start", "bot": f"eval-{task.id}"}) if not acp_command and not cli_command: send({"type": "set_model", "model": effective_model}) if fallback_model: @@ -231,14 +244,11 @@ def start_session_and_prompt(idx: int) -> None: send({"type": "step_limit", "steps": steps}) elif cli_command and effective_model and effective_model != "default": send({"type": "set_model", "model": effective_model}) - prompt_op: dict[str, Any] = { - "type": "prompt", - "nonce": f"n{idx + 1}", - "text": turn.prompt, - } - if check: - prompt_op["check"] = True - send(prompt_op) + pending_prompt_idx = idx + send({"type": "start", "bot": f"eval-{task.id}"}) + start_req_id = f"e{req_n}" + return + send_prompt(idx) with trace_path.open("w", encoding="utf-8") as trace_f: for line in proc.stdout: @@ -255,6 +265,16 @@ def start_session_and_prompt(idx: int) -> None: if et == "ready": start_session_and_prompt(0) + elif et == "session": + if pending_prompt_idx is not None: + idx = pending_prompt_idx + pending_prompt_idx = None + start_req_id = None + send_prompt(idx) + elif et == "response" and ev.get("error") and ev.get("id") == start_req_id: + turn_reasons.append("error") + turn_errors.append(str(ev.get("error"))) + break elif et == "token": tok: dict[str, Any] = { "type": "token", diff --git a/evals/gateway.py b/evals/gateway.py index cf18659..02bfd51 100644 --- a/evals/gateway.py +++ b/evals/gateway.py @@ -430,7 +430,9 @@ def handle_ctl(self, cmd: dict[str, Any]) -> dict[str, Any]: def base_url(self) -> str: return f"http://{self.host}:{self.port}/v1" - def _call_omp_stdio(self, path: str, body: dict[str, Any]) -> tuple[int, dict[str, Any]]: + def _call_omp_stdio( + self, path: str, body: dict[str, Any] | None = None, method: str = "POST" + ) -> tuple[int, dict[str, Any]]: with self._omp_lock: if self._omp_proc is None or self._omp_proc.poll() is not None: omp_bin = shutil.which("omp") or "omp" @@ -444,21 +446,34 @@ def _call_omp_stdio(self, path: str, body: dict[str, Any]) -> tuple[int, dict[st ) assert self._omp_proc.stdin is not None and self._omp_proc.stdout is not None self._omp_req_id += 1 - req_frame = {"id": self._omp_req_id, "path": path, "body": {**body, "stream": False}} + req_id = self._omp_req_id + req_frame: dict[str, Any] = {"id": req_id, "method": method, "path": path} + if body is not None: + req_frame["body"] = {**body, "stream": False} self._omp_proc.stdin.write(json.dumps(req_frame) + "\n") self._omp_proc.stdin.flush() - line = self._omp_proc.stdout.readline() - if not line: - return 502, {"error": {"message": "omp auth-gateway stdio closed unexpectedly"}} - resp = json.loads(line) - status = int(resp.get("status", 200)) - payload = resp.get("body", resp) - if isinstance(payload, str): + # Skip startup banners (e.g. `{"ready":true,"version":...}`) until matching `id`. + while True: + line = self._omp_proc.stdout.readline() + if not line: + return 502, {"error": {"message": "omp auth-gateway stdio closed unexpectedly"}} + line = line.strip() + if not line: + continue try: - payload = json.loads(payload) + resp = json.loads(line) except json.JSONDecodeError: - payload = {"error": {"message": payload}} - return status, payload if isinstance(payload, dict) else {"data": payload} + continue + if resp.get("id") != req_id: + continue + status = int(resp.get("status", 200)) + payload = resp.get("body", resp) + if isinstance(payload, str): + try: + payload = json.loads(payload) + except json.JSONDecodeError: + payload = {"error": {"message": payload}} + return status, payload if isinstance(payload, dict) else {"data": payload} def _dispatch_chat( self, req_body: dict[str, Any], target: RouteTarget @@ -645,6 +660,10 @@ def do_GET(self) -> None: self._send(200, "application/json", json.dumps(gw.status_snapshot()).encode("utf-8")) return if self.path.rstrip("/") in ("/v1/models", "/models"): + if gw.default_target.backend == "omp": + code, payload = gw._call_omp_stdio("/v1/models", body=None, method="GET") + self._send(code, "application/json", json.dumps(payload).encode("utf-8")) + return models = [{"id": k, "object": "model"} for k in gw.routes] or [ {"id": gw.default_target.model_override or "default", "object": "model"} ]