Skip to content

refactor(llm): one quality-judgment seam for LLM-scored quality; SELF_REFLECTION routes through it (#16133) - #21815

Merged
mrveiss merged 19 commits into
mainfrom
issue-16133-llm-judged-quality
Nov 19, 2026
Merged

mrveiss merged 19 commits into
mainfrom
issue-16133-llm-judged-quality

Conversation

@mrveiss

@mrveiss mrveiss commented Nov 18, 2026 •

Copy link
Copy Markdown
Owner

Thinking Path

This PR was opened for an existing branch that never had one (triage status UNFINISHED). The branch carries 1ahead commit(s) of work not on main, linked to #16133 (tech-debt(quality): LLM-judged quality is implemented three times — ReflectionResult, JudgmentResult and ThinkCategory.SELF_REFLECTION). It still needs a conflict sync with main and a review before it can merge. Acceptance criteria have not been verified against this branch.

What Changed

Commits on the branch (not on main):

Diff summary: 13 files changed, 349 insertions(+), 28 deletions(-)

Verification

Not yet verified. No CI evidence: this is a draft; no CI has run on it yet, and it needs a conflict sync with main and a review first.

Model Used

Branch authored by earlier Claude sessions; PR opened by Claude Sonnet 5.5.

Refs #16133

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Reflection results now include a confidence score and critique, with scores kept within the 0–1 range.
    • Quality assessments now present a consistent score, critique, optional hint and threshold status across reflection and judgment results.
  • Improvements
    • Reflection-evaluation failures are now distinguished from low-scoring results, with a clear failure indication.
    • Evaluation verdicts and score thresholds are handled consistently across quality checks.

@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 35 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 576976e and 5563071.

Files selected for processing: 13

  • autobot-backend/agent_loop/self_reflection_seam_16133_test.py
  • autobot-backend/agent_loop/think_tool.py
  • autobot-backend/conftest.py
  • autobot-backend/judges/__init__.py
  • autobot-backend/llm_shared/quality_judgment.py
  • autobot-backend/llm_shared/quality_judgment_test.py
  • autobot-backend/rlm/evaluator.py
  • autobot-backend/rlm/types.py
  • repo_tests/_reach_declared_scopes.py
  • repo_tests/_reach_policy_verdicts.py
  • repo_tests/_reach_roots_record.py
  • repo_tests/llm_quality_seam_16133_test.py
  • repo_tests/reach_scope_claim_17844_test.py
Walkthrough

The changes add shared LLM judgement helpers and assessment projections. The judge, RLM evaluator, and self-reflection path use validated judgement. New tests cover these paths, and a source scan checks the designated callers.

Changes: LLM quality judgement

Layer / File(s) Summary
Shared judgement helpers and assessment projections
autobot-backend/llm_shared/quality_judgment.py, autobot-backend/rlm/types.py, autobot-backend/judges/__init__.py
Adds validated-judgement, score-clamping, and threshold helpers, plus an immutable QualityAssessment view. Judgment and reflection results can project their fields into that view. RLM verdicts map to recommendation terms.
Validated judgement callers and checks
autobot-backend/judges/__init__.py, autobot-backend/rlm/evaluator.py, autobot-backend/llm_shared/quality_judgment_test.py, autobot-backend/conftest.py, repo_tests/*
The judge and RLM evaluator use the shared validated-judgement helper. RLM score and verdict handling uses the shared score helpers. Tests cover results, verdicts, assessment projections, and score boundaries. A source scan checks for direct complete_validated calls and verifies designated callers use judge_validated.
Self-reflection through validated judgement
autobot-backend/agent_loop/think_tool.py, autobot-backend/agent_loop/self_reflection_seam_16133_test.py
Self-reflection requests schema-conforming JSON and uses validated judgement. It clamps the returned score and assigns zero confidence with a named risk when judging fails. Tests cover prompt formatting, result mapping, client use, and failure handling.
Merge Risk: Low · previous review 57697

Merge Risk: 🔵 Low · up to 57697

A malformed self-reflection reply containing NaN can be reported as perfect confidence instead of a judge failure. The impact is narrow and the fix is small, so this is mergeable with a follow-up.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: a single quality-judgment seam for LLM-scored quality, with SELF_REFLECTION routed through it. The changeset adds llm_shared/quality_judgment.py with judge_validated, …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: a single quality-judgment seam for LLM-scored quality, with SELF_REFLECTION routed through it. The changeset adds llm_shared/quality_judgment.py with judge_validated, updates the judges, RLM evaluator and think tool to use it, and adds a guard test that flags direct complete_validated calls. The title is concise, specific and matches the objectives. The title is 107 characters, which is longer than ideal but still readable.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions

Copy link
Copy Markdown
Contributor

Auto-sync: merging main into issue-16133-llm-judged-quality conflicts

The sync aborted the merge and pushed nothing. Conflicts are information, so it never resolves one itself. Below, for each conflicted file, are the commits that touched it on each side since the merge base 38c62a97b8. Merge main in yourself and push; the label clears on the first run that finds this branch 0 behind.

repo_tests/_reach_policy.py

side commit subject issue refs
main a471e4d87e test(i18n): a shrink-only ratchet on hard-coded English UI text, per file (#12732) #12732
main 091af388da fix(api): register literal routes ahead of the {param} routes that captured them (#18720) #18720
main b10b96593b fix(config): floor the env-family guard's reach and declare its filter widening (#18555) #18555
main 246b86f9ee test(train): record why #18641's backoff-formula-scan allowance is absolute (#15402) #18641, #15402
main 8ba19f55b0 Merge #18626 @ 514e49b into train-2026-10-17-22b #18626
main a44a310265 refactor(llm): one Anthropic-family message formatter shared by the anthropic and vertexai providers (#16815) #16815
main 547f376ebb refactor(resilience): the circuit breaker moves to autobot_shared behind a backend shim; a guard stops new hand-rolled breakers (#18554) #18554
main a388889be4 Merge #18612 @ af1ff7e into train-2026-10-16-20 #18612
main 8864e0c436 fix(slm): node enrollment deploys the real agent through the slm_agent role; the inline stand-in agent and string-embedded playbook are gone (#18606) #18606
main 383ea8c375 refactor(redis): a guard freezes today's direct Redis constructors; the terminal and timeout callers use the canonical client (#18553) #18553
main 8251c2087f Merge #18595 @ a600d2a into train-2026-10-16-17b #18595
main 0be6ce0c6a Merge #18591 @ 5f94ace into train-2026-10-16-17b (hub union: reach policy) #18591
main a600d2afc0 refactor(backend): retire 8 compatibility facades; importers use the canonical modules (#18552) #18552
main aaeb648337 refactor(data): one copy of each static data file (#18556) #18556
main 960fa5086c refactor(browser): one playwright-server.js; drop the unreferenced backup compose (#18549) #18549
main 96 more commit(s) not listed
this branch 14a9c0ecb0 refactor(llm): one judging seam for LLM-scored quality, drop the unwired SELF_REFLECTION fork (#16133) #16133

repo_tests/python_file_size_ratchet_baseline.py

side commit subject issue refs
main ad4e03163c dedup(ratchet): one ceiling table per size gate, checked against the base commit; a guard bars a second one (#19544) #19544
main c79ad98806 Merge main @ 6f1dcd3 into the merge train (PR #19638) #19638
main 51f15381cd Merge #19396 @ 1148b33 into train-2026-10-26-85l #19396
main 3730956301 Merge #19415 @ 8b7452d into train-2026-10-26-85l #19415
main c66adca250 Merge #19392 @ 84e1d04 into train-2026-10-26-85l #19392
main 2224f6e036 Merge #19627 @ e503344 into train-2026-10-26-85l #19627
main c498219dc0 Merge main @ 8c511bf (train 85j) into train-2026-10-26-85k none
main 0a9108b96e Merge #19399 @ 1ff25fb into train-2026-10-26-85k #19399
main 104afb6f07 Merge remote-tracking branch 'origin/main' into issue-19144-kb-principal none
main 8b7452dce9 Merge remote-tracking branch 'origin/main' into issue-19320-postgres-one-source none
main f5e0464edc Merge remote-tracking branch 'origin/main' into issue-19319-routers-strict none
main 84e1d04069 Merge remote-tracking branch 'origin/main' into issue-19315-env-mode-one-source none
main 988b0e2a1e Merge remote-tracking branch 'origin/main' into issue-19280-rag-leftovers none
main 09bc2d80ae Merge remote-tracking branch 'origin/main' into HEAD none
main 785a832f02 Merge #19509 @ 8cf459a into train-2026-10-26-85j #19509
main 421 more commit(s) not listed
this branch 14a9c0ecb0 refactor(llm): one judging seam for LLM-scored quality, drop the unwired SELF_REFLECTION fork (#16133) #16133

repo_tests/reach_scope_claim_17844_test.py

side commit subject issue refs
main be5b2b0be2 test(guards): one compare-and-delete script, the shape matched with recorded exceptions and a planted-copy control (#19631) #19631
main fe97219e8c Merge origin/main into issue-21078-test-filenames (#21078) #21078
main 5d6c08c7eb refactor: move the reach scope record to its own module and register the test-name guard (#21078) #21078
main eb0ccc38fc Merge main into issue-20761-api-key-compare (auto-sync) [skip ci] none
main 464269b063 fix(train): reach floor follows the merged tree; scope-claim test stays under the 600-line cap (#17844) #17844
main 8019cce84d Merge branch 'main' into train-2026-11-07-t91 none
main 1fd6964fd3 fix(auth): the constant-time compare guard declares its reach floor, scope and roots (#20761) #20761
main 25b8798246 Merge #20969 @ b9c58d0 into the merge train #20969
main c16ff8bae0 Merge #20893 @ 1658109 into the merge train #20893
main 74816fa315 fix(deploy): record the venv-builder guard's declared scope in both reach records (#20932) #20932
main 982e6998ff merge: origin/main into issue-20889-snapshot-cleanup; route #20478 sites through accessors (#20889) #20478, #20889
main a35719e02d Merge main into issue-20046-ssh-password-proposal (auto-sync) [skip ci] none
main c09459f5d8 fix(snapshots): record the inline-lazy_singleton guard's scope and floor (#20889) #20889
main ab55d41295 Merge main into issue-20046-ssh-password-proposal none
main 2b2f7e52f4 Merge main into issue-20512-unconnected-code-gate (auto-sync) [skip ci] none
main 311 more commit(s) not listed
this branch 14a9c0ecb0 refactor(llm): one judging seam for LLM-scored quality, drop the unwired SELF_REFLECTION fork (#16133) #16133

@github-actions github-actions Bot added the sync-conflict Set by the branch sync (#19548) label Nov 18, 2026
@mrveiss mrveiss changed the title refactor(llm): one judging seam for LLM-scored quality, drop the unwired SELF_REFLECTION fork (#16133) refactor(llm): one quality-judgment seam for LLM-scored quality, drop unwired SELF_REFLECTION (#16133) Nov 18, 2026
@mrveiss

mrveiss commented Nov 18, 2026

Copy link
Copy Markdown
Owner Author

Decision needed: remove or wire in ThinkCategory.SELF_REFLECTION

This PR (synced with main today, 13 files) adds one quality-judgment seam (autobot-backend/llm_shared/quality_judgment.py, used by rlm/evaluator.py and judges/). It also deletes ThinkCategory.SELF_REFLECTION (agent_loop/types.py:102) and its prompt (agent_loop/think_tool.py:116) because nothing selects that category today.

The standing rule is that unwired code is wired in, not deleted. SELF_REFLECTION describes exactly what the new seam does (RLM evaluating its own response quality, #1373), so wiring is a real option.

Option What happens
A (recommended): wire it in Keep the category; make the think tool's self-reflection step call the new quality seam, so the category has a caller.
B: delete as the PR does Accept the removal; record why in this PR (no caller, superseded by the seam).
C: split Land the seam now without touching SELF_REFLECTION; decide the category in #16133.

The PR stays a draft until this is decided.

@mrveiss mrveiss added the needs-decision Blocked on an owner decision; options and a recommendation are on the issue label Nov 18, 2026
@mrveiss

mrveiss commented Nov 18, 2026

Copy link
Copy Markdown
Owner Author

Decision (owner, 2026-11-18): option A — keep ThinkCategory.SELF_REFLECTION and wire it in: the think tool's self-reflection step routes through the new quality-judgment seam (llm_shared/quality_judgment.py), so the category gains a caller instead of being deleted. Rework follows in this PR.

@mrveiss mrveiss removed the needs-decision Blocked on an owner decision; options and a recommendation are on the issue label Nov 18, 2026
@mrveiss mrveiss changed the title refactor(llm): one quality-judgment seam for LLM-scored quality, drop unwired SELF_REFLECTION (#16133) refactor(llm): one quality-judgment seam for LLM-scored quality; SELF_REFLECTION routes through it (#16133) Nov 18, 2026
@mrveiss
mrveiss marked this pull request as ready for review November 19, 2026 00:06
@github-actions

Copy link
Copy Markdown
Contributor

Notice: 29 open PRs — past the runaway threshold (25)

This is not a request to defer this PR. There is no cap on open PRs (#19397) -- nothing blocks opening or pushing a PR.

This notice only means the count is high enough to be worth a glance for a runaway — something opening PRs in a loop, or a merge pipeline that has stalled so nothing is draining.

Currently open:

If the queue is draining normally, ignore this. Otherwise:

  1. Check whether CI is dispatching at all — see the ci-dispatch-watchdog status on these PRs
  2. Approved PRs land through the merge train the coordinator sequences (merge commits, never squash) -- check the open chore(merge-train) PR is moving, not each PR on its own
  3. Look for a loop opening near-identical PRs

Warn-only runaway detector — .github/workflows/pr-queue-gate.yml. It never blocks a merge.

@github-actions

Copy link
Copy Markdown
Contributor

✅ SSOT Configuration Compliance: Passing

🎉 No new hardcoded values of either class — ssot and other both block.

Known backlog in pipeline-scripts/hardcoded_values_baseline.txt is suppressed and tracked in #14371.

@mrveiss mrveiss added the land-next Landing set: CI capacity goes to these PRs first (owner direction 2026-09-18, #15397) label Nov 19, 2026
@github-actions github-actions Bot removed the sync-conflict Set by the branch sync (#19548) label Nov 19, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between f2c0d74 and 13aa18b.

Files selected for processing: 13

  • autobot-backend/agent_loop/self_reflection_seam_16133_test.py
  • autobot-backend/agent_loop/think_tool.py
  • autobot-backend/conftest.py
  • autobot-backend/judges/__init__.py
  • autobot-backend/llm_shared/quality_judgment.py
  • autobot-backend/llm_shared/quality_judgment_test.py
  • autobot-backend/rlm/evaluator.py
  • autobot-backend/rlm/types.py
  • repo_tests/_reach_declared_scopes.py
  • repo_tests/_reach_policy_verdicts.py
  • repo_tests/_reach_roots_record.py
  • repo_tests/llm_quality_seam_16133_test.py
  • repo_tests/reach_scope_claim_17844_test.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@mrveiss mrveiss added land-next Landing set: CI capacity goes to these PRs first (owner direction 2026-09-18, #15397) and removed land-next Landing set: CI capacity goes to these PRs first (owner direction 2026-09-18, #15397) labels Nov 19, 2026
@mrveiss mrveiss removed the land-next Landing set: CI capacity goes to these PRs first (owner direction 2026-09-18, #15397) label Nov 19, 2026
@mrveiss
mrveiss merged commit 11f20b3 into main Nov 19, 2026
66 checks passed
@mrveiss
mrveiss deleted the issue-16133-llm-judged-quality branch November 19, 2026 09:13
@mrveiss mrveiss removed the land-next Landing set: CI capacity goes to these PRs first (owner direction 2026-09-18, #15397) label Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

phase:M4.9 One definition per concept

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant