Skip to content

fix(databricks): backport the ai_decide AI Function route to rc/1.106.0 (#45722) - #45921

Open
devin-ai-integration[bot] wants to merge 11 commits into
rc/1.106.0from
litellm_backport_databricks_ai_decide_rc_1_106_0
Open

devin-ai-integration[bot] wants to merge 11 commits into
rc/1.106.0from
litellm_backport_databricks_ai_decide_rc_1_106_0

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

TLDR

This backports #45722's Databricks ai_decide fix onto rc/1.106.0 as part of the decisions key feature (# key-feature: decisions). #45200 already landed on the rc, so this carries only #45722

Problem this solves:

  • On the rc, databricks/ai_decide goes to <workspace>/serving-endpoints/ai_decide/invocations, which answers 404
  • So /v1/systemone, /v1/decisions, and the Databricks auto router classifier never reach it

How it solves it:

  • databricks/ai_decide now posts to /api/2.0/ai-functions/ai-decide with no model, and its response envelope is unwrapped
  • Bare serving endpoint names still go to /serving-endpoints/<name>/invocations

User Flow

Before: an admin on rc/1.106.0 whose Databricks workspace has ai_decide gets a 404 on every decision

  1. They add a databricks/ai_decide model with DATABRICKS_API_BASE and DATABRICKS_API_KEY
  2. They send POST https://litellm-domain/v1/systemone with that model, a state, and a tier choice question
  3. They get a 404 from Databricks saying the ai_decide serving endpoint does not exist

After: the same request gets its answers from ai_decide, and the auto router can classify through it

  1. They add the same databricks/ai_decide model
  2. The same POST https://litellm-domain/v1/systemone answers 200 with the tier answer from Databricks
  3. A bare serving endpoint model such as databricks/databricks-openjev-qwen35-4b still answers from its serving endpoint
  4. On https://litellm-domain/ui/?page=models, Add Auto Router with the Databricks classifier starts on ai_decide

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. uv run pytest tests/unit/<your_test_file>.py -v. Leave the suites (make test-unit-*, make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • 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 (Greptile reviews automatically once the PR is opened; only comment @greptileai to re-request a review after pushing changes)

Screenshots / Proof of Fix

The live proof against a real Databricks workspace is in #45722. On this branch the decisions, auto router, and Jev classifier tests pass, plus the classifier config Vitest files

Type

🆕 New Feature

Changes

The commits of #45722, adapted to the rc and merged with rc/1.106.0 after #45200 landed there. #45722 is still open on main, so this gets refreshed if it changes before merge

Link to Devin session: https://app.devin.ai/sessions/eb7bc14dde6d4598a7abc06e9eca6267
Open in Devin Desktop: https://app.devin.ai/desktop/session/eb7bc14dde6d4598a7abc06e9eca6267?variant=devin


Note

Medium Risk
Changes Databricks decisions URL/body/response handling for a dedicated model id across proxy, router, and classifiers; behavior is well covered by tests but affects evaluation and auto-routing paths.

Overview
Fixes databricks/ai_decide so it no longer hits a non-existent serving-endpoint URL (…/serving-endpoints/ai_decide/invocations). The model now POSTs to /api/2.0/ai-functions/ai-decide, drops model from the request body, and normalizes the wrapped response payload (including mapping probability → noul for System One answers).

Named serving endpoints are unchanged: they still use /serving-endpoints/<name>/invocations with model in the body. Validation and error copy now allow ai_decide or a bare endpoint name.

The same routing applies on adecisions / asystemone, proxy /v1/systemone, and the OSS/Jev Databricks classifier (HTTP client omits model for ai_decide). databricks/ai_decide is added to the model cost map (zero spend). Dashboard auto-router defaults the Databricks classifier to ai_decide with updated placeholders and schema validation.

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

mateo-berri and others added 7 commits October 11, 2026 04:43
…5200)

* feat(decisions): add Databricks ai_decide as a /v1/decisions provider and auto-router decider

* fix(decisions): reject Databricks endpoint names carrying URL separators and keep the provider wiring under llms/

* fix(decisions): reject dot-segment Databricks endpoint names and add Databricks to the dashboard's OSS classifier editor

* fix(ui): name every OSS classifier provider in the classifier radio copy

* feat(decisions): register the Databricks OpenJev decider as an evaluation-mode cost-map entry

* fix(cost-map): declare zero cache rates on the databricks-openjev-qwen35-4b entry

* fix(proxy): reconcile every DB deployment when a registry miss lands on an auto router

A /model/new for an auto router lands on one replica. A request routed to
that auto router on a sibling replica missed it, the model read-through
loaded only the auto router's own row, and the pre-routing hook then picked
a tier the sibling had not loaded, so the caller got a 400 "no healthy
deployments for <tier>" until the next periodic reload. An auto router miss
now runs the full add_deployment reconcile, tiers included. Found by the
audit's two-worker rig on this PR's routing cells; CircleCI's one-worker
proxy never opens the window.

* test(integration): audit cells for Databricks decisions and the Databricks auto-router classifier

Wire cells for /v1/decisions with databricks/<endpoint> deployments, routing
cells for the complexity router's databricks classifier on all three
endpoints with the Postgres rows read back, management cells for the
classifier's spend writes and for the evaluation-mode health check of a
Databricks serving endpoint.

(cherry picked from commit 883e321)
…routing

Databricks serves ai_decide at POST <host>/api/2.0/ai-functions/ai-decide, not
on a serving endpoint's /invocations route. The decisions provider and the
auto-router classifier now accept only the ai_decide model, post to that route
without a model field, unwrap the response envelope, and map a noul answer's
probability to the System One noul field.

(cherry picked from commit ee1743a)
…he liveliness bound

(cherry picked from commit 99452c2)
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor

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.

Stale Bugbot comment from a previous run.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration devin-ai-integration Bot changed the title feat(decisions): backport the Databricks ai_decide decider to rc/1.106.0 (#45200, #45722) fix(databricks): backport the ai_decide AI Function route to rc/1.106.0 (#45722) Oct 11, 2026
…e rc merge

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@mateo-berri

Copy link
Copy Markdown
Contributor

bugbot run

@mateo-berri

Copy link
Copy Markdown
Contributor

@litereview greptile code-review

@litereview

litereview Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

✅ greptile

Completed · Some checks not run.

Score: 3/5

Fix the duplicate test definitions before merging. I found no production defect; 362 focused tests pass, but test-tree lint fails

Checks and execution details
  • Passed · Provider, decisions, and classifier tests (optional): 229 tests passed across tests/unit/llms/databricks/decisions/test_transformation.py, tests/unit/decisions/test_main.py, and tests/unit/router_strategy/complexity_router/test_jev_classifier.py
  • Passed · Proxy endpoint and permission tests (optional): 133 tests passed across tests/unit/proxy/decisions_endpoints/test_endpoints.py and tests/unit/proxy/management_helpers/test_auto_router_permissions.py after installing locked dev/proxy-dev dependencies and generating the Prisma client
  • Failed · Changed decisions test-file lint (optional): uv run --no-sync ruff check --config ruff-tests.toml tests/unit/decisions/test_main.py failed with six F811 redefinition errors
  • Not run · Live Databricks verification (optional): Reviewed routing and response handling through source inspection and mocked upstream tests; did not call a live Databricks workspace

View review · Reviewed afd6f4512476

@litereview

litereview Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

✅ code-review

Completed · Some checks not run.

Standards

I found one hard problem, which is in the tests. The other findings are judgement calls.

Hard violations

  • tests/unit/decisions/test_main.py: the backport pastes over tests that already exist.
    • Lines 1260–1447 redefine _DEDICATED_DECIDER_PROVIDERS, test_every_dedicated_decider_provider_ships_an_evaluation_mode_cost_map_entry, and five test_databricks_* functions. The same names are already defined at lines 1102–1249.
    • Python keeps whichever definition comes last, so pytest never collects the originals. Those originals test litellm.asystemone(...) with the serving-endpoint model and the "bare endpoint name" message. A side-by-side diff of the two blocks shows that only the entry point, the model, and the message differ.
    • Ruff doesn't catch this because ruff.toml has lint.exclude = [..., "tests/*"], so F811 never runs on these files.
    • This breaks AGENTS.md: tests must fail if the code is changed in a way that breaks the feature, and a bug fix should extend the existing test file instead of piling on. Right now the serving-endpoint coverage through asystemone is gone without any warning. The fix is to merge the two blocks or rename the new tests.

Judgement calls (documented rules)

  • Vendor facts pinned in tests (AGENTS.md: "Never pin facts we don't own... cite its source and date"). _AI_DECIDE_ROUTE/_DATABRICKS_ROUTE hard-code /api/2.0/ai-functions/ai-decide. The test name ..._because_the_route_rejects_unexpected_parameters states Databricks behaviour as fact. Neither cites a source or a date.
  • AGENTS.md: "Don't throw; model failures as values". validate_databricks_decisions_model builds on the existing ValueError path instead of returning a value. The pattern was already there, so this is minor.

Baseline smells (always judgement calls)

  • Duplicated Code / Shotgun Surgery. The rule that ai_decide drops model lives in two places. One is DatabricksDecisionsConfig.transform_decisions_request (if key != "model"). The other is JevClassifier._excluded_fields (_WITHOUT_MODEL if self._provider == "databricks" and is_ai_decide_model(model)). The "copy the dict minus one key" shape ({key: value for ... if key != "..."}) also shows up three times in transformation.py.
  • Repeated Switches. is_ai_decide_model(model) branches in canonical_model, get_complete_url, transform_decisions_request, config.py, jev_classifier.py, and the TS isSupportedClassifierModel.
  • Primitive Obsession. The model str stands for two different things: the "ai_decide" sentinel and a serving-endpoint name. A small tagged union (AiDecide | ServingEndpoint(name)), parsed once, would remove the repeated switch above. AGENTS.md also says "Use tagged unions + match".
  • Mysterious Name. _mapping(value) doesn't say that it validates or returns None. _systemone_answer doesn't say that it renames probability to noul.

Tooling-enforced (skipped)

The removed blank line before _log_response in jev_classifier.py and the one before jevClassifierConfigFields in jev_classifier_config.ts are formatter issues, so I left them out.

Checks and execution details
  • Passed · Read standards sources (AGENTS.md, CONTRIBUTING.md, ruff.toml) (required): Read the coding conventions and testing rules in AGENTS.md and CONTRIBUTING.md. Read ruff.toml to see what tooling already enforces. That is how I found that tests/* is lint-excluded.
  • Passed · Duplicate definitions in test_main.py (optional): Used grep and a diff of lines 1102–1258 against 1260–1446. This confirmed that seven top-level names are defined twice.
  • Not run · Run pytest on touched tests (optional): This was a read-only static standards review, so I didn't run pytest.

View review · Reviewed afd6f4512476

Comment thread tests/unit/decisions/test_main.py Outdated


@pytest.mark.asyncio
async def test_databricks_requires_api_base_before_http(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

High · Backported tests redefine existing test functions, so pytest never collects the originals

The new block redefines names that are already defined at lines 1102–1249: _DEDICATED_DECIDER_PROVIDERS, test_every_dedicated_decider_provider_ships_an_evaluation_mode_cost_map_entry, test_databricks_requires_api_base_before_http, test_databricks_rejects_a_serving_endpoint_name_that_would_rewrite_the_url, test_databricks_requires_a_key_before_http, test_databricks_posts_the_jev_body_to_the_serving_endpoint_invocations_route and test_databricks_router_deployment_sends_its_own_key_to_its_own_base.

Python keeps the last definition, so the earlier versions never run. Those versions cover litellm.asystemone with the serving-endpoint model and the bare endpoint name message.

This breaks AGENTS.md: tests must fail when the feature breaks, and changes should extend the existing mapped test file. Ruff doesn't flag it because tests/* is in lint.exclude, so F811 never runs here.

grep -n 'def test_databricks' tests/unit/decisions/test_main.py lists each name twice (1102/1260, 1123/1281, 1142/1300, 1164/1322, 1202/1402)

diff of the two blocks: the only differences are asystemone vs adecisions, _DATABRICKS_ENDPOINT vs ai_decide, and the error-message text

Review by code-review · Reviewed afd6f4512476

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.

Fixed in 7417436, which removed the duplicate definitions and restored the formatter blank line

verbose_router_logger.warning("JEV response logging failed (%s)", type(exc).__name__)
return TypeAdapter(JevSystemOneResponse).validate_python(normalized_body)

def _excluded_fields(self, model: str) -> Mapping[str, bool] | None:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Low · Rule that ai_decide drops model is duplicated across transformation and JEV classifier

Possible Duplicated Code / Shotgun Surgery (a judgement call). _excluded_fields repeats the model stripping that DatabricksDecisionsConfig.transform_decisions_request already does. If the ai_decide body shape changes, both places have to change together.

return _WITHOUT_MODEL if self._provider == "databricks" and is_ai_decide_model(model) else None

return MappingProxyType({key: value for key, value in body.items() if key != "model"})

Review by code-review · Reviewed afd6f4512476

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.

This backport keeps the code identical to #45722 on main, so a change here would belong there first. It's Low, so I'm tracking it as a follow-up



def is_ai_decide_model(model: str) -> bool:
return model == DATABRICKS_AI_DECIDE_MODEL

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Low · model string stands for both the ai_decide sentinel and an endpoint name

Possible Primitive Obsession / Repeated Switches (a judgement call). Six call sites in Python and TS branch on is_ai_decide_model. AGENTS.md says "Use tagged unions + match". Parsing the string once into AiDecide | ServingEndpoint would put that branching in one place.

def is_ai_decide_model(model: str) -> bool: return model == DATABRICKS_AI_DECIDE_MODEL

Review by code-review · Reviewed afd6f4512476

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.

This backport keeps the code identical to #45722 on main, so a change here would belong there first. It's Low, so I'm tracking it as a follow-up

_BASE: Final = "https://workspace.example/serving-endpoints"
_HOST: Final = "https://workspace.example"
_BASE: Final = f"{_HOST}/serving-endpoints"
_AI_DECIDE_ROUTE: Final = f"{_HOST}/api/2.0/ai-functions/ai-decide"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Low · Tests pin the Databricks ai_decide route and behaviour without citing a source or date

AGENTS.md: "Never pin facts we don't own ... If an outside fact is truly load-bearing, cite its source and date next to the assertion." The vendor path and the claim that the route rejects extra params are hard-coded with no citation.

_AI_DECIDE_ROUTE: Final = f"{_HOST}/api/2.0/ai-functions/ai-decide"

def test_the_ai_decide_request_omits_model_because_the_route_rejects_unexpected_parameters()

Review by code-review · Reviewed afd6f4512476

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.

The route matches what #45722 shipped and verified against a live Databricks workspace. Any citation change goes to main first, then gets backported

Comment thread tests/unit/decisions/test_main.py Outdated


@pytest.mark.asyncio
async def test_databricks_router_deployment_sends_its_own_key_to_its_own_base(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Medium · Keep the existing Databricks tests discoverable

Six duplicate names hide existing tests, including serving-endpoint credential isolation (line 1202), and fail the F811 CI gate. Rename distinct cases or consolidate duplicates

ruff check --config ruff-tests.toml tests/unit/decisions/test_main.py reports six F811 errors at lines 1260, 1281, 1300, 1322, 1402, and 1447

The definition at line 1402 replaces the serving-endpoint test at line 1202 with an ai_decide test before pytest collection

.github/workflows/test-linting.yml:136 runs the test-tree Ruff gate

Review by greptile · Reviewed afd6f4512476

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.

Fixed in 7417436, which removed the duplicate definitions and restored the formatter blank line

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

Stale Bugbot comment from a previous run.

Comment thread tests/unit/decisions/test_main.py Resolved
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@mateo-berri

Copy link
Copy Markdown
Contributor

bugbot run

@mateo-berri

Copy link
Copy Markdown
Contributor

@litereview greptile code-review

@litereview

litereview Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

✅ greptile

Completed · Some checks not run.

Score: 3/5

The Databricks routing and response changes passed 377 focused Python tests. Fix the duplicate test definitions before merging: they remove existing regression coverage and fail the test lint gate

Checks and execution details
  • Passed · Review context (required): Read the PR metadata, complete supplied diff, applicable AGENTS.md files, attached skill, and Greptile knowledge-base index and provider-adapter context
  • Passed · Decisions and classifier tests (optional): 241 tests passed across the Databricks transformation, decisions main, and Jev classifier test files
  • Passed · Proxy regression tests (optional): 136 tests passed across decisions endpoints and auto-router permissions after installing Prisma 0.11.0 and generating its client
  • Passed · Changed production Python lint (optional): Ruff passed for the three changed production Python files
  • Failed · Decisions test lint (optional): The repository's ruff-tests.toml check reports six duplicate test definitions (F811)
  • Not run · Live Databricks verification (optional): Used mocked upstream tests; did not call a live workspace

View review · Reviewed de1fef7c5a3f

@litereview

litereview Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

✅ code-review

Completed · Some checks not run.

I reviewed this PR on two separate axes, Standards and Spec, and I'm reporting them separately on purpose. The PR has no git history, so I used the immutable diff from base 69738f5 to head de1fef7 as the fixed point. The spec is the PR description, which backports #45722.

Standards

Hard violations

  • Duplicated test names silently drop existing tests. tests/unit/decisions/test_main.py now has a second copy of six tests that already exist at lines 1102–1258. Running ruff check --config ruff-tests.toml reports 6 F811 redefinitions. Python keeps only the later definitions, so the existing litellm.asystemone serving-endpoint tests never run.
  • Formatting. The diff deletes the blank line before def _log_response in litellm/router_strategy/complexity_router/jev_classifier.py. Running ruff format --check reports that the file would be reformatted. The Standards sub-agent also says some new lines in test_jev_classifier.py run past 120 characters. I didn't check that myself.

Judgement calls (baseline smells)

  • Possible Duplicated Code / Feature Envy: JevClassifier._excluded_fields repeats the "drop model for ai_decide" rule. DatabricksDecisionsConfig.transform_decisions_request already owns that rule.
  • Possible Mysterious Name: validate_serving_endpoint_name only checks endpoint names, but its error message now describes the wider ai_decide-or-endpoint rule.
  • Possible Repeated Switches: the same ai_decide / provider branch appears in get_complete_url, transform_decisions_request, and _excluded_fields.

Spec

I found no spec findings:

  • databricks/ai_decide posts to /api/2.0/ai-functions/ai-decide without model.
  • The response envelope is unwrapped, and probability is mapped to noul on noul answers.
  • Bare serving endpoint names still go to /serving-endpoints/&lt;name>/invocations.
  • The change is wired through adecisions, /v1/systemone, and the Jev classifier.
  • Config validation and the dashboard default the Databricks classifier to ai_decide.
  • The zero-cost evaluation entry is in both cost maps.

There is no meaningful scope creep. One minor note: the help text still suggests a /serving-endpoints base, though ai_decide also accepts a bare workspace host.


Summary: Standards has 2 hard findings and 3 judgement calls; the worst is the six F811 test redefinitions that silently drop existing asystemone coverage. Spec has 0 findings.

Checks and execution details
  • Passed · Standards sub-agent review (required): Ran in parallel. It checked the diff against AGENTS.md, CONTRIBUTING.md, the ruff configs, and the Fowler smell baseline.
  • Passed · Spec sub-agent review (required): Ran in parallel against the spec in the PR description. It reported no missing requirements, no scope creep, and nothing implemented wrongly.
  • Failed · ruff check (tests config) on test_main.py (optional): 6 F811 redefinitions.
  • Failed · ruff format --check on changed source (optional): jev_classifier.py would be reformatted.
  • Passed · Backend pytest for touched test files (optional): Run by the Spec sub-agent. 241 tests passed across the Databricks transformation, Jev classifier, and decisions main tests. Another 136 passed across the proxy decisions endpoints and auto-router permissions tests, after uv sync --all-extras and installing prisma.
  • Not run · Dashboard Vitest files (optional): npm ci failed in the sandbox, so the Vitest config couldn't load. The UI changes were reviewed by reading the code only.

View review · Reviewed de1fef7c5a3f

Comment thread tests/unit/decisions/test_main.py Outdated


@pytest.mark.asyncio
async def test_databricks_router_deployment_sends_its_own_key_to_its_own_base(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Medium · Give the added regression tests unique names

This definition replaces the serving-endpoint router.asystemone test at line 1202 during import, so pytest runs only the new ai_decide case. Five other test names also repeat. The configured test lint check fails with six F811 errors. Rename the distinct cases and remove identical duplicates to preserve coverage and pass CI

uv run --no-sync ruff check --config ruff-tests.toml tests/unit/decisions/test_main.py --output-format concise reports six F811 errors

The definitions at lines 1202 and 1402 call router.asystemone and router.adecisions, respectively, but share the same test name

Review by greptile · Reviewed de1fef7c5a3f

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.

Fixed in 7417436, which removed the duplicate definitions and restored the formatter blank line

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

Stale Bugbot comment from a previous run.

Comment thread tests/unit/decisions/test_main.py Outdated


@pytest.mark.asyncio
async def test_databricks_requires_api_base_before_http(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Medium · Duplicated test names silently drop six existing Databricks tests

The new hunk adds tests with the same names as tests already at lines 1102–1258:

  • test_databricks_requires_api_base_before_http
  • test_databricks_rejects_a_serving_endpoint_name_that_would_rewrite_the_url
  • test_databricks_requires_a_key_before_http
  • test_databricks_posts_the_jev_body_to_the_serving_endpoint_invocations_route
  • test_databricks_router_deployment_sends_its_own_key_to_its_own_base
  • test_every_dedicated_decider_provider_ships_an_evaluation_mode_cost_map_entry

Python keeps only the later definitions, so the existing litellm.asystemone variants never run. ruff-tests.toml turns on F811 to catch exactly this, so CI lint should fail.

The new tests look like they were meant to replace the old ones, which suggests a merge left both copies in. Either delete the old block or rename the new tests and keep both entry points covered.

uvx ruff check --config ruff-tests.toml tests/unit/decisions/test_main.py -> Found 6 errors. (all F811, e.g. Redefinition of unused test_databricks_requires_api_base_before_http from line 1102)

Review by code-review · Reviewed de1fef7c5a3f

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.

Fixed in 7417436, which removed the duplicate definitions and restored the formatter blank line

case "typesafe" | "bespoke":
return body

def _log_response(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Low · Removed blank line before _log_response breaks ruff format

The diff deletes the blank line between the _normalized_body match block and def _log_response. The repo's formatter check would fail on this file, which is a breach of the documented lint/format standard.

uvx ruff format --check litellm/router_strategy/complexity_router/jev_classifier.py ... -> 1 file would be reformatted

Review by code-review · Reviewed de1fef7c5a3f

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.

Fixed in 7417436, which removed the duplicate definitions and restored the formatter blank line

verbose_router_logger.warning("JEV response logging failed (%s)", type(exc).__name__)
return TypeAdapter(JevSystemOneResponse).validate_python(normalized_body)

def _excluded_fields(self, model: str) -> Mapping[str, bool] | None:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Low · Possible Duplicated Code: classifier repeats the ai_decide model-stripping rule

This is a judgement call, not a hard violation.

_excluded_fields checks self._provider == "databricks" and is_ai_decide_model(model) to drop model from the request. DatabricksDecisionsConfig.transform_decisions_request already encodes the same rule.

The classifier already asks DATABRICKS_DECISIONS_CONFIG for the URL and for response normalization. Asking it for the request body too would keep the rule in one place.

Review by code-review · Reviewed de1fef7c5a3f

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.

This backport keeps the code identical to #45722 on main, so a change here would belong there first. It's Low, so I'm tracking it as a follow-up

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@mateo-berri

Copy link
Copy Markdown
Contributor

bugbot run

@mateo-berri

Copy link
Copy Markdown
Contributor

@litereview greptile code-review

@litereview

litereview Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

✅ greptile

Completed · Some checks not run.

Score: 4/5

I found no actionable defects. The backport covers AI Function routing, request and response normalization, classifier calls, and dashboard defaults while preserving serving-endpoint behavior. Safe to merge based on code review and 387 passing Python tests; I did not verify a live Databricks workspace

Checks and execution details
  • Passed · Repository and knowledge-base context (required): Read applicable AGENTS.md files and the Greptile knowledge-base index and provider-adapter documentation
  • Passed · Decisions and classifier regression tests (optional): 251 tests passed across tests/unit/llms/databricks/decisions/test_transformation.py, tests/unit/decisions/test_main.py, and tests/unit/router_strategy/complexity_router/test_jev_classifier.py using frozen uv dependencies
  • Passed · Proxy dispatch and authorization tests (optional): 136 tests passed across tests/unit/proxy/decisions_endpoints/test_endpoints.py and tests/unit/proxy/management_helpers/test_auto_router_permissions.py after installing the locked extra_proxy dependencies and generating Prisma
  • Passed · Model catalog consistency (optional): Confirmed the databricks/ai_decide entries match in the primary and backup catalogs
  • Not run · Dashboard and live-provider verification (optional): Reviewed dashboard changes and test assertions without running Vitest or a live Databricks request

View review · Reviewed 74174369dd8b

@litereview

litereview Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

✅ code-review

Completed · Some checks not run.

Code review: PR #45921, Databricks ai_decide backport to rc/1.106.0

Fixed point: base 69738f5, head 7417436. The checkout is a source archive with no .git, so I took the diff from the supplied PR metadata (17 files). The spec is the PR description, which backports #45722. I reviewed the two axes in separate parallel sub-agents and report them separately below; they are not merged or reranked.

Standards

Sources checked: AGENTS.md, tests/unit/AGENTS.md, ui/litellm-dashboard/AGENTS.md, CONTRIBUTING.md. I left out anything a lint gate already enforces.

Documented-standard breaches (both soft)

  • String switch instead of a tagged union. AGENTS.md says "Use tagged unions + match". Instead, is_ai_decide_model(model) is an if on a raw str, repeated in four places:

    • validate_databricks_decisions_model
    • get_complete_url
    • transform_decisions_request
    • jev_classifier._excluded_fields

    An AiDecide | ServingEndpoint union, parsed once in canonical_model, would remove these branches.

  • More throwing code. AGENTS.md says "Don't throw; model failures as values". validate_databricks_decisions_model still raise ValueError through validate_serving_endpoint_name, and more callers now use it (config.py, canonical_model). The raise predates this PR, so this is soft.

Baseline smells (judgement calls)

  • Possible Duplicated Code / Shotgun Surgery. The rule "ai_decide has no model in its body" is written twice:
    • the dict comprehension in DatabricksDecisionsConfig.transform_decisions_request
    • _WITHOUT_MODEL / _excluded_fields in jev_classifier.py
  • Possible Feature Envy. jev_classifier._excluded_fields checks Databricks model details that belong on DATABRICKS_DECISIONS_CONFIG. That object already owns get_complete_url and classifier_response.
  • Possible Primitive Obsession. "ai_decide" is a bare string sentinel in both Python and TypeScript.
  • Possible Mysterious Name.
    • _mapping: something like _as_mapping would say what it does.
    • _systemone_answer: it renames probability to noul, which the name doesn't say.
  • Possible Middle Man. validate_databricks_decisions_model is a thin pass-through. Borderline.

Clean

  • Tests assert behaviour: the route, a body without model, unwrapped answers, and the rejection not echoing the name.
  • The two cost-map files match.
  • UI tests follow the dashboard AGENTS.md.

Spec

Verdict: the spec is implemented. All three call paths go through the provider config:

  • litellm.adecisions / proxy, via prepare_call: canonical_model, transform_decisions_request, get_complete_url, then unwrap_response.
  • The JEV classifier: _excluded_fields, _request_url, _normalized_body.
  • The complexity-router config validator.

The ai-decide route gets no model. Noul probability becomes noul. The Databricks API reference the sub-agent fetched shows choice and score answers already match ChoiceAnswer and ScoreAnswer. The cost-map entry is mode: evaluation with zero cost, and the UI defaults to ai_decide.

(a) Missing or partial

  • The OpenAI-format /v1/decisions path with databricks/ai_decide has no test. The proxy test only covers /v1/systemone. The code path is shared, so this is a coverage gap, not a defect.

(b) Scope creep

  • unwrap_response now runs for every Databricks model, not just ai_decide. It does nothing when there is no response envelope, so it is harmless, but it is wider than the spec's "its response envelope is unwrapped".
  • Error messages and UI copy were reworded. Minor, and in keeping with the change.

(c) Implemented, but worth a look

  • "Bare serving endpoint names still go to /serving-endpoints/&lt;name>/invocations": true only if DATABRICKS_API_BASE already ends in /serving-endpoints.
    • ai_decide now accepts a bare workspace host (databricks_workspace_host strips the suffix).
    • Serving endpoints just append /&lt;name>/invocations to the base as given, so the same bare-host base gives https://host/&lt;name>/invocations and a 404.
    • This predates the PR and the docs say to use /serving-endpoints, but the two model kinds now accept different bases.
  • No test covers a score answer coming back from ai_decide.

Summary

  • Standards: 2 soft breaches and 5 smells. The worst is the repeated ai_decide string switch, with the strip-model rule leaking into jev_classifier.
  • Spec: 0 missing requirements and 0 defects, plus 4 minor notes. The worst is that the accepted API base forms differ between ai_decide and serving endpoints.

Verification: the Spec sub-agent ran the targeted Python suites: 251 passed, and 136 passed for the proxy and auto-router suites. The UI vitest suites were not run.

Checks and execution details
  • Passed · Standards sub-agent review (required): Checked the diff against AGENTS.md, tests/unit/AGENTS.md, ui/litellm-dashboard/AGENTS.md, CONTRIBUTING.md and the Fowler smell baseline.
  • Passed · Spec sub-agent review (required): Checked the diff against the PR description, used as the spec (backport of fix(databricks): call the ai_decide AI Function route for decisions and the auto-router #45722).
  • Passed · Targeted Python unit tests (Databricks decisions, decisions main, JEV classifier) (optional): uv run pytest tests/unit/llms/databricks/decisions tests/unit/decisions/test_main.py tests/unit/router_strategy/complexity_router/test_jev_classifier.py -q: 251 passed.
  • Passed · Proxy decisions endpoints and auto-router permission tests (optional): uv run --extra proxy --extra extra_proxy pytest tests/unit/proxy/decisions_endpoints/test_endpoints.py tests/unit/proxy/management_helpers/test_auto_router_permissions.py -q: 136 passed. The first attempt without the proxy extras failed with ModuleNotFoundError: prisma.
  • Not run · UI vitest suites (optional): Not run. The UI changes are small and their behaviour is covered by the tests in the diff.

View review · Reviewed 74174369dd8b

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

_MAPPING_ADAPTER: Final[TypeAdapter[Mapping[str, object]]] = TypeAdapter(Mapping[str, object])


def is_ai_decide_model(model: str) -> bool:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Low · ai_decide string switch repeated across modules instead of a tagged union

AGENTS.md says "Use tagged unions + match". Instead, is_ai_decide_model(model) is an if on a raw str in four places:

  • validate_databricks_decisions_model
  • get_complete_url
  • transform_decisions_request
  • jev_classifier._excluded_fields

Parsing the model once into an AiDecide | ServingEndpoint union in canonical_model would remove these branches. This is a judgement-level breach (Standards axis).

transformation.py:33, 92, 103 and jev_classifier.py:201 all call is_ai_decide_model

Review by code-review · Reviewed 74174369dd8b

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.

This backport keeps the code identical to #45722 on main, so a change here would belong there first. It's Low, so I'm tracking it as a follow-up

return TypeAdapter(JevSystemOneResponse).validate_python(normalized_body)

def _excluded_fields(self, model: str) -> Mapping[str, bool] | None:
return _WITHOUT_MODEL if self._provider == "databricks" and is_ai_decide_model(model) else None

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Low · Possible Duplicated Code / Feature Envy: rule to drop model for ai_decide is written twice

The rule that the ai-decide route takes no model in its body is written in two places:

  • the dict comprehension in DatabricksDecisionsConfig.transform_decisions_request
  • _WITHOUT_MODEL / _excluded_fields in the JEV classifier

The classifier also checks Databricks model details that DATABRICKS_DECISIONS_CONFIG should own; it already owns the URL and the response. A single config method that builds the request body would keep the two in sync. This is a baseline smell and a judgement call (Standards axis).

_WITHOUT_MODEL: Final = MappingProxyType({"model": True})

return MappingProxyType({key: value for key, value in body.items() if key != "model"})

Review by code-review · Reviewed 74174369dd8b

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.

This backport keeps the code identical to #45722 on main, so a change here would belong there first. It's Low, so I'm tracking it as a follow-up


def get_complete_url(self, api_base: str, model: str) -> str:
return f"{api_base.rstrip('/')}/{validate_serving_endpoint_name(model)}/invocations"
if is_ai_decide_model(model):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Low · Accepted API base forms differ between ai_decide and serving endpoints

ai_decide strips a trailing /serving-endpoints, so tests accept a bare workspace host as DATABRICKS_API_BASE. Serving endpoints append /&lt;name>/invocations to the base unchanged. With a bare-host base, databricks/&lt;endpoint> would post to https://host/&lt;name>/invocations and get a 404.

This predates the PR, and the docs say to use /serving-endpoints. It is still an inconsistency for admins who share one base across both model kinds. Accepting both forms for serving endpoints too, using databricks_workspace_host plus /serving-endpoints, would remove it (Spec axis).

get_complete_url: only the ai_decide branch calls databricks_workspace_host

Review by code-review · Reviewed 74174369dd8b

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.

This backport keeps the code identical to #45722 on main, so a change here would belong there first. It's Low, so I'm tracking it as a follow-up

This branch has not been deployed

No deployments
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.

1 participant