Repository navigation
fix(databricks): backport the ai_decide AI Function route to rc/1.106.0 (#45722) - #45921
devin-ai-integration[bot] wants to merge 11 commits into
Conversation
…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)
…wall time (cherry picked from commit ca4628f)
…he liveliness bound (cherry picked from commit 99452c2)
(cherry picked from commit cd081a2)
…t routing case (cherry picked from commit 0859b7e)
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
bugbot run |
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…e rc merge Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
bugbot run |
|
@litereview greptile code-review |
✅ greptileCompleted · Some checks not run. Score: 3/5Fix the duplicate test definitions before merging. I found no production defect; 362 focused tests pass, but test-tree lint fails
Checks and execution details
View review · Reviewed |
✅ code-reviewCompleted · Some checks not run. StandardsI found one hard problem, which is in the tests. The other findings are judgement calls. Hard violations
Judgement calls (documented rules)
Baseline smells (always judgement calls)
Tooling-enforced (skipped)The removed blank line before
Checks and execution details
View review · Reviewed |
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_databricks_requires_api_base_before_http( |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
The route matches what #45722 shipped and verified against a live Databricks workspace. Any citation change goes to main first, then gets backported
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_databricks_router_deployment_sends_its_own_key_to_its_own_base( |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Fixed in 7417436, which removed the duplicate definitions and restored the formatter blank line
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
bugbot run |
|
@litereview greptile code-review |
✅ greptileCompleted · Some checks not run. Score: 3/5The 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
View review · Reviewed |
✅ code-reviewCompleted · 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 StandardsHard violations
Judgement calls (baseline smells)
SpecI found no spec findings:
There is no meaningful scope creep. One minor note: the help text still suggests a Summary: Standards has 2 hard findings and 3 judgement calls; the worst is the six
Checks and execution details
View review · Reviewed |
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_databricks_router_deployment_sends_its_own_key_to_its_own_base( |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Fixed in 7417436, which removed the duplicate definitions and restored the formatter blank line
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_databricks_requires_api_base_before_http( |
There was a problem hiding this comment.
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_httptest_databricks_rejects_a_serving_endpoint_name_that_would_rewrite_the_urltest_databricks_requires_a_key_before_httptest_databricks_posts_the_jev_body_to_the_serving_endpoint_invocations_routetest_databricks_router_deployment_sends_its_own_key_to_its_own_basetest_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
There was a problem hiding this comment.
Fixed in 7417436, which removed the duplicate definitions and restored the formatter blank line
| case "typesafe" | "bespoke": | ||
| return body | ||
|
|
||
| def _log_response( |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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>
|
bugbot run |
|
@litereview greptile code-review |
✅ greptileCompleted · Some checks not run. Score: 4/5I 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
View review · Reviewed |
✅ code-reviewCompleted · Some checks not run. Code review: PR #45921, Databricks
|
There was a problem hiding this comment.
✅ 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: |
There was a problem hiding this comment.
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_modelget_complete_urltransform_decisions_requestjev_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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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_fieldsin 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
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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 /<name>/invocations to the base unchanged. With a bare-host base, databricks/<endpoint> would post to https://host/<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
There was a problem hiding this comment.
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
TLDR
This backports #45722's Databricks
ai_decidefix 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 #45722Problem this solves:
databricks/ai_decidegoes to<workspace>/serving-endpoints/ai_decide/invocations, which answers 404/v1/systemone,/v1/decisions, and the Databricks auto router classifier never reach itHow it solves it:
databricks/ai_decidenow posts to/api/2.0/ai-functions/ai-decidewith nomodel, and itsresponseenvelope is unwrapped/serving-endpoints/<name>/invocationsUser Flow
Before: an admin on rc/1.106.0 whose Databricks workspace has
ai_decidegets a 404 on every decisiondatabricks/ai_decidemodel withDATABRICKS_API_BASEandDATABRICKS_API_KEYstate, and atierchoice questionai_decideserving endpoint does not existAfter: the same request gets its answers from
ai_decide, and the auto router can classify through itdatabricks/ai_decidemodeltieranswer from Databricksdatabricks/databricks-openjev-qwen35-4bstill answers from its serving endpointai_decidePre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
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@greptileaito 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_decideso 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, dropsmodelfrom the request body, and normalizes the wrappedresponsepayload (including mappingprobability→noulfor System One answers).Named serving endpoints are unchanged: they still use
/serving-endpoints/<name>/invocationswithmodelin the body. Validation and error copy now allowai_decideor a bare endpoint name.The same routing applies on
adecisions/asystemone, proxy/v1/systemone, and the OSS/Jev Databricks classifier (HTTP client omitsmodelforai_decide).databricks/ai_decideis added to the model cost map (zero spend). Dashboard auto-router defaults the Databricks classifier toai_decidewith 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.