Skip to content

fix(databricks): call the ai_decide AI Function route for decisions and the auto-router - #45722

Merged
mateo-berri merged 10 commits into
mainfrom
litellm_databricks_ai_decide_route
Oct 11, 2026
Merged

mateo-berri merged 10 commits into
mainfrom
litellm_databricks_ai_decide_route

Conversation

@devin-ai-integration

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

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

How it solves it:

  • databricks/ai_decide now posts to <workspace>/api/2.0/ai-functions/ai-decide
  • That body is {state, questions} with no model, since Databricks rejects it. options is not forwarded, same as every other Decisions provider today
  • Its {"response": {"answers": ...}, "metadata": ...} envelope is unwrapped, metadata kept
  • Any other bare name still goes to its serving endpoint, exactly as before
  • Admin UI: the Databricks classifier field now starts on ai_decide

User Flow

Before: an admin whose Databricks workspace has the ai_decide preview gets a 404 on every decision, so the auto router never gets a Databricks tier

  1. The admin sets DATABRICKS_API_BASE to the workspace URL and DATABRICKS_API_KEY to a PAT, and adds a databricks/ai_decide model
  2. A developer sends POST http://localhost:4000/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, the same on POST http://localhost:4000/v1/decisions
  4. On http://localhost:4000/ui/?page=models, Add Auto Router with the Databricks classifier starts on an empty serving endpoint name

After: the same request gets its answers from the ai_decide AI Function, and the auto router routes on them

  1. The admin sets the same DATABRICKS_API_BASE and DATABRICKS_API_KEY, and adds the same databricks/ai_decide model
  2. A developer sends the same POST http://localhost:4000/v1/systemone
  3. They get 200 with answers.tier holding the chosen tier and metadata.version, at $0 spend, the same on POST http://localhost:4000/v1/decisions
  4. Add Auto Router with the Databricks classifier starts on ai_decide, and chat through that router is routed by its answer
  5. A databricks/databricks-openjev-qwen35-4b model still answers 200 from its serving endpoint, as it did before

Linear ticket

Resolves LIT-9315

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)

Design decisions

  • Which route a model takes: exactly ai_decide goes to the AI Function, any other bare name to <api_base>/<name>/invocations
    • Alternative: replace the serving endpoint route with ai_decide only. Rejected, since it turned a working serving endpoint 200 into a 400
    • Alternative: match ai_decide without case. Rejected, since AI_DECIDE can be a real serving endpoint name and goes there today
  • A rejected name gets a 400 that states the rule and never echoes the name, so a huge name is not sent back
  • ai_decide URL: the workspace host plus the fixed path, with a trailing /serving-endpoints on DATABRICKS_API_BASE stripped
    • Alternative: refuse such a base. Rejected, since one DATABRICKS_API_BASE then serves chat, serving endpoints, and ai_decide
  • ai_decide request body: model is dropped from the Decisions request (state, questions), since Databricks answers 400 on model
  • ai_decide response: the response envelope is unwrapped and metadata is kept as is
  • noul answers: Databricks's probability comes back as the SystemOne noul field, since SystemOne clients read noul
  • /v1/systemone returns model: null for ai_decide, since Databricks returns none; /v1/decisions fills in the requested model as for every provider
  • Spend: ai_decide is $0 with no x-litellm-classifier-cost header, since Databricks returns no usage for it
  • Cost map: a databricks/ai_decide evaluation row is added beside the existing databricks/databricks-openjev-qwen35-4b row
  • Auto router: the backend still requires the classifier model; only the Admin UI fills in ai_decide as the starting value

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

Screenshots / Proof of Fix

QA is running against the tip; this section is replaced with the before and after run when it finishes

Type

🐛 Bug Fix
✅ Test

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

Medium Risk
Changes URL construction, request shaping, and response parsing for Databricks decisions and auto-router classifiers; serving-endpoint behavior is preserved but misconfiguration could still hit the wrong workspace route.

Overview
Adds first-class support for Databricks ai_decide alongside existing serving-endpoint decision models.

Routing & requests: Model ai_decide posts to POST /api/2.0/ai-functions/ai-decide (workspace host derived from api_base, stripping /serving-endpoints). Other bare names still use …/<endpoint>/invocations. Validation now accepts ai_decide or a bare endpoint name. Outbound bodies for ai_decide omit model (including JEV/complexity-router classifier calls).

Responses: Unwraps the {"response": {"answers": …}, "metadata": …} envelope, keeps metadata, and maps noul answers from Databricks probability to SystemOne noul.

Product surface: Cost map entry for databricks/ai_decide ($0 evaluation). Admin UI defaults the Databricks OSS classifier to ai_decide and updates help text/validation. Tests cover proxy, health checks, wire flows, and auto-router behavior for both ai_decide and serving endpoints.

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

…nd the auto-router

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.
…_decide_route

# Conflicts:
#	tests/integration/providers/test_decisions_wire.py
@devin-ai-integration

devin-ai-integration Bot commented Oct 10, 2026 •

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

@greptile-apps

greptile-apps Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no blocking findings remain.

Summary

This PR sends Databricks ai_decide requests to the AI Function route while keeping serving-endpoint requests on their existing route.

  • Databricks decisions send ai_decide requests to the AI Function.
  • Databricks auto-router classifiers can use ai_decide.

Reviews (5) · Last reviewed commit: "test(databricks): assert the whole class..." · Reviewed by Greptile

greptile-apps[bot]

This comment was marked as resolved.

@codspeed

codspeed Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

⚠️ 1 benchmark spent significant time in system calls

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

Measurement and system calls

✅ 31 untouched benchmarks


Comparing litellm_databricks_ai_decide_route (708938b) with main (2ab80ba)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (5390199) during the generation of this report, so 2ab80ba was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@codecov

codecov Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.95918% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...outer_strategy/complexity_router/jev_classifier.py 80.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

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

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

@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

greptile-apps[bot]

This comment was marked as resolved.

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

…_decide_route

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

# Conflicts:
#	tests/integration/management/test_auto_router_databricks_classifier_writes.py
#	tests/integration/providers/test_decisions_openai_format_wire.py
#	tests/unit/decisions/test_main.py
#	ui/litellm-dashboard/src/components/add_model/JevClassifierConfig.tsx
#	ui/litellm-dashboard/src/components/add_model/jev_classifier_config.ts
@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor

bugbot run

cursor[bot]

This comment was marked as 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 4/5

No actionable defects found. The changes preserve serving-endpoint routing while adding the ai_decide route, request filtering, and response normalization. Safe to merge based on source review and 241 passing focused tests. I did not verify against a live Databricks workspace

Checks and execution details
  • Passed · Review context (required): Read the complete supplied diff, applicable AGENTS.md files, and Greptile knowledge-base index and provider-adapter documentation
  • Passed · Focused Python tests (optional): Installed locked dependencies with uv sync --frozen --no-install-project, then ran uv run --no-sync pytest tests/unit/llms/databricks/decisions/test_transformation.py tests/unit/decisions/test_main.py tests/unit/router_strategy/complexity_router/test_jev_classifier.py -q. Result was 241 passed with 22 warnings
  • Passed · Price-map consistency (optional): Parsed both price-map JSON files and confirmed matching databricks/ai_decide entries
  • Not run · Live provider, integration, and dashboard checks (optional): Review verification covered source inspection and focused Python tests. I did not start the integration stack, dashboard, or a live Databricks session

View review · Reviewed 708938ba5895

@litereview

litereview Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

✅ code-review

Completed · Some checks not run.

Two-axis review: fix(databricks): call the ai_decide AI Function route (#45722)

Fixed point: base 2ab80ba4 against head 708938ba. The checkout has no .git history, so I took the diff from the supplied PR diff.

Spec source: the PR description, which points to Linear LIT-9315. I couldn't fetch the ticket, so the PR text served as the spec.

Standards sources: AGENTS.md, CONTRIBUTING.md and ARCHITECTURE.md, plus the smell baseline.

Standards

No hard violations. The diff adds no new comments, extends existing test files instead of creating new ones, and updates the UI tests alongside the logic change. I found these judgement calls:

  • Untested source for vendor facts. AGENTS.md says: "Never pin facts we don't own … cite its source and date". Several integration and unit tests hard-code _ROUTE = "/api/2.0/ai-functions/ai-decide" and the vendor's {"response": …, "metadata": {"version": "1.0"}} envelope. None of them cites where these come from; only the cost-map row has a source. This is defensible, because the tests can be read as checking LiteLLM's own URL building.
  • Possible Duplicated Code / Feature Envy in jev_classifier.py. _excluded_fields re-implements "drop model for ai_decide", a rule that DatabricksDecisionsConfig.transform_decisions_request already owns. The classifier reaches into Databricks rules instead of asking the config to build the body.
  • Possible Repeated Switches. _request_url and _excluded_fields both branch on self._provider == "databricks".
  • Possible Shotgun Surgery. The ai_decide literal and the full validation-error sentence are repeated across Python, TypeScript and about five test files.
  • Possible Mysterious Name. _systemone_answer renames probability to noul, and the name doesn't say so.
  • Possible Primitive Obsession. api_base is a bare str that may or may not end in /serving-endpoints. databricks_workspace_host and get_complete_url each normalise it in their own way.

Spec

Most of the spec checks out:

  • The host derivation strips a trailing /serving-endpoints.
  • The match on ai_decide is exact-case: AI_DECIDE still goes to its serving endpoint.
  • metadata is kept.
  • /v1/systemone returns model: null; /v1/decisions fills in the requested model.
  • Spend is $0 with no x-litellm-classifier-cost header.
  • The cost-map row is in both JSON files.
  • The backend still requires the classifier model; only the UI starts on ai_decide.

Two issues:

  • (a) Partial requirement: options is never forwarded. The spec says "That body is {state, questions, options}" and "every other field passes as sent". On the proxy/SDK path, systemone_request_to_ir keeps only state and questions. On the auto-router path, JevSystemOneRequest has no options field. A sub-agent's check in the repo .venv confirmed that a request with options reaches Databricks without it. The wire tests assert exactly {state, questions}, so they lock this gap in.
  • (b) Scope creep: unwrapping is not limited to ai_decide. The spec says "Any other bare name still goes to its serving endpoint, exactly as before". But unwrap_response and classifier_response run ai_decide_response on every Databricks payload. Serving-endpoint responses that happen to match the shape would now be reshaped.

Summary

  • Standards: 6 findings, none hard. The worst is the duplicated "drop model for ai_decide" rule in jev_classifier.py.
  • Spec: 2 findings. The worst is that options never reaches Databricks, despite what the description says.

Verification

Low · Tests pin the Databricks route and envelope without a cited source · tests/integration/providers/test_databricks_decisions_wire.py

Standards axis (judgement call). AGENTS.md says: "Never pin facts we don't own … If an outside fact is truly load-bearing, cite its source and date next to the assertion." Several test files hard-code /api/2.0/ai-functions/ai-decide and the vendor's {"response": …, "metadata": {"version": "1.0"}} shape, with no source or date. Only the cost-map row carries a source URL.

Checks and execution details
  • Passed · Standards sub-agent review (required): Ran in parallel against AGENTS.md, CONTRIBUTING.md, ARCHITECTURE.md and the smell baseline. Found no hard violations and six judgement calls.
  • Passed · Spec sub-agent review (required): Ran in parallel against the PR description, used as the spec. Found one partial requirement (options dropped) and one piece of scope creep.
  • Passed · Unit tests covering the change (optional): uv run --frozen pytest tests/unit/llms/databricks/decisions/test_transformation.py tests/unit/router_strategy/complexity_router/test_jev_classifier.py: 144 passed.
  • Not run · Integration and UI tests (optional): Not run; the review stuck to the targeted unit tests.

View review · Reviewed 708938ba5895

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

if is_ai_decide_model(model):
return f"{databricks_workspace_host(api_base)}{_AI_DECIDE_PATH}"
return f"{api_base.rstrip('/')}/{validate_databricks_decisions_model(model)}/invocations"

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 · options is dropped on the ai_decide request, against the spec

Spec axis. The PR says the body is {state, questions, options} and that model is dropped while "every other field passes as sent". In fact transform_decisions_request only strips model from the output of ir_to_systemone_request, which only ever has model, state and questions.

  • Proxy/SDK path: systemone_request_to_ir builds the IR from only state and questions, so a client's options is discarded silently.
  • Auto-router path: JevSystemOneRequest has no options field, so it can never send one.
  • Tests: the wire tests assert exactly {state, questions}, which locks the gap in.

Fix: carry options through to the ai_decide body, or correct the description and document that it isn't supported.

litellm/llms/base_llm/decisions/transformation.py:100-104: systemone_request_to_ir keeps only state and questions

litellm/llms/base_llm/decisions/transformation.py:175-179: ir_to_systemone_request returns only model, state and questions

A sub-agent's check in the repo .venv: a request with options: {"temperature": 0} produced {'state': 's', 'questions': {...}}

Review by code-review · Reviewed 708938ba5895

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.

You're right, the description was wrong. The shared Decisions IR never carries options for any provider, so I fixed the description instead of changing the scope

if isinstance(body, UnsupportedDecisionsRequest) or not is_ai_decide_model(model):
return body
return MappingProxyType({key: value for key, value in body.items() if key != "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 · ai_decide unwrapping also runs on serving-endpoint responses

Spec axis (scope creep). The spec says "Any other bare name still goes to its serving endpoint, exactly as before". But unwrap_response and classifier_response call ai_decide_response on every Databricks payload, with no is_ai_decide_model check.

If a serving endpoint returns a top-level response.answers, or a noul answer with probability, its output is now reshaped. This is unlikely to matter in practice, but it is a behaviour change the spec rules out.

Fix: gate both methods on is_ai_decide_model(model).

Review by code-review · Reviewed 708938ba5895

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.

A serving endpoint returning a top-level response.answers envelope is unlikely, and unwrapping it would still be correct. I'll add a model-gated follow-up after the cutoff

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 / Feature Envy: the classifier re-implements the "drop model" rule

Standards axis (judgement call, baseline smell). _excluded_fields returns _WITHOUT_MODEL if self._provider == "databricks" and is_ai_decide_model(model). That duplicates the rule DatabricksDecisionsConfig.transform_decisions_request already owns. It also adds a second provider == "databricks" branch next to _request_url, a possible Repeated Switches.

If the rule changes, two places need editing. Having the Databricks config build the classifier request body would keep the rule in one place.

Review by code-review · Reviewed 708938ba5895

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.

Agreed, this is a small duplication. I'll move the request shape into the config in a follow-up so the rc backport stays a faithful pick

@mateo-berri

Copy link
Copy Markdown
Contributor

@litereview greptile code-review

@mateo-berri

Copy link
Copy Markdown
Contributor

bugbot run

@litereview

litereview Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

✅ greptile

Review incomplete.

Score 4/5

I found no actionable defects. The focused tests passed. Merge confidence excludes live Databricks verification and the unavailable Greptile context

Couldn’t complete

  • Could not complete the required Greptile knowledge-base consultation because this environment exposes no Greptile tool or resource
  • Greptile knowledge base: No Greptile tool was available. MCP resource and resource-template discovery returned empty lists
Checks and execution details
  • Passed · Diff and repository context review (required): Reviewed the supplied diff, applicable AGENTS.md files, request serialization, response normalization, classifier routing, and dashboard defaults
  • Passed · Python regression tests (optional): 373 tests passed across test_transformation.py, decisions/test_main.py, test_jev_classifier.py, decisions_endpoints/test_endpoints.py, and test_auto_router_permissions.py. Installed locked dependencies with uv and generated the Prisma client
  • Passed · Dashboard regression tests (optional): 296 tests passed across the four changed dashboard test files. Used Node 24.14.1 and npm 11.10.0 after the initial npm ci rejected the installed Node version
  • Passed · Cost-map consistency (optional): Confirmed matching databricks/ai_decide entries in both cost maps with evaluation mode
  • Not run · Greptile knowledge base (required): No Greptile tool was available. MCP resource and resource-template discovery returned empty lists
  • Not run · Live provider and full-stack integration verification (optional): Did not run live Databricks calls or the PostgreSQL/Redis integration harness. The executed tests use mocked upstream responses

View review · Reviewed 708938ba5895

@litereview

litereview Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

✅ code-review

Completed · Some checks not run.

Two-axis review: PR #45722, databricks/ai_decide routing

What I compared against: this checkout is a source archive with no .git history, so I used the diff supplied in review-context.json as the base...head diff. The commit list isn't available.

Spec source: the PR description. Linear LIT-9315 wasn't accessible from here.

I ran the Standards and Spec reviews as separate sub-agents in parallel. Their reports are shown separately below and are not reranked against each other.

Standards

Sources checked: AGENTS.md, CONTRIBUTING.md, ARCHITECTURE.md, tests/AGENTS.md, tests/unit/AGENTS.md, tests/integration/AGENTS.md, ui/litellm-dashboard/AGENTS.md, plus the smell baseline.

Documented-standard breaches

  • Weakened regression test. The judgement leans toward a hard breach, and I confirmed it in the diff. In tests/integration/providers/test_databricks_decisions_wire.py, the megabyte-name test was renamed from ..._stays_fast to ..._stays_up.
    • elapsed &lt; 3 became elapsed &lt; 25 * tenth_elapsed.
    • The liveliness limit &lt; 1 became &lt; max(1.0, elapsed / 2).
    • Ten times more input may now take 25 times longer, so "linear time" is no longer actually checked.
    • The liveliness limit loosens as the slow path gets slower.
    • This conflicts with tests/AGENTS.md: "Red when the claim in the name is broken."
  • Throws instead of returning failures as values (soft). validate_databricks_decisions_model still raises ValueError, against AGENTS.md "Don't throw. Model failures as values". The pattern was already there before this PR.

Smells (judgement calls)

  • Possible Duplicated Code / Feature Envy. The "drop model for ai_decide" rule is written twice:

    • transformation.py transform_decisions_request
    • jev_classifier.py _excluded_fields

    The classifier is reaching into a Databricks rule that belongs on DATABRICKS_DECISIONS_CONFIG, the same way _request_url already hands off to it.

  • Possible Repeated Switches / Primitive Obsession. The plain string "ai_decide" selects between two kinds of upstream, and is_ai_decide_model is checked in four places. AGENTS.md asks for "tagged unions + match".

  • Possible Mysterious Name. _systemone_answer actually renames probability to noul, and its name doesn't say that. _mapping and _WITHOUT_MODEL say little too.

  • Possible Middle Man. is_ai_decide_model only wraps an equality check. This is minor.

Spec

The sub-agent ran uv run pytest tests/unit/llms/databricks/decisions/test_transformation.py tests/unit/router_strategy/complexity_router/test_jev_classifier.py -q, and all 144 tests passed.

  • (a) Partial. "Spend: ai_decide is $0 with no x-litellm-classifier-cost header". Nothing sets this explicitly; it happens because Databricks returns no usage. That is correct today, but if Databricks starts returning usage, ai_decide could begin recording spend.
  • (b) Scope creep / regression risk. "Any other bare name still goes to its serving endpoint, exactly as before". unwrap_response and classifier_response apply ai_decide_response no matter which model was called. A serving-endpoint reply shaped like {"response": {"answers": …}}, or a noul answer carrying probability, now gets rewritten.
  • (c) Questionable. "A rejected name gets a 400 that … never echoes the name". The decisions path is fine: it uses a fixed message and maps to BadRequestError. On the classifier-config path, the error is raised inside a Pydantic validator. Any caller that returns str(ValidationError) will echo input_value. The member write path is safe; the admin path wasn't traced.

Confirmed as specified:

  • The URL and the /serving-endpoints stripping
  • The exact-case ai_decide match
  • Dropping model from the request body
  • /v1/systemone returning model: null, and /v1/decisions filling in the requested model
  • The classifier unwrapping the envelope before validation
  • The cost-map row
  • The UI default to ai_decide
  • The backend still requiring model

Totals:

Checks and execution details
  • Passed · Standards sub-agent review (required): Ran in parallel against the repo's AGENTS.md/CONTRIBUTING.md files and the smell baseline. Report included above.
  • Passed · Spec sub-agent review (required): Ran in parallel against the PR description, used as the spec because LIT-9315 wasn't accessible. Report included above.
  • Passed · Targeted unit tests (optional): The Spec sub-agent ran uv run pytest tests/unit/llms/databricks/decisions/test_transformation.py tests/unit/router_strategy/complexity_router/test_jev_classifier.py -q: 144 passed.
  • Not run · Integration and UI tests (optional): Not run. The integration tests need a gateway harness, and the dashboard tests weren't in scope for this review.

View review · Reviewed 708938ba5895

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

@@ -503,16 +635,15 @@ def poll() -> None:

poller: Final = threading.Thread(target=poll)

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 · Linear-time / liveliness regression test was weakened

Standards axis.

The test was renamed from ..._stays_fast to ..._stays_up.

  • The fixed limit elapsed &lt; 3 became elapsed &lt; 25 * tenth_elapsed. Ten times more input may now take 25 times longer, so the test no longer checks linear time.
  • The liveliness limit &lt; 1 became &lt; max(1.0, elapsed / 2), which loosens as the slow path gets slower.

This conflicts with tests/AGENTS.md: "Red when the claim in the name is broken."

Suggested fix: keep a near-linear ratio (around 12×) and a fixed liveliness limit.

  •    assert elapsed < 3, elapsed
    
  •    assert elapsed < 25 * tenth_elapsed, (elapsed, tenth_elapsed)
    
  •    assert max(seconds for _, seconds in liveliness) < max(1.0, elapsed / 2), (elapsed, liveliness)
    

Review by code-review · Reviewed 708938ba5895

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 wall clock limits fail on slow CI runners. The ratio and liveliness bounds still go red on a stall, which is the claim the renamed test makes

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

def unwrap_response(self, payload: object) -> object:

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 envelope/noul rewrite also runs on serving-endpoint responses

Spec axis.

The spec says: "Any other bare name still goes to its serving endpoint, exactly as before".

unwrap_response and classifier_response call ai_decide_response without checking the model. As a result, a serving endpoint reply shaped like {"response": {"answers": ...}} is flattened, and any noul answer that carries probability is rewritten. The request URL and body are unchanged, but response handling is not.

Suggested fix: gate the rewrite on is_ai_decide_model(model). That requires passing the model into these hooks.

def unwrap_response(self, payload: object) -> object:
fields: Final = _mapping(payload)
return payload if fields is None else ai_decide_response(fields)

return MappingProxyType({**ai_decide_response(body), "model": requested_model})

Review by code-review · Reviewed 708938ba5895

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.

Serving endpoints answer flat payloads, never a response.answers envelope, so the rewrite is a no-op there. Gating it is a Low cleanup for a follow-up

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 for dropping model on ai_decide is duplicated in the JEV classifier

Standards axis (judgement call: possible Duplicated Code / Feature Envy).

The Databricks-specific "drop model for ai_decide" rule appears in two places:

  • DatabricksDecisionsConfig.transform_decisions_request
  • JevClassifierClient._excluded_fields

The URL decision already lives on DATABRICKS_DECISIONS_CONFIG.get_complete_url. The body shaping should live there too, so the two paths can't drift apart.

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

Review by code-review · Reviewed 708938ba5895

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 classifier builds its own wire body on purpose, the config owns the URL. Merging body shaping into the config is a refactor for a follow-up

return f"{databricks_workspace_host(api_base)}{_AI_DECIDE_PATH}"
return f"{api_base.rstrip('/')}/{validate_databricks_decisions_model(model)}/invocations"

def transform_decisions_request(

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 · Zero spend for ai_decide is only implicit

Spec axis (partial).

The spec says: "Spend: ai_decide is $0 with no x-litellm-classifier-cost header".

No code enforces this. It happens because the upstream returns no usage, so provider_reported_cost and jev_classifier_cost stay None. If Databricks starts returning usage, ai_decide could start recording spend and sending the cost header.

Review by code-review · Reviewed 708938ba5895

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.

Spend comes from provider usage everywhere in Decisions, Databricks returns none for ai_decide, so $0 is the designed outcome, not an accident

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

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

LGTM

@mateo-berri
mateo-berri merged commit ca0ff24 into main Oct 11, 2026
88 checks passed
@mateo-berri
mateo-berri deleted the litellm_databricks_ai_decide_route branch October 11, 2026 06:58
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