feat(llm): implement ClassifierMode::Judge for cascade routing#1751
Merged
feat(llm): implement ClassifierMode::Judge for cascade routing#1751
Conversation
Wire the previously stubbed `ClassifierMode::Judge` path in `CascadeRouter`: - Add `judge_score()` in `cascade.rs`: sends a lightweight 0-10 scoring prompt to the summary provider, normalises the result to [0.0, 1.0], returns `None` on any error so callers can fall back to heuristics. - Add `evaluate_quality()` async helper in `RouterProvider`: dispatches to `judge_score` when mode is `Judge`, falls back to heuristic on LLM error or missing provider. - Update `cascade_chat` and `cascade_chat_stream` to call `evaluate_quality` instead of `evaluate_heuristic` directly. - Add `summary_provider: Option<AnyProvider>` field to `CascadeRouterConfig`. - Bootstrap: build and wire the summary provider when `classifier_mode = "judge"`; emit a startup warning when judge mode is configured without `summary_model`. - Add unit tests for `parse_judge_score` (integer, decimal, surrounding text, boundary values, garbage input).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1723
Summary
ClassifierMode::JudgeinCascadeRouter— previously configured as an option but silently fell through to heuristic mode with no warningjudge_score()incascade.rs: sends a lightweight 0–10 scoring prompt to the summary provider, normalises the result to [0.0, 1.0], returnsNoneon any error so callers fall back to heuristicsevaluate_quality()async helper inRouterProvider: dispatches tojudge_scorewhen mode isJudge, falls back to heuristic on LLM error or missing providercascade_chatandcascade_chat_streamnow useevaluate_qualityinstead ofevaluate_heuristicdirectlyCascadeRouterConfiggainssummary_provider: Option<AnyProvider>field[llm] summary_modelwhenclassifier_mode = "judge"; emits startupWARNwhen judge mode is configured withoutsummary_modelparse_judge_score: integer, decimal, surrounding text, boundary values (0, 10), garbage inputTest plan
cargo nextest run --workspace --features full --lib --bins— 5433 passed, 0 failedcargo clippy --workspace --features full -- -D warnings— cleancargo +nightly fmt --check— cleanstrategy = "cascade",classifier_mode = "judge",summary_model = "ollama/qwen3:8b"and verify judge scoring in actionsummary_modeland verify startup warning in logs