Skip to content

fix(auto-router): separate tuning and select chained heuristic - #44928

Merged
tin-berri merged 1 commit into
mainfrom
litellm_classifier_chaining_tuning
Oct 6, 2026
Merged

tin-berri merged 1 commit into
mainfrom
litellm_classifier_chaining_tuning

Conversation

@tin-berri

@tin-berri tin-berri commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • Always-judge mode exposes unrelated heuristic controls
  • Chaining only supports v1, with tuning mixed together

How it solves it:

  • Show only the selected heuristic's tuning
  • Separate collapsible Heuristic tuning and LLM tuning
  • Support v1 or v2 in both chaining modes

Intentional product change: Always-judge mode hides heuristic tuning, including fallback tuning, to keep judge settings focused. Existing fallback behavior stays unchanged

Companion documentation: Optimize your classifier, with 16 dashboard screenshots, matching YAML, and the full settings reference

User Flow

Before: configuring the judge exposes heuristic weights, while chaining has no version selector

  1. Open http://classifier.localhost:3058/models-and-endpoints/, click Add Auto Router, and select LLM
  2. Expand Advanced settings and select Always use the judge
  3. Scroll through Classifier tuning: Advanced scoring appears beneath judge controls
  4. Choose Heuristic first or Hybrid: there is no v1/v2 choice
Before screenshots

Always-judge mode before
Heuristic controls mixed with judge controls

After: judge-only settings stay focused, and chained heuristics have their own controls

  1. Open http://classifier.localhost:3058/models-and-endpoints/, click Add Auto Router, and select LLM
  2. Expand Advanced settings and select Always use the judge
  3. Only LLM tuning appears; heuristic tuning is hidden
  4. Choose Heuristic first or Hybrid, select v1/v2, and expand its Heuristic tuning section

Always-judge mode after

Saved router with v2 chaining

Version selector and separate tuning groups

Changes

  • Use the selected heuristic for local decisions and judge-failure recovery
  • Preserve selection through create, edit, reload, and preview
  • Enforce both v2 and custom-prompt allowances when combined
  • Keep omitted selectors on v1; no database migration

Pre-Submission checklist

  • Meaningful regression and mutation tests added
  • Focused tests and make check pass locally
  • Required CI and coverage pass on the current tip
  • Scope limited to classifier chaining and tuning
  • Greptile 5/5 on current tip 2b634df9; Bugbot, Veria, and human review complete

Screenshots / Proof of Fix

Real local proxy and isolated Postgres, with demo-efficient and demo-capable model aliases. The saved classifier-chain-demo router uses heuristic_first, local_heuristic: heuristic_v2, threshold 0.6, and maximum local tier MEDIUM

Shared routing command, with an authenticated local master key:

curl -sS http://127.0.0.1:4058/auto_router/test_routing \
  -H "Authorization: Bearer $LITELLM_MASTER_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"saved_model_id":"b686c693-3acd-4916-839a-f346631412e2","prompt":"Hi, thanks!","complexity_router_config":{"tiers":{"SIMPLE":["demo-efficient"]},"classifier_type":"heuristic"}}'

The saved router overrides the required inline config

Before (b6d587d)

Tuning UI

  1. Follow the Before flow above on the baseline dashboard
  2. Observe mixed heuristic/judge controls in the Before screenshots

Saved v2 Chain

  1. Run the shared command against the baseline proxy
  2. Observe cause: heuristic_first_short_circuit, tier: SIMPLE, score: -0.15000000000000002, and v1 keyword signals; no v2 forecast

After (2b634df)

Tuning UI

  1. Follow the After flow above on the current dashboard; create, reopen, and edit the saved router
  2. Observe mode-specific controls in the After screenshots; desktop and 390px mobile layouts verified

Saved v2 Chain

  1. Run the same command against the current proxy
  2. Observe cause: heuristic_first_short_circuit, tier: SIMPLE, and heuristic_v2_forecast with threshold 0.6 and SIMPLE probability 0.9010844930101933

30-second recording of real browser interactions:

classifier-tuning-demo.mp4

Type

Bug Fix, New Feature

Caveats

Medium

Final Attestation

  • Tests cover scorer selection, boundaries, recovery, persistence, and quotas

Note

Medium Risk
Changes live routing short-circuit logic and multi-capability license enforcement on model writes; broad test coverage but behavior shifts for heuristic_first/hybrid operators.

Overview
Adds local_heuristic so heuristic_first and hybrid can use heuristic v1 or v2 for local scoring before the LLM judge. Routing now picks the local scorer via configured_local_heuristic, applies v2 success-threshold and margin rules for short-circuit vs judge escalation, and records heuristic_v2_forecast on v2 decisions. Standalone v2 behavior is unchanged; chained v2 defers to the judge when no tier qualifies.

Licensing moves from a single gated capability per router to gated_capabilities_of / claimed_capabilities, so a v2 chain plus a custom classifier prompt can consume both heuristic_v2 and customization slots. Proxy availability and model-write paths loop all claimed capabilities under the same advisory lock.

Validation and tuning: local_heuristic is only allowed on chaining modes; custom dimensions require v1. Heuristic-v1 tuning quotas ignore v2-chained configs until v1 is selected.

Dashboard: Advanced settings split into selection, LLM/classifier tuning, and Heuristic tuning; judge-only mode hides heuristic knobs. Create/edit/build paths persist local_heuristic and gate the v2 chain on allowance UI.

Reviewed by Cursor Bugbot for commit 2b634df. Bugbot is set up for automated code reviews on this repo. Configure here.

@tin-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

Please review the current tip, especially scorer selection, combined capability allowances, and create/edit persistence across mode switches

@codecov

codecov Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@tin-berri

Copy link
Copy Markdown
Contributor Author

@greptileai Please review current commit 86a9a82, focusing on classifier selection, v2 chaining behavior, preserved defaults, and combined capability allowances

@tin-berri
tin-berri force-pushed the litellm_classifier_chaining_tuning branch from 86a9a82 to 2b634df Compare October 6, 2026 20:15
@tin-berri

Copy link
Copy Markdown
Contributor Author

@greptileai Please review current tip 2b634df, which adds the missing exhaustive saved-setting fixture and preserves the already-verified runtime behavior

@tin-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

Please review current tip 2b634df, including the updated exhaustive persistence fixture. Runtime code is unchanged from the previous tip

@greptile-apps

greptile-apps Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[High risk] Refactors auto-router capability tracking and heuristic classifier chaining.

The PR appears safe to merge; no actionable defects or rule violations were found

What we checked:

  • Images still reach the judge: Both chaining modes keep the existing image check before choosing a local result
  • Judge-only saves omit the selector: The form may retain the draft choice, but the builder writes local_heuristic only for chaining modes

Summary

This PR separates heuristic and judge tuning, adds a v1/v2 selector to both chaining modes, and checks every allowance claimed by a combined router

  • The selected scorer is used for local decisions and judge-failure recovery
  • Added tests cover thresholds, images, fallback choices, allowances, and saved settings, including the exhaustive saved-setting fixture
  • No actionable issues were found through code inspection. Tests and live browser flows were not run during this review

Acknowledgment: tin-berri explicitly states that Always-judge mode intentionally hides heuristic tuning, including fallback tuning, while keeping fallback behavior unchanged. This was not reported as an issue

Reviews (2) · Last reviewed commit: "fix(auto-router): separate tuning and se..."

@cursor cursor 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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 2b634df. Configure here.

@codspeed

codspeed Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing litellm_classifier_chaining_tuning (2b634df) with main (abd3af4)

Open in CodSpeed

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