Skip to content

feat(ui): expose the assistant-turn classifier context switch on Auto-Router screens - #35500

Merged
tin-berri merged 1 commit into
litellm_internal_stagingfrom
litellm_lit5082_autorouter_assistant_context_ui
Aug 1, 2026
Merged

feat(ui): expose the assistant-turn classifier context switch on Auto-Router screens#35500
tin-berri merged 1 commit into
litellm_internal_stagingfrom
litellm_lit5082_autorouter_assistant_context_ui

Conversation

@tin-berri

@tin-berri tin-berri commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

How it solves it:

  • Adds an "Include Assistant Turns" switch to the classifier section, rendered only when the LLM classifier is selected
  • Wires it through the create stack and the edit stack, which share the rendered control but keep separate serializers, hydration and managed-key sets

Relevant issues

  • Puts the assistant-turn context switch on the Auto-Router create and edit screens
  • Persists the switch when it is off, since that is a choice rather than an absent value
  • Labels the switch for assistive technology, so it is identifiable rather than an unnamed control

Follows the UI split established by #35185 -> #35315

Linear ticket

Resolves LIT-5082

Pre-Submission checklist

  • I have added meaningful tests
  • My PR passes all CI/CD checks (e.g., lint, format, unit tests)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review

Screenshots / Proof of Fix

This is a UI change, so here is the click-through rather than a curl. Run the proxy on localhost:4000 and the dashboard dev server with npm run dev in ui/litellm-dashboard.

Create path:

  1. Go to http://localhost:3000/ui/?page=llm-model-hub, open the Add Model tab and pick Auto Router
  2. Expand Advanced: Classification Method and select LLM Classifier
  3. An Include Assistant Turns switch appears under the existing Context Window Size and Context Per-Turn Character Limit, off by default
  4. Switch it on and create the router
  5. Go to http://localhost:4000/ui/?page=llm-model-hub, find the router, and confirm the stored complexity_router_config carries classifier_context_include_assistant_turns: true

Edit path, which is the half that a create-only wiring would break:

  1. Open the router's Edit modal and expand Advanced: Classification Method
  2. The switch reads back on
  3. Save without touching anything and confirm the value survives unchanged
  4. Turn it off, save, and confirm the stored config now has classifier_context_include_assistant_turns: false rather than the key vanishing
  5. Select Heuristic and confirm the switch disappears and the key is not written

The backend behaviour this control drives was proven on a live proxy in #35471.

Type

🆕 New Feature

Changes

  • ClassificationMethodConfig.tsx renders the switch inside the existing classifier_type === "llm" block, with an aria-label so it has an accessible name, and clears the field when the classifier is switched back to heuristic
  • ComplexityRouterConfig.tsx carries the field on ComplexityRouterConfigValue
  • build_complexity_router_config.ts and add_auto_router_tab.tsx serialize it on the create path
  • edit_auto_router_modal.tsx adds it to MANAGED_COMPLEXITY_ROUTER_KEYS, to buildUpdatedComplexityRouterConfig, and to the hydration that fills the form from the stored config

Things a reviewer will ask about:

Why false is emitted rather than omitted. An operator turning assistant context off is a decision that has to overwrite a stored true, and a truthiness-based emit would silently drop it, so the switch emits whenever it is defined rather than only when true.

Why the field count is five rather than one. The create and edit paths share ClassificationMethodConfig but duplicate the serializer, the hydrator and the managed-key allow-set. Anything missing from MANAGED_COMPLEXITY_ROUTER_KEYS is carried through from the stored config untouched, so a field wired everywhere except that set silently ignores the form. The edit-modal test drives the real component through open, edit and save, because the serializer unit tests are handed a form value assembled by hand and cannot see a hydration or managed-key gap.

QA runbook

Automated coverage, npx vitest run src/components/add_model src/components/edit_auto_router, 164 tests:

  • build_complexity_router_config.test.ts covers emit when llm, omit when heuristic, omit when unset, and false still emitted
  • build_updated_complexity_router_config.test.ts covers the same on the edit serializer plus the untouched round trip and the no-stale-resurrection case
  • ComplexityRouterConfig.test.tsx covers rendering, the default-off state, hiding under heuristic, and the switch calling onChange
  • edit_auto_router_modal.test.tsx drives the real modal: the stored value hydrates, an untouched save preserves it, and turning the switch off persists

Mutation-checked by removing each wiring point in turn: dropping the key from MANAGED_COMPLEXITY_ROUTER_KEYS, removing the hydration arm, and removing the aria-label each fail tests that pass on the real code.

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

Note

Low Risk
Dashboard-only wiring for an existing router config flag; enabling it can change tier routing and spend, but behavior is explicit in the UI and covered by tests.

Overview
Exposes classifier_context_include_assistant_turns in the Admin UI for complexity Auto-Routers, which previously required config.yaml or the model API.

When LLM Classifier is selected under Advanced: Classification Method, a new Include Assistant Turns switch appears (default off, with tooltip about tier/spend and sending assistant text to the classifier). Switching back to Heuristic clears the field from form state.

The flag is threaded through create (add_auto_router_tabbuild_complexity_router_config) and edit (edit_auto_router_modal: hydration, MANAGED_COMPLEXITY_ROUTER_KEYS, buildUpdatedComplexityRouterConfig). Serialization only includes the key for LLM classifiers when the value is defined—including false so turning it off overwrites a stored true.

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

@tin-berri

Copy link
Copy Markdown
Contributor Author

@greptileai can you reply here with a score and why that score?

@tin-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@greptile-apps

greptile-apps Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Score: 5/5

The implementation is clean and the rationale is sound. Here's what holds it at a 5:

Correctness of the two asymmetric emit rules:

  • false for the switch is emitted because it's an explicit operator decision that must overwrite a stored true — a truthiness gate would silently drop it. Correct.
  • Blank rubric is omitted rather than sent as "" because the backend falls back to built-in tiers on absence, and an empty string would round-trip as a stored "value" that pollutes the edit form. Correct.

Coverage gaps that aren't gaps:

  • The PR description correctly explains why the serializer unit tests can't catch a hydration or managed-key miss — they receive a hand-assembled form value, not one produced by the hydrator. The edit_auto_router_modal.test.tsx integration test fills that gap by driving the real component through open → edit → save.
  • MANAGED_COMPLEXITY_ROUTER_KEYS is correctly extended with both keys, so neither is silently preserved from stored config when the form clears them.

Things I verified that are fine:

  • The typeof guards in the hydrator (=== "boolean", === "string") correctly reject non-typed stored values rather than coercing them.
  • The classifierType === "llm" guard in ClassificationMethodConfig.handleClassifierTypeChange correctly nulls both fields when switching back to heuristic, so stale values don't re-emerge if the user switches back to LLM.
  • Test mutations described in the QA runbook (dropping keys from MANAGED_COMPLEXITY_ROUTER_KEYS, removing hydration arms) would indeed fail the tests — the coverage is honest.

No issues found.

@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 4f98099. Configure here.

@greptile-apps

greptile-apps Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR exposes the existing assistant-turn classifier context option in the Auto-Router create and edit screens.

  • Adds an accessible switch for LLM classifier configurations.
  • Serializes, hydrates, and preserves explicit true and false values across create and edit flows.
  • Adds component and serializer coverage for rendering, persistence, and heuristic-mode omission.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains; the previously unnamed switch now exposes an accessible name on the interactive control, and the tests query it by that name.

Important Files Changed

Filename Overview
ui/litellm-dashboard/src/components/add_model/ClassificationMethodConfig.tsx Adds the assistant-turn switch with an accessible name and clears its value when switching to the heuristic classifier.
ui/litellm-dashboard/src/components/add_model/ComplexityRouterConfig.tsx Extends the form value type with the optional assistant-turn classifier setting.
ui/litellm-dashboard/src/components/add_model/add_auto_router_tab.tsx Carries the assistant-turn value from create-form state into payload construction.
ui/litellm-dashboard/src/components/add_model/build_complexity_router_config.ts Serializes defined boolean values for LLM classifiers, including an explicit false value.
ui/litellm-dashboard/src/components/edit_auto_router/edit_auto_router_modal.tsx Adds the setting to edit hydration, managed-key handling, and update serialization.
ui/litellm-dashboard/src/components/add_model/ComplexityRouterConfig.test.tsx Verifies accessible rendering, default state, classifier-dependent visibility, and state updates.
ui/litellm-dashboard/src/components/add_model/build_complexity_router_config.test.ts Covers true, false, unset, and heuristic serialization behavior on create.
ui/litellm-dashboard/src/components/edit_auto_router/build_updated_complexity_router_config.test.ts Covers edit round trips, explicit disabling, omission, and stale-value removal.
ui/litellm-dashboard/src/components/edit_auto_router/edit_auto_router_modal.test.tsx Exercises hydration and persistence through the real edit modal.

Reviews (2): Last reviewed commit: "feat(ui): expose the assistant-turn clas..." | Re-trigger Greptile

@tin-berri
tin-berri force-pushed the litellm_lit5082_autorouter_assistant_context_ui branch from 4f98099 to a8abb70 Compare August 1, 2026 21:21
…-Router screens

PR #35471 added classifier_context_include_assistant_turns to ComplexityRouterConfig.
It worked through config.yaml and the model API but had no control on the Add Model or
Edit Auto-Router screens, so an operator working from the dashboard could not reach it.
Wires it into the create and edit forms, shown only when the LLM classifier is
selected, matching what #35315 did for the two context-window fields

The create and edit stacks share the rendered control but keep their own serializer,
their own hydration, and their own managed-key set, so the field is added in five
places rather than one. A field wired into only one stack fails in a way neither
serializer unit test can see, since those are handed a form value assembled by hand,
so the edit-modal test drives the real component through open, edit and save

The switch is emitted even when false, because there the operator turning it off is a
choice that has to overwrite a stored true rather than an absent value a truthiness
gate would drop
@tin-berri
tin-berri force-pushed the litellm_lit5082_autorouter_assistant_context_ui branch from a8abb70 to 4c7b66c Compare August 1, 2026 21:29
@tin-berri tin-berri changed the title feat(ui): expose assistant-turn context and custom tier rubric on Auto-Router screens feat(ui): expose the assistant-turn classifier context switch on Auto-Router screens Aug 1, 2026
@tin-berri

Copy link
Copy Markdown
Contributor Author

@greptileai can you review this and give me a score & why the score

@tin-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@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 4c7b66c. Configure here.

@tin-berri
tin-berri enabled auto-merge (squash) August 1, 2026 21:46
@tin-berri
tin-berri disabled auto-merge August 1, 2026 22:38
@tin-berri
tin-berri merged commit 787a863 into litellm_internal_staging Aug 1, 2026
79 checks passed
@tin-berri
tin-berri deleted the litellm_lit5082_autorouter_assistant_context_ui branch August 1, 2026 22:38
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