diff --git a/backend-fastapi/scripts/verify_ai_agent_admin.py b/backend-fastapi/scripts/verify_ai_agent_admin.py index 01003c0..1c2df00 100644 --- a/backend-fastapi/scripts/verify_ai_agent_admin.py +++ b/backend-fastapi/scripts/verify_ai_agent_admin.py @@ -75,6 +75,30 @@ def _unwrap(payload: Any) -> Any: return payload +async def _find_completed_issue_run( + client: ApiClient, + workflow_id: str, + issue: str, +) -> dict[str, Any]: + runs_data = _unwrap(await client.get("/api/ai/workflow/runs?page=1&pageSize=50")) + runs = runs_data.get("items", runs_data) if isinstance(runs_data, dict) else runs_data + candidates = [ + run + for run in runs + if run.get("workflow_id") == workflow_id and run.get("status") == "completed" + ] + issue_text = issue.lower() + for run in candidates: + run_detail = _unwrap(await client.get(f"/api/ai/workflow/runs/{run['id']}")) + searchable = " ".join( + _preview(run_detail.get(key), 2000) + for key in ("inputs", "outputs", "execution_log") + ).lower() + if issue_text in searchable: + return run_detail + raise RuntimeError(f"completed run not found for issue: {issue}") + + async def verify(args: argparse.Namespace) -> int: base_url = args.base_url.rstrip("/") client = ApiClient(base_url=base_url, timeout=args.timeout) @@ -116,19 +140,7 @@ async def verify(args: argparse.Namespace) -> int: if workflow.get("status") != "published": raise RuntimeError(f"workflow is not published: {workflow.get('status')}") - runs_data = _unwrap(await client.get("/api/ai/workflow/runs?page=1&pageSize=20")) - runs = runs_data.get("items", runs_data) if isinstance(runs_data, dict) else runs_data - matching_runs = [ - run - for run in runs - if run.get("workflow_id") == workflow.get("id") - and run.get("status") == "completed" - and args.issue.lower() in _preview(run.get("inputs"), 1000).lower() - ] - if not matching_runs: - raise RuntimeError(f"completed run not found for issue: {args.issue}") - - run_detail = _unwrap(await client.get(f"/api/ai/workflow/runs/{matching_runs[0]['id']}")) + run_detail = await _find_completed_issue_run(client, workflow.get("id"), args.issue) execution_log = run_detail.get("execution_log") or [] if len(execution_log) < args.min_steps: raise RuntimeError(f"execution log too short: {len(execution_log)} < {args.min_steps}") diff --git a/ops/deploy-non-docker.sh b/ops/deploy-non-docker.sh index 913bab9..d0c18a1 100644 --- a/ops/deploy-non-docker.sh +++ b/ops/deploy-non-docker.sh @@ -16,7 +16,7 @@ SEED_MULTICA_AGENTS="${SEED_MULTICA_AGENTS:-1}" BUILD_WEB="${BUILD_WEB:-0}" VERIFY_RUNTIME="${VERIFY_RUNTIME:-1}" VERIFY_BASE_URL="${VERIFY_BASE_URL:-http://127.0.0.1:${BACKEND_PORT}}" -VERIFY_USERNAME="${VERIFY_USERNAME:-superadmin}" +VERIFY_USERNAME="${VERIFY_USERNAME:-zhangwei}" VERIFY_PASSWORD="${VERIFY_PASSWORD:-123456}" VERIFY_ATTEMPTS="${VERIFY_ATTEMPTS:-6}" VERIFY_SLEEP_SECONDS="${VERIFY_SLEEP_SECONDS:-5}"