Multi-tier framework for evaluating AI agent skills and plugins with quality gates, security scanning, harness compatibility checks, semantic overlap detection, synthetic evaluation dataset generation, and live agent evaluation that measures how skills affect agent behavior. Ships reusable CI templates that bring every check to any repository.
Python agent-evaluationagent-pluginsagent-securityagent-skillsagentic-aibenchmarkci-templatesclaude-codecodexevaluateevaluationharnesspluginplugin-evaluationsecurity-scannerskill-evalskill-evaluationskill-evaluatorskill-gap-analysisskills
Fix Windows subprocess decoding, reasoning-model token budget, and harbor bin resolution (#194)
Minervaowl73cb0757efd3a
diff --git a/src/skillevaluator/constants.py b/src/skillevaluator/constants.pyindex c2b1705f..cd17bae6 100644--- a/src/skillevaluator/constants.py+++ b/src/skillevaluator/constants.py@@ -409,6 +409,21 @@ RUBRIC_MAX_TOKENS = MAX_COMPLETION_TOKENSRUBRIC_MIN_SCORE = 60RUBRIC_REASONING_EFFORT = "medium"+# Reasoning models spend the completion budget on hidden reasoning before any+# visible content, so a 4096-token cap truncates the JSON mid-object (measured:+# reasoning_tokens=4000, text_tokens=0). Raise the cap for known reasoning+# families; SKILL_EVAL_LLM_MAX_TOKENS still overrides it explicitly.+RUBRIC_REASONING_MODEL_MARKERS = (+ "deepseek-r",+ "deepseek-v4",+ "o1",+ "o3",+ "o4",+ "gpt-5",+ "reasoning",+)+RUBRIC_REASONING_MAX_TOKENS = 32768+RUBRIC_CRITERIA = [{"id": "description_clarity",diff --git a/src/skillevaluator/tier3/harbor/runner.py b/src/skillevaluator/tier3/harbor/runner.pyindex f02f2a34..6011cb84 100644--- a/src/skillevaluator/tier3/harbor/runner.py+++ b/src/skillevaluator/tier3/harbor/runner.py@@ -1303,8 +1303,14 @@ class AgentRuntimePlan:def _harbor_bin() -> str:"""Return the Harbor executable installed with the active interpreter."""- candidate = Path(os.sys.executable).parent / "harbor"- return str(candidate) if candidate.exists() else (shutil.which("harbor") or "harbor")+ bin_dir = Path(os.sys.executable).parent+ # Windows installs the console script as harbor.exe; the suffix-less probe+ # below only matches POSIX layouts.+ for name in ("harbor", "harbor.exe", "harbor.cmd"):+ candidate = bin_dir / name+ if candidate.exists():+ return str(candidate)+ return shutil.which("harbor") or "harbor"# Harbor loads ``.env.local`` from its working directory, and Harbor and LiteLLMdiff --git a/src/skillevaluator/utils/tool_runner.py b/src/skillevaluator/utils/tool_runner.pyindex 5af0a4e8..e643cb34 100644--- a/src/skillevaluator/utils/tool_runner.py+++ b/src/skillevaluator/utils/tool_runner.py@@ -227,18 +227,23 @@ class ExternalTool:try:child_env = dict(env or {}) if replace_env else ({**os.environ, **env} if env else None)+ # text=True decodes strictly with the locale codec, so a child that+ # emits non-UTF-8 bytes (a Windows traceback with a CJK path, for+ # example) raises UnicodeDecodeError in the reader thread and leaves+ # proc.stdout/stderr unset -> None. Capture bytes and decode+ # tolerantly so a scanner's diagnostic output can never turn into an+ # AttributeError in the caller.proc = subprocess.run(cmd,capture_output=True,- text=True,timeout=timeout,cwd=cwd,env=child_env,)return ToolResult(success=True,- stdout=proc.stdout,- stderr=proc.stderr,+ stdout=_captured_text(proc.stdout),+ stderr=_captured_text(proc.stderr),exit_code=proc.returncode,)diff --git a/src/skillevaluator/validators/rubric_eval.py b/src/skillevaluator/validators/rubric_eval.pyindex e8b7a15c..7c2689b7 100644--- a/src/skillevaluator/validators/rubric_eval.py+++ b/src/skillevaluator/validators/rubric_eval.py@@ -23,7 +23,13 @@ from collections import Counterfrom pathlib import Pathfrom typing import Any-from skillevaluator.constants import RUBRIC_CRITERIA, RUBRIC_MAX_TOKENS, RUBRIC_MIN_SCORE, RUBRIC_REASONING_EFFORT+from skillevaluator.constants import (+ RUBRIC_CRITERIA,+ RUBRIC_MAX_TOKENS,+ RUBRIC_MIN_SCORE,+ RUBRIC_REASONING_MAX_TOKENS,+ RUBRIC_REASONING_MODEL_MARKERS,+)from skillevaluator.inference.client import LLMClientfrom skillevaluator.logging_config import get_loggerfrom skillevaluator.models.result import Finding, Severity, ValidationResult@@ -221,6 +227,27 @@ class RubricJudge(LLMClient):response_schema: dict[str, Any] | None = RUBRIC_JSON_SCHEMAschema_name: str = "rubric_evaluation"+ @staticmethod+ def _resolved_model_name() -> str:+ """Best-effort model name from the environment, ignoring config errors."""+ try:+ from skillevaluator.provider_config import resolve_llm_provider++ return resolve_llm_provider().model+ except Exception:+ return ""++ def __init__(self, *args: Any, **kwargs: Any) -> None:+ # A reasoning model burns the whole completion budget on hidden+ # reasoning before emitting visible JSON, so the default cap truncates+ # the answer mid-object. Raise it for those families unless the caller+ # passed an explicit max_tokens.+ if kwargs.get("max_tokens") is None:+ model = (kwargs.get("model") or self._resolved_model_name() or "").lower()+ if any(marker in model for marker in RUBRIC_REASONING_MODEL_MARKERS):+ kwargs["max_tokens"] = RUBRIC_REASONING_MAX_TOKENS+ super().__init__(*args, **kwargs)+_SYSTEM_PROMPT = ("You are evaluating an AI Agent Skill documentation file (SKILL.md).\n""Score each criterion 0-10 (0=fails completely, 10=exceeds expectations).\n\n"diff --git a/src/skillevaluator/validators/security.py b/src/skillevaluator/validators/security.pyindex fb90cdba..b4a2b382 100644--- a/src/skillevaluator/validators/security.py+++ b/src/skillevaluator/validators/security.py@@ -377,7 +377,7 @@ def _skillspector_llm_stderr_failed(stderr: str) -> bool:explicitly requested LLM stage, those warnings mean the evidence isincomplete regardless of the process exit code or JSON metadata."""- normalized = stderr.casefold()+ normalized = (stderr or "").casefold()return any(marker in normalized for marker in _SKILLSPECTOR_LLM_FAILURE_MARKERS)diff --git a/tests/test_harbor_local_mode.py b/tests/test_harbor_local_mode.pyindex 17a0dbbe..16786a2d 100644--- a/tests/test_harbor_local_mode.py+++ b/tests/test_harbor_local_mode.py@@ -5956,3 +5956,53 @@ def test_local_nvidia_opencode_config_disables_oauth_for_remote_mcp(monkeypatch:config = json.loads(payload)assert config["mcp"]["remote-tools"] == {"type": "remote", "url": "https://tools.example/mcp", "oauth": False}assert config["mcp"]["local-tools"] == {"type": "local", "command": ["tool-server", "--stdio"]}++[email protected]("script_name", ["harbor", "harbor.exe", "harbor.cmd"])+def test_harbor_bin_resolves_windows_console_script_suffixes(+ tmp_path: Path,+ monkeypatch: pytest.MonkeyPatch,+ script_name: str,+) -> None:+ """The Harbor console script carries a suffix on Windows.++ Probing only the suffix-less ``harbor`` name misses the interpreter-sibling+ install entirely and falls through to ``shutil.which``, so+ ``doctor --env-mode docker`` reports "harbor CLI not found" on a machine+ where Harbor 0.24.0 is installed and runnable.+ """+ from skillevaluator.tier3.harbor import runner++ fake_interpreter = tmp_path / "python.exe"+ fake_interpreter.write_text("", encoding="utf-8")+ (tmp_path / script_name).write_text("", encoding="utf-8")+ monkeypatch.setattr(runner.os, "sys", SimpleNamespace(executable=str(fake_interpreter)))+ monkeypatch.delenv("PATH", raising=False)++ assert runner._harbor_bin() == str(tmp_path / script_name)+++def test_harbor_bin_falls_back_to_path_lookup(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:+ """With no sibling script, PATH lookup still applies."""+ from skillevaluator.tier3.harbor import runner++ fake_interpreter = tmp_path / "python.exe"+ fake_interpreter.write_text("", encoding="utf-8")+ monkeypatch.setattr(runner.os, "sys", SimpleNamespace(executable=str(fake_interpreter)))+ monkeypatch.setattr(runner.shutil, "which", lambda _name: "/opt/harbor/bin/harbor")++ assert runner._harbor_bin() == "/opt/harbor/bin/harbor"+++def test_harbor_bin_returns_bare_name_when_missing_everywhere(+ tmp_path: Path, monkeypatch: pytest.MonkeyPatch+) -> None:+ """A missing Harbor still yields the command name for the caller to report."""+ from skillevaluator.tier3.harbor import runner++ fake_interpreter = tmp_path / "python.exe"+ fake_interpreter.write_text("", encoding="utf-8")+ monkeypatch.setattr(runner.os, "sys", SimpleNamespace(executable=str(fake_interpreter)))+ monkeypatch.setattr(runner.shutil, "which", lambda _name: None)++ assert runner._harbor_bin() == "harbor"diff --git a/tests/utils/test_tool_runner.py b/tests/utils/test_tool_runner.pyindex ebe88420..f602a5fa 100644--- a/tests/utils/test_tool_runner.py+++ b/tests/utils/test_tool_runner.py@@ -304,6 +304,40 @@ class TestExternalTool:assert result.stderr == "still working"assert "timed out" in (result.error_message or "")+ def test_run_decodes_non_utf8_output_tolerantly(self):+ """A child emitting non-UTF-8 bytes must not lose its captured streams.++ ``text=True`` decodes strictly, so a Windows child printing a traceback+ with a non-ASCII path raises UnicodeDecodeError inside subprocess's+ reader thread and leaves ``proc.stdout``/``proc.stderr`` unset (None).+ Callers such as the SkillSpector wrapper then crash on ``stderr.casefold()``+ instead of reading the scanner's diagnostics.+ """+ undecodable = b"WARNING path \xa1 not utf-8\n"+ mock_proc = CompletedProcess(args=["scanner"], returncode=0, stdout=b'{"ok": true}', stderr=undecodable)+ with (+ patch("shutil.which", return_value="/usr/bin/scanner"),+ patch("skillevaluator.utils.tool_runner.subprocess.run", return_value=mock_proc),+ ):+ result = ExternalTool("Scanner", "scanner").run([], log_command=False)++ assert result.success is True+ assert result.exit_code == 0+ assert result.stderr is not None, "stderr must never be None on a successful run"+ assert "WARNING path" in result.stderr+ assert result.stdout == '{"ok": true}'++ def test_run_captures_bytes_without_text_mode(self):+ """subprocess.run is invoked without text=True so decoding is our own."""+ mock_proc = CompletedProcess(args=["scanner"], returncode=0, stdout=b"out", stderr=b"err")+ with (+ patch("shutil.which", return_value="/usr/bin/scanner"),+ patch("skillevaluator.utils.tool_runner.subprocess.run", return_value=mock_proc) as mock_run,+ ):+ ExternalTool("Scanner", "scanner").run([], log_command=False)++ assert mock_run.call_args.kwargs.get("text") is not True+def test_run_merges_extra_env_over_ambient(self):"""env additions are merged onto os.environ, not substituted for it."""mock_proc = CompletedProcess(args=["true"], returncode=0, stdout="", stderr="")diff --git a/tests/validators/test_rubric_eval.py b/tests/validators/test_rubric_eval.pyindex 860e818a..6ab96d53 100644--- a/tests/validators/test_rubric_eval.py+++ b/tests/validators/test_rubric_eval.py@@ -10,7 +10,11 @@ from unittest.mock import patchimport pytest-from skillevaluator.constants import RUBRIC_CRITERIA+from skillevaluator.constants import (+ RUBRIC_CRITERIA,+ RUBRIC_MAX_TOKENS,+ RUBRIC_REASONING_MAX_TOKENS,+)from skillevaluator.reporting import HTMLReporterfrom skillevaluator.validators.rubric_eval import (RubricEvalValidator,@@ -110,6 +114,27 @@ class TestRubricJudge:result = judge.parse_response('{"score": 80, "overall_pass": true, "checks": []}')assert result["score"] == 80+ def test_reasoning_model_gets_a_larger_token_budget(self):+ """Reasoning models spend the completion budget before emitting content.++ Measured on deepseek/deepseek-v4.1-flash with a 4096-token cap:+ ``reasoning_tokens=4000, text_tokens=0`` and ``finish_reason=length``,+ so the rubric JSON was truncated mid-object and never parsed.+ """+ judge = RubricJudge(model="deepseek/deepseek-v4.1-flash")+ assert judge._max_tokens == RUBRIC_REASONING_MAX_TOKENS+ assert judge._max_tokens > RUBRIC_MAX_TOKENS++ def test_standard_model_keeps_default_token_budget(self):+ """Non-reasoning models must not pay the larger budget's latency."""+ judge = RubricJudge(model="gpt-4o")+ assert judge._max_tokens == RUBRIC_MAX_TOKENS++ def test_explicit_token_override_is_preserved(self):+ """An explicit max_tokens always wins over the reasoning-model default."""+ judge = RubricJudge(model="deepseek/deepseek-v4.1-flash", max_tokens=1234)+ assert judge._max_tokens == 1234+class TestCollectSupplementaryContent:def test_empty_dir(self, tmp_path):