Repository navigation
feat(llm): record the model that wrote rubric scores and Tier 3 insights - #308
Conversation
Rubric evaluation JSON reports and LLM-written Tier 3 conclusions, recommendations and compute_dimensions dimensions did not say which model produced them. On the native Claude API, a Claude 5.5 or later request that the safety classifier refuses is answered within the same call by the server-side fallback model, claude-opus-4-8, whose scores and wording can differ from the configured model's. Those results could not be told apart from the configured model's. LLMClient now records the model that answered each successful completions() call as model_used, per thread: the configured model, or the model named by the server-side fallback block of an Anthropic reply. It is None before a call succeeds and after a call fails. A provider property exposes the resolved provider. - rubric-eval: rubric_eval metadata and the rubric_eval success detail carry llm_provider and llm_model_used, so each skill of a folder run keeps its own model. - Insights: each LLM-written conclusion and recommendation carries model next to source "llm". - compute_dimensions: each LLM-written dimension carries model; deterministic dimensions, including the fallback after a failed call, carry none. Report labels pass through the same sanitizer that Tier 2 uses for its provider and model labels (now also exposed as safe_llm_model), so a URL or key-like model value is reported as "unresolved". Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
When a native Claude API request falls back to the server-side refusal fallback model, the API sends repeats of that request straight to the fallback model for a while. Such a sticky-served reply has no fallback content block; only its top-level model names the model that wrote it. model_used read the block alone, so re-running rubric-eval on the same skill soon after a fallback reported a score written by the fallback model as coming from the configured model. The Harbor verifier template's judge_model_used had the same gap. For a native Claude API request that asked for server-side fallback, both LLMClient and the template now take the model from the last fallback block, then from the reply's top-level model, then from the configured model. Other requests keep the configured model, so a gateway's deployment name is never reported. Tests cover a sticky-served turn through the real SDK, the template's required-judge provenance, and gateway replies whose model is ignored. The rubric report test now sends replies whose top-level model matches the model that answered. Docs and the CHANGELOG describe the label as the model the reply names instead of a fixed fallback model. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Narendran Raghavan <[email protected]>
rng1995
left a comment
There was a problem hiding this comment.
Automated review: 5 findings (0 P1, 1 P2, 4 P3); 4 posted inline.
Findings outside the diff or about the description:
PR_DESCRIPTION: P3: The "Label sanitizing" bullet comes right after the Tier 3 judge provenance bullet and says that all labels go through the sanitizer Tier 2 uses. That is not true for the Tier 3 judge label. The verifier template is standalone and cannot importsafe_llm_model._call_anthropiccopies the fallback block'sto.modelintojudge_model_usedas is, as it did before. For a sticky-served turn it now does the same with the reply's top-levelmodel. For example, a native reply with no fallback block and"model": "https://x.example/sk-abc"recordsjudge_model_used: "https://x.example/sk-abc", whilesafe_llm_modelreturnsunresolvedfor the same string. Only the rubric, Insights andcompute_dimensionslabels go through the sanitizer. Someone reading the description would expect the judge label to be limited the same way.
Suggested fix: Limit the "Label sanitizing" bullet to the rubric, Insights and compute_dimensions labels. Add that the Tier 3 judge label is stored as the reply gives it, and that the top-level model is read only for native api.anthropic.com requests. If you want the judge label limited the same way, add an inline copy of the safe_llm_model check to the template instead.
Conflicted files: CHANGELOG.md (kept both sides). Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Keep the block-only judge reply as its own case, and add replies whose fallback block names a different model than the top-level model, for the Harbor verifier template and for LLMClient.model_used. The LLMClient case also pins that a block is honored on a gateway. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
A fallback content block is honored on any Anthropic endpoint; only the top-level model read is limited to native Claude 5.5+ requests that ask for server-side fallback. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Limit the reply-model wording in the docs and CHANGELOG to Claude 5.5 or later models on the native Claude API, and say in the Fixed entry that a sticky-served judge turn sets judge_fallback_used and can move a case into judge_mixed_cases for Skill Lift. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
chrisknvidia
left a comment
There was a problem hiding this comment.
The LLMClient plumbing looks right: model_used is cleared at the start of each call, set only after a successful return and kept per thread, and the rubric, Insights and compute_dimensions labels read it on the same thread as the call. The newest commits are tests and docs only; the new fallback-block-before-reply-model cases would fail if the top-level model were read first, and the docs now match the gating (the reply model is read only for Claude 5.5 or later on the native API, a fallback block on any Anthropic endpoint). Nothing blocking.
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Narendran Raghavan <[email protected]>
main's model provenance (#308) leaves LLMClient.model_used as None after a failed call. chat() validated the history before _complete_messages cleared it, so an invalid history raised LLMClientError while model_used still named the model from the previous call. chat() now clears it first; no client is created, so an invalid history still fails before any provider call. The model_used and chat() docstrings name chat() too. A new provenance test checks that chat() reports the server-side fallback model after a success and None after an empty history. It fails without this change. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
* feat(inference): add LLMClient.chat for multi-turn requests chat(messages) takes an OpenAI-style history: optional leading system messages, then user and assistant turns. completions() now calls the same private _complete_messages helper with one user turn, so both paths share the retries, the typed refusal, truncation and empty-reply errors, the Anthropic server-side fallback headers and the ADC token refresh. Anthropic receives the system text in its separate system field; Bedrock and OpenAI-compatible endpoints receive it as a leading system message. An invalid history raises LLMClientError before any client is created. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(tier3): add tier3 feedback chat over a completed run `skillevaluator tier3 feedback RUN_DIR [--skill PATH]` opens a terminal chat about one completed Tier 3 run. Answers are grounded in the run's scores, with-skill and baseline comparisons, measured agent tokens and seconds, execution errors, every case's attempts with per-metric scores, and the report feedback saved in result.json when its run_id names the run directory. The payload is built without a second judge call. The skill is inferred from the run's publication target; an explicit --skill must match it (NFC, case-insensitive), and a changed skill digest is pointed out. Each question sends compact evidence to the configured provider with the run ID instead of its host path and with credential- shaped text redacted. Model text is printed literally with terminal controls removed. Failed turns print a sanitized message and leave the history unchanged; Ctrl-C discards the current question. No request is sent before the first question, empty stdin exits 0, and the command exits 1 when every question failed. Nothing is written to disk. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(tier3): mask feedback chat evidence before shortening it Warnings, execution errors, case questions and ground truth, dimension explanations and saved feedback were cut to their limits before the run path was replaced and credentials were redacted. A token or path that crossed the limit lost the part a redaction pattern needs, and its prefix reached the provider. Each string now has the run path replaced with the run ID and goes through redact_sensitive_text with max_len and a bounded input window, as the plugin evidence helpers do, before it is shortened. The final pass over the whole context stays for fields that are never shortened. A dimension explanation that is not text is dropped instead of sliced. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(tier3): share the feedback chat case budget across agents Case rows were kept in agent order until the 300,000-character budget ran out, so a large multi-agent run could send every case for the agents that sort first and none for the last one. cases_omitted was one number and did not say whose cases were missing. The budget is now spent one case at a time across agents, so each agent keeps the same leading cases. Kept rows are still listed by agent and case, and cases_omitted counts the rows left out per agent. The system prompt asks the model to say which agent's cases are missing. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(tier3): note that tier3 feedback wins over a folder named feedback tier3 checks its registered commands before it treats the first argument as a skill path, so `tier3 feedback` opens the chat even when the current directory has a skill folder named feedback. The tier3 feedback section now says to run `tier3 ./feedback` or `tier3 evaluate feedback` to evaluate that skill, and a test pins both routes. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(inference): leave unrelated test formatting to its own change Restore the two long monkeypatch.setattr lines in the Vertex ADC tests as they are on main. Wrapping them belongs to the open change that reformats this file; this branch only adds the chat tests. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(tier3): keep long feedback chat text that has no spaces Each shortened field is masked over a window of limit * 4 + 256 characters, cut back to the window's last whitespace so a credential split at the edge is dropped. Text with no whitespace after its limit, such as a compact JSON ground truth or a minified provider error, was cut back to its last space or to nothing. The model saw an empty ground truth or error with no sign that text was left out. Such text is now masked over a 65,536-character window instead, so it keeps a masked prefix up to its limit. When a window still drops text, the field ends in ...<truncated>, the same marker as other shortened fields. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(tier3): mask the path a copied run had where it first ran The feedback chat replaced only the run directory's current path with the run ID. A run copied from another machine keeps its ID, and its errors and warnings still name the original location, for example /home/<user>/work/<skill>/evals/results/<run_id>/jobs/t1. That path, with the user and skill names in it, reached the provider unchanged. JSON-escaped Windows paths and other spellings of the same directory were missed too. Any absolute path (POSIX, home, UNC or drive letter, escaped or not) that ends in a path segment equal to the run ID is now replaced with the ID. The path starts at the first absolute-path root after the preceding whitespace or quote, so a prefix such as --output= is kept. Relative paths and names such as <run_id>_old or <run_id>.log are left as they are. The scan is linear in the text length. The CLI reference now says which paths are replaced, that a path from another machine containing a space is not recognized, and that a shortened field ends in ...<truncated>. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(inference): clear model_used before chat() checks its history main's model provenance (#308) leaves LLMClient.model_used as None after a failed call. chat() validated the history before _complete_messages cleared it, so an invalid history raised LLMClientError while model_used still named the model from the previous call. chat() now clears it first; no client is created, so an invalid history still fails before any provider call. The model_used and chat() docstrings name chat() too. A new provenance test checks that chat() reports the server-side fallback model after a success and None after an empty history. It fails without this change. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Signed-off-by: Narendran Raghavan <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
Summary
Rubric scores, LLM-written Tier 3 insights and LLM-written
compute_dimensionsdimensions now name the model that produced them. On the native Claude API, the recorded model is the server-side fallback model when that model wrote the reply.LLMClient.model_used(new). This is the model that answered the thread's last successfulcompletions()call. For a native Claude API request that asked for server-side fallback, it is read from the reply, in this order:fallbackcontent block hands over to. Both block shapes are read: the dict that the current SDK leaves on an untyped block, and theto.modelattribute of a typed block.model. A turn served by sticky routing has nofallbackblock. When a request falls back, the API sends repeats of it straight to the fallback model for a while, so re-runningrubric-evalon the same skill soon after can be answered by the fallback model with no block. The top-levelmodelnames the model that wrote the message.For every other request (gateways, other providers, models before Claude 5.5) it is the configured model. A reply's
modelfield is not read there, so a gateway's deployment name is never reported. The value is kept per thread, because one client can serve concurrent calls. It isNonebefore a call succeeds and after a call fails. A smallproviderproperty exposes the resolved provider, next to the existingmodelandbase_urlproperties.rubric-eval. The skill'srubric_evalsuccess detail carriesllm_providerandllm_model_used. For a single skill, therubric_evalobject carries them too. Success details survive folder merges, so each skill of a folder run keeps its own model.Tier 3 Insights. Each LLM-written conclusion and recommendation carries
modelnext tosource: "llm". Deterministic entries are unchanged.compute_dimensions. Each LLM-written dimension carriesmodel. Deterministic dimensions carry none, including the deterministic fallback after a failed or unparseable call. The docstring says so.Tier 3 judge provenance (fix). The Harbor verifier template's
_call_anthropicreadjudge_model_usedonly from thefallbackblock, so a sticky-served judge reply was labeled with the configured model. It now uses the same order asLLMClient, so both copies agree. A gateway reply'smodelis still ignored there.Label sanitizing. All labels go through the sanitizer Tier 2 already uses for
llm_analysis.providerandmodel. Its model half is now also exposed assafe_llm_model. A URL or key-like model value is reported asunresolved.Docs.
docs/tier1-validation.mdxcovers the rubric fields.docs/reports.mdxcovers the Insights field in the Tier 3 payload. Both say the label is the model the reply names, without naming a specific fallback model.CHANGELOG. One entry under Unreleased / Added for the new fields, one under Fixed for the Tier 3 judge label.
Why
Since 0.6.0, a Claude 5.5 or later request to the native Claude API asks for server-side refusal fallback. When the safety classifier refuses, a different model can write the reply within the same call, and for a while afterwards the API can send repeats of that request straight to the fallback model. Until now, the rubric JSON, Insights entries and
compute_dimensionsoutput did not record any model. A score or recommendation written by the fallback model could not be told apart from one written by the configured model, and the two models can score and word things differently.Tier 2 already records its provider and model in
llm_analysis, and each Tier 3 judge recordsjudge_model_used. This change gives the rubric judge, the Insights judge and the dimension judge the same provenance, and makes the Tier 3 judge label hold for sticky-served turns too.There is no public issue for this.
Kept from public
LLMClientmakes one call per request. On the native Claude API, the server-side fallback already covers refusals. This change only records which model answered. It adds no per-role fallback models and no refusal chaining. Tier 3 judge fallback (LLM_JUDGE_FALLBACK_MODELS, the Bedrock Opus 4.8 retry) is unchanged.fallbacksbody sent to the native Claude API are unchanged. Whether that header and body form match still needs a live check against the API; that belongs in a separate change, not here.rubric_evalmetadata, which the JSON reporter already emits. They are only added on the succeeded path. Failed, unavailable and malformed-judge records are unchanged, and so are the per-criterion aggregation and fail-closed checks.safe_llm_labelskeeps its behavior and now delegates its model half tosafe_llm_model.main's Python 3.9 verifier check still holds.InsightsJudge.parse_responseandDimensionJudge.parse_responseaddmodelonly when a call answered. Direct parse calls, such as the existing grounding tests, return exactly what they returned before.Tests
On unmodified
main, 12 of the new or changed tests fail andtests/inference/test_diagnostics.pyfails to importsafe_llm_model. All pass with this change. Two template tests also pass onmain: the existing fallback-block case and the new gateway guard.tests/validators/test_rubric_eval.py::test_json_report_names_the_model_that_scoredRubricEvalValidatorthrough the real Anthropic SDK with anhttpx.MockTransporton the native endpoint. Each reply's top-levelmodelis the model that answered, as the API sends it.rubric_evaland success detail nameclaude-opus-5-5.fallbackblock and afallback_messageusage iteration; they nameclaude-opus-4-8.modeland afallback_messageusage iteration; they nameclaude-opus-4-8.tests/inference/test_llm_client.py::TestModelProvenancemodel_usedisNonebefore a call, the configured model after a success, andNoneagain after a refused call.fallbackssent, configured model reported).claude-opus-4-8.model.tests/tier3/test_judge_parse_robustness.pytest_template_required_judge_records_the_model_that_answeredcovers a fallback in this call and a sticky-served turn; both recordjudge_model_used: claude-opus-4-8andjudge_fallback_used: true.test_template_anthropic_reply_model_is_ignored_without_server_side_fallback: a gateway reply'smodeldoes not replace the configured model.tests/inference/test_diagnostics.py: the URL, token and control-text cases now also coversafe_llm_model.tests/inference,tests/evaluation,tests/validators,tests/deduplication,tests/reporting,tests/tier3,tests/cli/test_tier_workflows.py,tests/test_llm_judge.py,tests/test_tier3_public_runtime.py,tests/test_harbor_local_environment.pyandtests/test_harbor_runtime_skill_isolation.py. 11,563 passed, 4 skipped, 15 failed. All 15 failures are in code this change does not touch and are unrelated to it:test_generated_custom_only_script_*cases intests/tier3/test_judge_failure_artifacts.py. The generated runner runs under the host'spython3, which was Python 3.9 there, and 3.9 rejectsint | floatinisinstance.tests/tier3/test_workflow.py. They hit their 5-second subprocess timeout under heavy machine load. This change does not touch the Tier 3 workflow.tests/inference,tests/evaluation,tests/validators/test_rubric_eval.pyandtests/tier3/test_judge_parse_robustness.pypass on the final commit (443 passed, 1 skipped).ruff checkpasses on all changed files.ruff format --checkpasses on all changed files except for two hunks this change does not touch intests/inference/test_llm_client.py, which fail the same way onmain.scripts/check_oss_boundary.pypasses..gitleaks.tomlfinds no leaks in this branch's commits.🤖 Generated with Claude Code