Skip to content

feat(llm): record the model that wrote rubric scores and Tier 3 insights - #308

Merged
rng1995 merged 7 commits into
mainfrom
naren/port-judge-model-provenance
Nov 5, 2026
Merged

rng1995 merged 7 commits into
mainfrom
naren/port-judge-model-provenance

Conversation

@rng1995

@rng1995 rng1995 commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

Rubric scores, LLM-written Tier 3 insights and LLM-written compute_dimensions dimensions 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 successful completions() call. For a native Claude API request that asked for server-side fallback, it is read from the reply, in this order:

    1. The model that the last fallback content block hands over to. Both block shapes are read: the dict that the current SDK leaves on an untyped block, and the to.model attribute of a typed block.
    2. Otherwise the reply's top-level model. A turn served by sticky routing has no fallback block. When a request falls back, the API sends repeats of it straight to the fallback model for a while, so re-running rubric-eval on the same skill soon after can be answered by the fallback model with no block. The top-level model names the model that wrote the message.
    3. Otherwise the configured model.

    For every other request (gateways, other providers, models before Claude 5.5) it is the configured model. A reply's model field 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 is None before a call succeeds and after a call fails. A small provider property exposes the resolved provider, next to the existing model and base_url properties.

  • rubric-eval. The skill's rubric_eval success detail carries llm_provider and llm_model_used. For a single skill, the rubric_eval object 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 model next to source: "llm". Deterministic entries are unchanged.

  • compute_dimensions. Each LLM-written dimension carries model. 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_anthropic read judge_model_used only from the fallback block, so a sticky-served judge reply was labeled with the configured model. It now uses the same order as LLMClient, so both copies agree. A gateway reply's model is still ignored there.

  • Label sanitizing. All labels go through the sanitizer Tier 2 already uses for llm_analysis.provider and model. Its model half is now also exposed as safe_llm_model. A URL or key-like model value is reported as unresolved.

  • Docs. docs/tier1-validation.mdx covers the rubric fields. docs/reports.mdx covers 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_dimensions output 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 records judge_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

  • No client-side role fallback chain. Public LLMClient makes 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.
  • The 0.6.0 request shape. The beta header and the fallbacks body 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.
  • Public's typed rubric execution contract. The labels are added to the existing rubric_eval metadata, 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.
  • Tier 2 label sanitizer. The same sanitizer is reused rather than writing raw model strings into reports. safe_llm_labels keeps its behavior and now delegates its model half to safe_llm_model.
  • Python 3.9 verifier. The Harbor verifier template change uses only syntax that Python 3.9 accepts, so main's Python 3.9 verifier check still holds.
  • Existing parse contracts. InsightsJudge.parse_response and DimensionJudge.parse_response add model only 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 and tests/inference/test_diagnostics.py fails to import safe_llm_model. All pass with this change. Two template tests also pass on main: the existing fallback-block case and the new gateway guard.

  • tests/validators/test_rubric_eval.py::test_json_report_names_the_model_that_scored
    • Runs RubricEvalValidator through the real Anthropic SDK with an httpx.MockTransport on the native endpoint. Each reply's top-level model is the model that answered, as the API sends it.
    • Configured model: no fallback block; the JSON report's rubric_eval and success detail name claude-opus-5-5.
    • Fallback in this call: a fallback block and a fallback_message usage iteration; they name claude-opus-4-8.
    • Sticky-served turn: no block, only the top-level model and a fallback_message usage iteration; they name claude-opus-4-8.
  • tests/inference/test_llm_client.py::TestModelProvenance
    • model_used is None before a call, the configured model after a success, and None again after a refused call.
    • It names the fallback model for both untyped (dict) and typed fallback blocks.
    • Through the real SDK: a sticky-served native reply with no block names the reply's model, and a gateway reply's model is ignored (no fallbacks sent, configured model reported).
    • It is per thread.
    • Insights conclusions and recommendations written after a fallback name claude-opus-4-8.
    • LLM-written dimensions name the model, and the deterministic fallback dimensions have no model.
  • tests/tier3/test_judge_parse_robustness.py
    • test_template_required_judge_records_the_model_that_answered covers a fallback in this call and a sticky-served turn; both record judge_model_used: claude-opus-4-8 and judge_fallback_used: true.
    • test_template_anthropic_reply_model_is_ignored_without_server_side_fallback: a gateway reply's model does not replace the configured model.
  • tests/inference/test_diagnostics.py: the URL, token and control-text cases now also cover safe_llm_model.
  • Neighbour suites in one run: 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.py and tests/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:
    • 13 test_generated_custom_only_script_* cases in tests/tier3/test_judge_failure_artifacts.py. The generated runner runs under the host's python3, which was Python 3.9 there, and 3.9 rejects int | float in isinstance.
    • 2 FIFO tests in 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.py and tests/tier3/test_judge_parse_robustness.py pass on the final commit (443 passed, 1 skipped).
  • ruff check passes on all changed files. ruff format --check passes on all changed files except for two hunks this change does not touch in tests/inference/test_llm_client.py, which fail the same way on main.
  • scripts/check_oss_boundary.py passes.
  • Gitleaks with the repository's .gitleaks.toml finds no leaks in this branch's commits.

🤖 Generated with Claude Code

rng1995 and others added 2 commits October 31, 2026 22:18
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 rng1995 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 import safe_llm_model. _call_anthropic copies the fallback block's to.model into judge_model_used as is, as it did before. For a sticky-served turn it now does the same with the reply's top-level model. For example, a native reply with no fallback block and "model": "https://x.example/sk-abc" records judge_model_used: "https://x.example/sk-abc", while safe_llm_model returns unresolved for the same string. Only the rubric, Insights and compute_dimensions labels 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.

Comment thread CHANGELOG.md Resolved
Comment thread docs/tier1-validation.mdx Resolved
Comment thread src/skillevaluator/inference/client.py Resolved
rng1995 and others added 4 commits November 2, 2026 11:16
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 chrisknvidia left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]>
@rng1995
rng1995 merged commit c928d82 into main Nov 5, 2026
22 checks passed
@rng1995
rng1995 deleted the naren/port-judge-model-provenance branch November 5, 2026 18:07
rng1995 added a commit that referenced this pull request Nov 5, 2026
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]>
rng1995 added a commit that referenced this pull request Nov 5, 2026
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants