Skip to content

feat(llm): implement ClassifierMode::Judge for cascade routing#1751

Merged
bug-ops merged 2 commits intomainfrom
feat-llm-implement-classifierm
Mar 14, 2026
Merged

feat(llm): implement ClassifierMode::Judge for cascade routing#1751
bug-ops merged 2 commits intomainfrom
feat-llm-implement-classifierm

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented Mar 14, 2026

Closes #1723

Summary

  • Wires ClassifierMode::Judge in CascadeRouter — previously configured as an option but silently fell through to heuristic mode with no warning
  • 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 fall back to heuristics
  • evaluate_quality() async helper in RouterProvider: dispatches to judge_score when mode is Judge, falls back to heuristic on LLM error or missing provider
  • Both cascade_chat and cascade_chat_stream now use evaluate_quality instead of evaluate_heuristic directly
  • CascadeRouterConfig gains summary_provider: Option<AnyProvider> field
  • Bootstrap: builds and wires the summary provider from [llm] summary_model when classifier_mode = "judge"; emits startup WARN when judge mode is configured without summary_model
  • 7 new unit tests for parse_judge_score: integer, decimal, surrounding text, boundary values (0, 10), garbage input

Test plan

  • cargo nextest run --workspace --features full --lib --bins — 5433 passed, 0 failed
  • cargo clippy --workspace --features full -- -D warnings — clean
  • cargo +nightly fmt --check — clean
  • Live session: configure strategy = "cascade", classifier_mode = "judge", summary_model = "ollama/qwen3:8b" and verify judge scoring in action
  • Live session: configure judge mode without summary_model and verify startup warning in logs

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).
@github-actions github-actions bot added enhancement New feature or request size/M Medium PR (51-200 lines) documentation Improvements or additions to documentation llm zeph-llm crate (Ollama, Claude) rust Rust code changes core zeph-core crate and removed size/M Medium PR (51-200 lines) labels Mar 14, 2026
@bug-ops bug-ops enabled auto-merge (squash) March 14, 2026 15:15
@github-actions github-actions bot added the size/M Medium PR (51-200 lines) label Mar 14, 2026
@bug-ops bug-ops merged commit 63f1231 into main Mar 14, 2026
15 checks passed
@bug-ops bug-ops deleted the feat-llm-implement-classifierm branch March 14, 2026 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core zeph-core crate documentation Improvements or additions to documentation enhancement New feature or request llm zeph-llm crate (Ollama, Claude) rust Rust code changes size/M Medium PR (51-200 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(llm): implement ClassifierMode::Judge for cascade routing

1 participant