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(llm): make the Anthropic refusal fallback model configurable (#494)
Lucas Saldanha Werneck67959b28f1ec
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 194f3583..fff64e8f 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -488,6 +488,17 @@ All notable changes to SkillEvaluator are documented in this file.lines are read, so a body that spells `exit_code=0` still reports nothing,and a result with no exit status, or a non-zero one, is judged by its textexactly as before.+- Add `SKILL_EVAL_LLM_REFUSAL_FALLBACK_MODEL` to set the model that Claude 5.5+ or later requests name as the server-side refusal fallback, or to turn it off+ with `none`, `off`, `disabled`, `false` or `0`. The Claude API answers HTTP+ 400 (`'claude-opus-4-8' is not a valid fallback target for+ 'claude-sonnet-5-5'`) when the fixed `claude-opus-4-8` target does not suit+ the request model, which made such a model unusable for LLM checks and as a+ Tier 3 judge. A fallback equal to the request model is no longer sent. The+ default is unchanged. The Harbor verifier receives the variable like+ `LLM_JUDGE_FALLBACK_MODELS`; its Bedrock refusal retry uses it too, adding+ the judge model's geography prefix to a bare name and using a full Bedrock+ ID as given. The reusable CI workflows do not take the variable.## 0.9.0 - 2026-11-13diff --git a/docs/ci-integration.mdx b/docs/ci-integration.mdxindex f903d994..4067c5f4 100644--- a/docs/ci-integration.mdx+++ b/docs/ci-integration.mdx@@ -333,6 +333,17 @@ jq -e '([.quality_summary[]?.overall_score] | min // 100) >= 80' "$report"evidence. See the workflow above or[Installation: System tools](/skills/skillevaluator/installation#system-tools).</Accordion>+ <Accordion title="Claude answers HTTP 400 'is not a valid fallback target'">+ The reusable SkillEvaluator workflows pass only their documented inputs+ (provider, model, base URL, and keys) to the provider-backed tiers, so a+ `SKILL_EVAL_LLM_REFUSAL_FALLBACK_MODEL` or `LLM_JUDGE_FALLBACK_MODELS` set+ in the calling job does not reach them. Choose a Claude model that accepts+ the default `claude-opus-4-8` fallback there. A pipeline that runs the CLI+ directly, as in the recipe above, can set+ `SKILL_EVAL_LLM_REFUSAL_FALLBACK_MODEL` in the step environment, or `none`+ to send no fallback. See+ [Environment variables](/skills/skillevaluator/environment-variables).+ </Accordion><Accordion title="The report artifact is empty">Make sure the artifact `path` matches your `-o` directory and that the upload step carries `if: always()` — otherwise a failed gate skips the upload, and you lose the report exactly when you need it.</Accordion>diff --git a/docs/custom-graders.mdx b/docs/custom-graders.mdxindex e399cbd4..28f78008 100644--- a/docs/custom-graders.mdx+++ b/docs/custom-graders.mdx@@ -257,8 +257,8 @@ The staged task also has explicit compatibility boundaries:provider or judge control is accepted in task/step `verifier.env` only whenthe operator explicitly staged that same name; unrelated verifier variablesremain available. Operator-set `LLM_JUDGE_FALLBACK_MODELS`,- `LLM_JUDGE_FALLBACK_POLICY`, and `LLM_JUDGE_RETRY_POLICY` values are- forwarded only to the standard verifier job, never to the agent environment+ `LLM_JUDGE_FALLBACK_POLICY`, `LLM_JUDGE_RETRY_POLICY`, and+ `SKILL_EVAL_LLM_REFUSAL_FALLBACK_MODEL` values are forwarded only to the standard verifier job, never to the agent environmentor a `custom_only` run. SkillEvaluator's Python verifier runs in isolated modefrom a replaced `tests/skill_evaluator/` payload so authored helper modulescannot shadow its imports.diff --git a/docs/environment-variables.mdx b/docs/environment-variables.mdxindex 5d5c4779..3c3e1db1 100644--- a/docs/environment-variables.mdx+++ b/docs/environment-variables.mdx@@ -173,7 +173,8 @@ execution environments are covered in| `SKILL_EVAL_HARBOR_PREBUILD_TASK_ENVS` | unset | Set to exactly `1` to opt in to pre-building Harbor task environment images before trials start (other truthy spellings are not honored). Opt-in because concurrent trial cleanup can remove a shared prebuilt image that sibling trials still need. || `SKILL_EVAL_JUDGE_MODEL` | falls back to `SKILL_EVAL_LLM_MODEL` | Operator-controlled model override for the Tier 3 dimension judge in standard grading. `LLM_JUDGE_MODEL` is honored as a higher-precedence spelling; when neither is set, the judge uses `SKILL_EVAL_LLM_MODEL`, then the built-in judge default. Both spellings change only the model used with the configured `SKILL_EVAL_LLM_PROVIDER`; they do not select a separate judge provider, so the model must be supported by that provider. Standard grading makes both spellings resolve to the selected override in Harbor's parent process, then forwards them through its verifier-only job layer, which takes precedence over task and step verifier declarations. Neither name is injected into the evaluated agent's initial environment; attempts to set or reference one from skill-authored `runtime_env` or native `[environment.env]` tables are rejected. Native custom-only graders keep ownership of their verifier configuration. Shared agent/verifier containers are a process boundary, not a confidentiality boundary; use a separate verifier environment when the model name itself must be hidden from untrusted agent processes. `run_config.json` records the configured judge provider, model, source, `override_applied`, reasoning effort, and catalog-verification status separately from agent models; an allowed provider fallback may use a different model for an individual judge call. When `override_applied` is false for a native Harbor task, `effective_model_source` is `native_harbor_runtime` and catalog verification is explicitly inconclusive because an authored task or step verifier declaration may supersede the recorded fallback. || `LLM_JUDGE_FALLBACK_MODELS` | unset | Comma-separated fallback models for the Tier 3 standard judges in the Harbor verifier. When the provider rejects the judge model as not found, invalid, or not accessible to the key, the verifier tries each fallback in order with the same provider. Fallback applies to the `openai`, `nv_build`, and `openai-compatible` providers. A safety refusal or an empty reply from the judge model also moves to the next fallback, on every provider. The value is forwarded only to standard verifier jobs, never to the agent environment or `custom_only` runs. |-| `LLM_JUDGE_FALLBACK_POLICY` | `append` | Opt-in limit on which models may answer a Tier 3 standard judge. `append` keeps the built-in refusal fallback, which sends a refused Claude 5.5 or later judge to `claude-opus-4-8`. `replace` turns it off, so only the judge model and the `LLM_JUDGE_FALLBACK_MODELS` entries answer. Values are case-insensitive; any other value stops a run with standard grading before trials start, and the verifier fails every standard judge on it before a request is sent. Forwarded like `LLM_JUDGE_FALLBACK_MODELS`, and recorded as `judge.fallback_policy` in `run_config.json` when set. See [Judge fallback and retry policies](tier3-live-evaluation.mdx#judge-fallback-and-retry-policies). |+| `SKILL_EVAL_LLM_REFUSAL_FALLBACK_MODEL` | `claude-opus-4-8` | Model named as the server-side refusal fallback on requests to Claude 5.5 or later models on the native Claude API; on Bedrock, the Tier 3 judge's refusal retry uses it. On Bedrock, a bare name such as `claude-opus-4-8` gets the judge model's geography prefix (`us.anthropic.`, `global.anthropic.`), and a full Bedrock ID such as `global.anthropic.claude-opus-4-8` is used as given. Set `none`, `off`, `disabled`, `false` or `0` to send no fallback, for example when the API answers HTTP 400 `is not a valid fallback target` for your model. An empty value counts as unset, and a fallback equal to the request model is never sent. Forwarded to standard verifier jobs like `LLM_JUDGE_FALLBACK_MODELS`. The reusable SkillEvaluator CI workflows do not take this variable; their provider-backed jobs keep the default. |+| `LLM_JUDGE_FALLBACK_POLICY` | `append` | Opt-in limit on which models may answer a Tier 3 standard judge. `append` keeps the built-in refusal fallback, which sends a refused Claude 5.5 or later judge to `SKILL_EVAL_LLM_REFUSAL_FALLBACK_MODEL` (default `claude-opus-4-8`, off with `none`, never sent when it equals the judge model). `replace` turns it off, so only the judge model and the `LLM_JUDGE_FALLBACK_MODELS` entries answer. Values are case-insensitive; any other value stops a run with standard grading before trials start, and the verifier fails every standard judge on it before a request is sent. Forwarded like `LLM_JUDGE_FALLBACK_MODELS`, and recorded as `judge.fallback_policy` in `run_config.json` when set. See [Judge fallback and retry policies](tier3-live-evaluation.mdx#judge-fallback-and-retry-policies). || `LLM_JUDGE_RETRY_POLICY` | `legacy` | Opt-in retry policy for the Tier 3 standard judges. `strict` tries at most three models (the judge model, then the first two `LLM_JUDGE_FALLBACK_MODELS` entries) with at most two requests each within the per-judge time budget, moves on only when a model is unavailable, ends the judge on a refusal or a quota, budget, safety, or security error, and scores only a first completed reply that is exactly one JSON object. `legacy` keeps the standard retries, fallbacks, format retry, and salvage. Values are case-insensitive; any other value stops a run with standard grading before trials start, and the verifier fails every standard judge on it before a request is sent. Forwarded like `LLM_JUDGE_FALLBACK_MODELS`, and recorded as `judge.retry_policy` in `run_config.json` when set. See [Judge fallback and retry policies](tier3-live-evaluation.mdx#judge-fallback-and-retry-policies). || `SKILLEVALUATOR_HARBOR_DIAGNOSTIC_ARTIFACT_MAX_BYTES` | `5242880` (5 MiB) | Size cap per diagnostic artifact copied from a Harbor trial into the results directory. Values are bounded to 0–67108864 bytes (64 MiB); `0` skips non-empty artifacts. Oversized artifacts are skipped and recorded in the artifact manifest. || `SKILLEVALUATOR_GKE_CLUSTER`, `SKILLEVALUATOR_GKE_REGION`, `SKILLEVALUATOR_GKE_NAMESPACE`, `SKILLEVALUATOR_GKE_REGISTRY_LOCATION`, `SKILLEVALUATOR_GKE_REGISTRY_NAME` | — | Target cluster, region, namespace, and Artifact Registry coordinates for `--env-mode gke` when not supplied via `--ek`. |diff --git a/docs/tier3-live-evaluation.mdx b/docs/tier3-live-evaluation.mdxindex 0cc978c4..70304757 100644--- a/docs/tier3-live-evaluation.mdx+++ b/docs/tier3-live-evaluation.mdx@@ -1402,7 +1402,9 @@ the case is judged and scored normally.- **Refusals.** A safety-classifier refusal is never scored as an answer. Onthe native Claude API, Claude 5.5 or later judges use server-side fallback to`claude-opus-4-8`, and on Bedrock a filtered Claude 5.5 reply is retried- once on Claude Opus 4.8 in the same geography. A refusal or an empty reply+ once on Claude Opus 4.8 in the same geography.+ `SKILL_EVAL_LLM_REFUSAL_FALLBACK_MODEL` changes that target, or turns it off+ with `none`; a target equal to the judge model is never sent. A refusal or an empty replythen moves on to the next `LLM_JUDGE_FALLBACK_MODELS` entry, if any.Each judge's details in the trial's `skill_evaluator_reward.json` record`judge_model_used`, `judge_reasoning_effort`, and `judge_fallback_used`.@@ -1454,8 +1456,9 @@ like `LLM_JUDGE_FALLBACK_MODELS`: only to standard verifier jobs, never to theagent environment or `custom_only` runs.- **`LLM_JUDGE_FALLBACK_POLICY=replace`.** Only the judge model and your- `LLM_JUDGE_FALLBACK_MODELS` entries answer. The built-in `claude-opus-4-8`- refusal fallback for Claude 5.5 or later judges is not used, on the native+ `LLM_JUDGE_FALLBACK_MODELS` entries answer. The built-in refusal fallback+ for Claude 5.5 or later judges (`SKILL_EVAL_LLM_REFUSAL_FALLBACK_MODEL`,+ default `claude-opus-4-8`) is not used, on the nativeClaude API or on Bedrock. The default, `append`, keeps it.- **`LLM_JUDGE_RETRY_POLICY=strict`.** Each judge tries at most three models:the judge model, then the first two `LLM_JUDGE_FALLBACK_MODELS` entries. Itdiff --git a/src/skillevaluator/inference/client.py b/src/skillevaluator/inference/client.pyindex 193aee95..b2426851 100644--- a/src/skillevaluator/inference/client.py+++ b/src/skillevaluator/inference/client.py@@ -46,7 +46,6 @@ from skillevaluator.inference.types import ()from skillevaluator.logging_config import get_loggerfrom skillevaluator.provider_config import (- ANTHROPIC_REFUSAL_FALLBACK_MODEL,ANTHROPIC_SERVER_SIDE_FALLBACK_BETA,CHAT_DEFAULT_MODELS,MAX_COMPLETION_TOKENS,@@ -54,6 +53,7 @@ from skillevaluator.provider_config import (ProviderConfig,ProviderConfigurationError,_supports_custom_temperature,+ anthropic_refusal_fallback_model,completion_token_limit,effective_reasoning_effort,is_claude_5_5_or_later,@@ -735,7 +735,12 @@ class LLMClient:nonlocal answered_byuse_schema = response_schema is not None and target_key not in _SCHEMA_UNSUPPORTED_TARGETSif config.provider == "anthropic":- requests_fallback = is_claude_5_5_or_later(config.model) and _is_native_anthropic_endpoint(config)+ fallback_model = (+ anthropic_refusal_fallback_model(config.model)+ if is_claude_5_5_or_later(config.model) and _is_native_anthropic_endpoint(config)+ else None+ )+ requests_fallback = fallback_model is not Nonedef _anthropic_kwargs(include_schema: bool) -> dict[str, Any]:call_kwargs: dict[str, Any] = {@@ -756,7 +761,7 @@ class LLMClient:# Server-side fallback (beta): a safety-classifier refusal is retried on# the fallback model within the same call. Older SDKs lack typed fields.call_kwargs["extra_headers"] = {"anthropic-beta": ANTHROPIC_SERVER_SIDE_FALLBACK_BETA}- call_kwargs["extra_body"] = {"fallbacks": [{"model": ANTHROPIC_REFUSAL_FALLBACK_MODEL}]}+ call_kwargs["extra_body"] = {"fallbacks": [{"model": fallback_model}]}return call_kwargsresponse = _call_with_schema_fallback(diff --git a/src/skillevaluator/provider_config.py b/src/skillevaluator/provider_config.pyindex 37543067..0cd62359 100644--- a/src/skillevaluator/provider_config.py+++ b/src/skillevaluator/provider_config.py@@ -122,6 +122,26 @@ REASONING_MAX_COMPLETION_TOKENS = 32768# native Claude API then retries the request on this model in the same call.ANTHROPIC_REFUSAL_FALLBACK_MODEL = "claude-opus-4-8"ANTHROPIC_SERVER_SIDE_FALLBACK_BETA = "server-side-fallback-2026-07-01"+# The Claude API accepts only some fallback targets for a given request model+# and answers HTTP 400 "'<fallback>' is not a valid fallback target for+# '<model>'" otherwise. This variable overrides the target, or turns the+# server-side fallback off with one of the values below.+ANTHROPIC_REFUSAL_FALLBACK_MODEL_ENV = "SKILL_EVAL_LLM_REFUSAL_FALLBACK_MODEL"+_REFUSAL_FALLBACK_DISABLED_VALUES = frozenset({"none", "off", "disabled", "false", "0"})+++def anthropic_refusal_fallback_model(model: str, environ: Mapping[str, str] | None = None) -> str | None:+ """Return the server-side refusal fallback target for ``model``, or ``None`` for no fallback.++ ``SKILL_EVAL_LLM_REFUSAL_FALLBACK_MODEL`` replaces the built-in target; ``none``,+ ``off``, ``disabled``, ``false`` or ``0`` (any case) turns the fallback off. An+ empty value counts as unset. A target equal to ``model`` is never sent.+ """+ value = str((os.environ if environ is None else environ).get(ANTHROPIC_REFUSAL_FALLBACK_MODEL_ENV, "")).strip()+ if value.casefold() in _REFUSAL_FALLBACK_DISABLED_VALUES:+ return None+ target = value or ANTHROPIC_REFUSAL_FALLBACK_MODEL+ return None if target == str(model or "").strip() else targetdef _model_leaf(model: str) -> str:diff --git a/src/skillevaluator/tier3/harbor/adapter.py b/src/skillevaluator/tier3/harbor/adapter.pyindex 2754fdef..6a778201 100644--- a/src/skillevaluator/tier3/harbor/adapter.py+++ b/src/skillevaluator/tier3/harbor/adapter.py@@ -245,7 +245,12 @@ _COMPOSE_ALLOWED_VOLUME_KEYS = frozenset({"labels"})_VERIFIER_JUDGE_MODEL_ENV_VARS = frozenset({"LLM_JUDGE_MODEL", "SKILL_EVAL_JUDGE_MODEL"})# Fallback models and the opt-in fallback and retry policies of the standard judges._VERIFIER_JUDGE_FALLBACK_ENV_VARS = frozenset(- {"LLM_JUDGE_FALLBACK_MODELS", "LLM_JUDGE_FALLBACK_POLICY", "LLM_JUDGE_RETRY_POLICY"}+ {+ "LLM_JUDGE_FALLBACK_MODELS",+ "LLM_JUDGE_FALLBACK_POLICY",+ "LLM_JUDGE_RETRY_POLICY",+ "SKILL_EVAL_LLM_REFUSAL_FALLBACK_MODEL",+ })_VERIFIER_JUDGE_CONTROL_ENV_VARS = (_VERIFIER_JUDGE_MODEL_ENV_VARS | _VERIFIER_JUDGE_FALLBACK_ENV_VARS | {"SKILL_EVAL_JUDGE_CHARACTER_FACTS"}diff --git a/src/skillevaluator/tier3/harbor/templates/eval.py b/src/skillevaluator/tier3/harbor/templates/eval.pyindex 59df0d73..fd3be1dd 100644--- a/src/skillevaluator/tier3/harbor/templates/eval.py+++ b/src/skillevaluator/tier3/harbor/templates/eval.py@@ -677,6 +677,8 @@ JUDGE_REASONING_EFFORT = "medium"REASONING_MAX_COMPLETION_TOKENS = 32768ANTHROPIC_REFUSAL_FALLBACK_MODEL = "claude-opus-4-8"ANTHROPIC_SERVER_SIDE_FALLBACK_BETA = "server-side-fallback-2026-07-01"+ANTHROPIC_REFUSAL_FALLBACK_MODEL_ENV = "SKILL_EVAL_LLM_REFUSAL_FALLBACK_MODEL"+_REFUSAL_FALLBACK_DISABLED_VALUES = frozenset({"none", "off", "disabled", "false", "0"})_ANTHROPIC_DNS_LABEL_RE = re.compile(r"^[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?$")_ANTHROPIC_INTERNAL_LABEL_RE = re.compile(r"^[A-Za-z0-9_](?:[A-Za-z0-9_-]{0,61}[A-Za-z0-9_])?$")_ANTHROPIC_IPV6_ZONE_RE = re.compile(r"^[A-Za-z0-9._~-]+$")@@ -971,6 +973,21 @@ def _strict_judge_replies():return True+def _refusal_fallback_target(model):+ """Return the refusal fallback target for ``model``, or None for no fallback.++ SKILL_EVAL_LLM_REFUSAL_FALLBACK_MODEL replaces the built-in target; ``none``,+ ``off``, ``disabled``, ``false`` or ``0`` turns it off. An empty value counts+ as unset, and a target equal to ``model`` is never sent. Mirrors+ ``provider_config.anthropic_refusal_fallback_model``.+ """+ value = os.environ.get(ANTHROPIC_REFUSAL_FALLBACK_MODEL_ENV, "").strip()+ if value.casefold() in _REFUSAL_FALLBACK_DISABLED_VALUES:+ return None+ target = value or ANTHROPIC_REFUSAL_FALLBACK_MODEL+ return None if target == str(model or "").strip() else target++def _builtin_refusal_fallback_allowed():"""Return whether the built-in Claude Opus 4.8 refusal fallback may answer a refused judge.@@ -1953,9 +1970,11 @@ def _call_anthropic(prompt, model, max_tokens, temperature, response_schema=None# Server-side fallback (beta, native Claude API only): a safety-classifier# refusal is retried on the fallback model within the same call.server_side_fallback = (- _is_claude_5_5_or_later(model)+ _refusal_fallback_target(model)+ if _is_claude_5_5_or_later(model)and urlparse(target_url).hostname == "api.anthropic.com"and _builtin_refusal_fallback_allowed()+ else None)def _build_request(include_schema):@@ -1978,7 +1997,7 @@ def _call_anthropic(prompt, model, max_tokens, temperature, response_schema=None"anthropic-version": "2023-06-01",}if server_side_fallback:- payload["fallbacks"] = [{"model": ANTHROPIC_REFUSAL_FALLBACK_MODEL}]+ payload["fallbacks"] = [{"model": server_side_fallback}]headers["anthropic-beta"] = ANTHROPIC_SERVER_SIDE_FALLBACK_BETAreturn urllib.request.Request(target_url, data=json.dumps(payload).encode(), headers=headers)@@ -2076,12 +2095,25 @@ def _classify_bedrock_retry_error(error):return is_network, type_name, None+_BEDROCK_ANTHROPIC_PREFIX_RE = re.compile(r"(?:(?:[a-z]{2}|global)\.)?anthropic\.")++def _bedrock_refusal_fallback_model(model):- """Return Opus 4.8 in the same Bedrock geography as a Claude 5.5 or later model, else None."""- prefix = re.match(r"(?:(?:[a-z]{2}|global)\.)?anthropic\.", str(model or ""))+ """Return the Bedrock refusal fallback ID for a Claude 5.5 or later model, else None.++ A bare name such as ``claude-opus-4-8`` gets the request model's geography+ prefix. A value that is already a Bedrock ID (``us.anthropic.``,+ ``global.anthropic.``, ``anthropic.``) is used as given.+ """+ prefix = _BEDROCK_ANTHROPIC_PREFIX_RE.match(str(model or ""))if prefix is None or not _is_claude_5_5_or_later(model):return None- return prefix.group(0) + ANTHROPIC_REFUSAL_FALLBACK_MODEL+ target = _refusal_fallback_target(model)+ if not target:+ return None+ bedrock_target = target if _BEDROCK_ANTHROPIC_PREFIX_RE.match(target) else prefix.group(0) + target+ # Compare the resolved Bedrock ID, not the configured leaf name, with the request model.+ return None if bedrock_target == str(model).strip() else bedrock_targetdef _call_bedrock(prompt, model, max_tokens, temperature, timeout=90, provenance=None):diff --git a/tests/conftest.py b/tests/conftest.pyindex 5c2573eb..4fb8e842 100644--- a/tests/conftest.py+++ b/tests/conftest.py@@ -43,9 +43,10 @@ def _isolate_operator_vertex_routing(monkeypatch: pytest.MonkeyPatch) -> None:@pytest.fixture(autouse=True)def _isolate_operator_judge_policies(monkeypatch: pytest.MonkeyPatch) -> None:- """Keep tests on the default judge policies even when the host shell opts in to others."""+ """Keep tests on the default judge policies and refusal fallback even when the host shell sets others."""monkeypatch.delenv("LLM_JUDGE_FALLBACK_POLICY", raising=False)monkeypatch.delenv("LLM_JUDGE_RETRY_POLICY", raising=False)+ monkeypatch.delenv("SKILL_EVAL_LLM_REFUSAL_FALLBACK_MODEL", raising=False)# =============================================================================diff --git a/tests/inference/test_llm_client.py b/tests/inference/test_llm_client.pyindex dbf78d90..7f58304f 100644--- a/tests/inference/test_llm_client.py+++ b/tests/inference/test_llm_client.py@@ -1117,6 +1117,38 @@ class TestReasoningModelRequests:call_kwargs = mock_anthropic.messages.create.call_args.kwargsassert {"output_config", "extra_headers", "extra_body"}.isdisjoint(call_kwargs)+ @pytest.mark.parametrize(+ ("env_value", "expected"),+ [+ (None, [{"model": ANTHROPIC_REFUSAL_FALLBACK_MODEL}]),+ ("", [{"model": ANTHROPIC_REFUSAL_FALLBACK_MODEL}]),+ (" claude-opus-5 ", [{"model": "claude-opus-5"}]),+ ("none", None),+ ("OFF", None),+ ("disabled", None),+ ("claude-sonnet-5-5", None),+ ],+ )+ def test_refusal_fallback_model_is_configurable(+ self, monkeypatch: pytest.MonkeyPatch, env_value: str | None, expected: list[dict[str, str]] | None+ ) -> None:+ _use_provider(monkeypatch, "anthropic", "claude-sonnet-5-5")+ monkeypatch.delenv("SKILL_EVAL_LLM_REFUSAL_FALLBACK_MODEL", raising=False)+ if env_value is not None:+ monkeypatch.setenv("SKILL_EVAL_LLM_REFUSAL_FALLBACK_MODEL", env_value)+ mock_anthropic = MagicMock()+ mock_anthropic.messages.create.return_value = _anthropic_response("Done")++ with patch("anthropic.Anthropic", return_value=mock_anthropic):+ FindingVerifier().completions("system", "user")++ call_kwargs = mock_anthropic.messages.create.call_args.kwargs+ if expected is None:+ assert {"extra_headers", "extra_body"}.isdisjoint(call_kwargs)+ else:+ assert call_kwargs["extra_headers"] == {"anthropic-beta": ANTHROPIC_SERVER_SIDE_FALLBACK_BETA}+ assert call_kwargs["extra_body"] == {"fallbacks": expected}+def test_anthropic_gateway_gets_effort_without_server_side_fallback(self, monkeypatch: pytest.MonkeyPatch) -> None:_use_provider(monkeypatch, "anthropic", "claude-opus-5-5")monkeypatch.setenv("ANTHROPIC_BASE_URL", "https://gateway.example")diff --git a/tests/test_harbor_runner_environment.py b/tests/test_harbor_runner_environment.pyindex b352da8c..ab9a53e7 100644--- a/tests/test_harbor_runner_environment.py+++ b/tests/test_harbor_runner_environment.py@@ -289,6 +289,7 @@ def test_skill_config_cannot_control_evaluator_or_judge_routing(name: str) -> No"SKILL_EVAL_JUDGE_CHARACTER_FACTS","LLM_JUDGE_FALLBACK_POLICY","LLM_JUDGE_RETRY_POLICY",+ "SKILL_EVAL_LLM_REFUSAL_FALLBACK_MODEL",],)@pytest.mark.parametrize("provider_name", ["openai", "openai-compatible", "anthropic", "bedrock", "nv_build"])diff --git a/tests/test_harbor_runtime_skill_isolation.py b/tests/test_harbor_runtime_skill_isolation.pyindex 9832b186..6bb1e514 100644--- a/tests/test_harbor_runtime_skill_isolation.py+++ b/tests/test_harbor_runtime_skill_isolation.py@@ -417,6 +417,7 @@ def test_native_custom_only_preserves_authored_judge_controls_in_verifier_env("SKILL_EVAL_JUDGE_CHARACTER_FACTS","LLM_JUDGE_FALLBACK_POLICY","LLM_JUDGE_RETRY_POLICY",+ "SKILL_EVAL_LLM_REFUSAL_FALLBACK_MODEL",],)def test_native_standard_grading_rejects_task_owned_judge_controls(@@ -458,6 +459,7 @@ def test_native_standard_grading_rejects_task_owned_judge_controls("LLM_JUDGE_FALLBACK_MODELS","LLM_JUDGE_FALLBACK_POLICY","LLM_JUDGE_RETRY_POLICY",+ "SKILL_EVAL_LLM_REFUSAL_FALLBACK_MODEL",],)def test_native_standard_grading_allows_exact_operator_staged_control_placeholders(@@ -505,7 +507,7 @@ def test_native_standard_grading_injects_operator_staged_judge_fallback(tmp_pathdef test_native_standard_grading_injects_operator_staged_judge_policies(tmp_path: Path) -> None:_, target, _, _ = _write_projection_fixture(tmp_path)_write_minimal_native_task(target)- names = ("LLM_JUDGE_FALLBACK_POLICY", "LLM_JUDGE_RETRY_POLICY")+ names = ("LLM_JUDGE_FALLBACK_POLICY", "LLM_JUDGE_RETRY_POLICY", "SKILL_EVAL_LLM_REFUSAL_FALLBACK_MODEL")[staged] = stage_native_harbor_tasks(target,diff --git a/tests/tier3/test_judge_parse_robustness.py b/tests/tier3/test_judge_parse_robustness.pyindex 4fb72446..dcd1c9b2 100644--- a/tests/tier3/test_judge_parse_robustness.py+++ b/tests/tier3/test_judge_parse_robustness.py@@ -525,6 +525,32 @@ def test_template_budget_effort_and_fallback_constants_match_package():assert eval_template.JUDGE_REASONING_EFFORT == llm_judge.JUDGE_REASONING_EFFORTassert eval_template.ANTHROPIC_REFUSAL_FALLBACK_MODEL == provider_config.ANTHROPIC_REFUSAL_FALLBACK_MODELassert eval_template.ANTHROPIC_SERVER_SIDE_FALLBACK_BETA == provider_config.ANTHROPIC_SERVER_SIDE_FALLBACK_BETA+ assert eval_template.ANTHROPIC_REFUSAL_FALLBACK_MODEL_ENV == provider_config.ANTHROPIC_REFUSAL_FALLBACK_MODEL_ENV+ assert eval_template._REFUSAL_FALLBACK_DISABLED_VALUES == provider_config._REFUSAL_FALLBACK_DISABLED_VALUES+++ "value",+ [+ None,+ "",+ " ",+ *sorted(provider_config._REFUSAL_FALLBACK_DISABLED_VALUES),+ *(value.upper() for value in sorted(provider_config._REFUSAL_FALLBACK_DISABLED_VALUES)),+ *(value.title() for value in sorted(provider_config._REFUSAL_FALLBACK_DISABLED_VALUES)),+ "claude-opus-5-5",+ " claude-opus-5-5 ",+ "claude-opus-5",+ "us.anthropic.claude-opus-4-8",+ ],+)+def test_template_refusal_fallback_target_matches_package(monkeypatch, value):+ model = "claude-opus-5-5"+ monkeypatch.delenv(provider_config.ANTHROPIC_REFUSAL_FALLBACK_MODEL_ENV, raising=False)+ if value is not None:+ monkeypatch.setenv(provider_config.ANTHROPIC_REFUSAL_FALLBACK_MODEL_ENV, value)++ assert eval_template._refusal_fallback_target(model) == provider_config.anthropic_refusal_fallback_model(model)@pytest.mark.parametrize(diff --git a/tests/tier3/test_judge_policies.py b/tests/tier3/test_judge_policies.pyindex 6dccd10f..ce53bc8c 100644--- a/tests/tier3/test_judge_policies.py+++ b/tests/tier3/test_judge_policies.py@@ -186,6 +186,102 @@ def test_default_policies_keep_the_builtin_anthropic_refusal_fallback(assert json.loads(request.data)["fallbacks"] == [{"model": "claude-opus-4-8"}]+ ("value", "expected"),+ [+ (None, [{"model": "claude-opus-4-8"}]),+ ("", [{"model": "claude-opus-4-8"}]),+ ("claude-opus-5", [{"model": "claude-opus-5"}]),+ ("none", None),+ ("Off", None),+ ("claude-opus-5-5", None),+ ],+)+def test_refusal_fallback_model_env_for_the_anthropic_judge(verifier, monkeypatch, value, expected):+ monkeypatch.delenv("SKILL_EVAL_LLM_REFUSAL_FALLBACK_MODEL", raising=False)+ if value is not None:+ monkeypatch.setenv("SKILL_EVAL_LLM_REFUSAL_FALLBACK_MODEL", value)++ request = _anthropic_request(verifier, monkeypatch)++ payload = json.loads(request.data)+ assert payload.get("fallbacks") == expected+ assert (request.get_header("Anthropic-beta") is not None) == (expected is not None)+++def test_refusal_fallback_model_env_for_the_bedrock_judge(verifier, monkeypatch):+ import boto3++ monkeypatch.setenv("SKILL_EVAL_LLM_REFUSAL_FALLBACK_MODEL", "claude-opus-5")+ client = MagicMock()+ client.converse.side_effect = [+ {"stopReason": "content_filtered", "output": {"message": {"content": []}}},+ {"stopReason": "end_turn", "output": {"message": {"content": [{"text": "Done"}]}}},+ ]+ monkeypatch.setattr(boto3, "client", lambda *_args, **_kwargs: client)++ verifier._call_bedrock("prompt", "us.anthropic.claude-opus-5-5", 4096, 0.0)++ assert [call.kwargs["modelId"] for call in client.converse.call_args_list] == [+ "us.anthropic.claude-opus-5-5",+ "us.anthropic.claude-opus-5",+ ]++ monkeypatch.setenv("SKILL_EVAL_LLM_REFUSAL_FALLBACK_MODEL", "none")+ client.converse.reset_mock()+ client.converse.side_effect = [{"stopReason": "content_filtered", "output": {"message": {"content": []}}}]+ with pytest.raises(verifier._JudgeRefusedError):+ verifier._call_bedrock("prompt", "us.anthropic.claude-opus-5-5", 4096, 0.0)+ assert client.converse.call_count == 1+++def test_bedrock_refusal_fallback_equal_to_the_request_model_is_not_sent(verifier, monkeypatch):+ import boto3++ monkeypatch.setenv("SKILL_EVAL_LLM_REFUSAL_FALLBACK_MODEL", "claude-opus-5-5")+ client = MagicMock()+ client.converse.side_effect = [+ {"stopReason": "content_filtered", "output": {"message": {"content": []}}},+ {"stopReason": "content_filtered", "output": {"message": {"content": []}}},+ ]+ monkeypatch.setattr(boto3, "client", lambda *_args, **_kwargs: client)++ with pytest.raises(verifier._JudgeRefusedError):+ verifier._call_bedrock("prompt", "us.anthropic.claude-opus-5-5", 4096, 0.0)++ assert [call.kwargs["modelId"] for call in client.converse.call_args_list] == ["us.anthropic.claude-opus-5-5"]+++ ("value", "expected_calls"),+ [+ ("claude-opus-4-8", ["us.anthropic.claude-opus-5-5", "us.anthropic.claude-opus-4-8"]),+ ("us.anthropic.claude-opus-4-8", ["us.anthropic.claude-opus-5-5", "us.anthropic.claude-opus-4-8"]),+ ("global.anthropic.claude-opus-4-8", ["us.anthropic.claude-opus-5-5", "global.anthropic.claude-opus-4-8"]),+ ("anthropic.claude-opus-4-8", ["us.anthropic.claude-opus-5-5", "anthropic.claude-opus-4-8"]),+ ("us.anthropic.claude-opus-5-5", ["us.anthropic.claude-opus-5-5"]),+ ],+)+def test_bedrock_refusal_fallback_uses_a_qualified_bedrock_id_as_given(verifier, monkeypatch, value, expected_calls):+ import boto3++ monkeypatch.setenv("SKILL_EVAL_LLM_REFUSAL_FALLBACK_MODEL", value)+ client = MagicMock()+ client.converse.side_effect = [+ {"stopReason": "content_filtered", "output": {"message": {"content": []}}},+ {"stopReason": "end_turn", "output": {"message": {"content": [{"text": "Done"}]}}},+ ]+ monkeypatch.setattr(boto3, "client", lambda *_args, **_kwargs: client)++ if len(expected_calls) == 1:+ with pytest.raises(verifier._JudgeRefusedError):+ verifier._call_bedrock("prompt", "us.anthropic.claude-opus-5-5", 4096, 0.0)+ else:+ assert verifier._call_bedrock("prompt", "us.anthropic.claude-opus-5-5", 4096, 0.0) == ("Done", None)++ assert [call.kwargs["modelId"] for call in client.converse.call_args_list] == expected_calls++@pytest.mark.parametrize(("name", "value"), [("LLM_JUDGE_FALLBACK_POLICY", "replace"), ("LLM_JUDGE_RETRY_POLICY", "strict")])