Skip to content

feat(appkit): add DatabricksAdapter.fromAiGateway for gateway chat completions - #605

Draft
MarioCadenas wants to merge 1 commit into
mainfrom
feat/agents-ai-gateway
Draft

MarioCadenas wants to merge 1 commit into
mainfrom
feat/agents-ai-gateway

Conversation

@MarioCadenas

Copy link
Copy Markdown
Collaborator

What

Adds DatabricksAdapter.fromAiGateway({ model }) so agents can consume models through the Databricks AI Gateway Chat Completions endpoint (/ai-gateway/mlflow/v1/chat/completions), naming the model in the request body (e.g. system.ai.claude-opus-5-5) instead of a per-endpoint URL.

This is the migration path off the legacy databricks-* serving-endpoint names (/serving-endpoints/{name}/invocations) toward the gateway's UC system.ai.* models.

import { agents, DatabricksAdapter } from "@databricks/appkit/beta";

agents({
  agents: {
    assistant: createAgent({
      instructions: "You are a helpful assistant.",
      model: await DatabricksAdapter.fromAiGateway({
        model: "system.ai.claude-opus-5-5",
      }),
    }),
  },
});

How

The gateway speaks the same OpenAI Chat Completions wire format the adapter already used, so the change is deliberately tiny:

  • connectors/serving/client.ts — new streamAiGateway(): hard-codes the gateway path and forces stream: true (mirrors the existing stream() serving helper; keeps the @internal "hard-coded path only" contract of streamPath).
  • agents/databricks.ts — optional model on the adapter options, injected into the request body only when set; new fromAiGateway factory that auto-resolves a WorkspaceClient (like fromModelServing).

Everything else is reused unchanged: the multi-step tool loop, SSE parsing, dot→__ tool-name mapping, thought-signature pass-through, DoS caps, and generation params.

Non-breaking

Purely additive (+186 / -0). model is set only on the gateway path. fromModelServing, fromServingEndpoint, and bare-string model: never set a body model, so their requests are byte-identical to before — a test pins this.

Verification

  • Live against the dogfood gateway: confirmed the path /ai-gateway/mlflow/v1/chat/completions 200s, model-in-body works (system.ai.claude-opus-5-5 → global.anthropic.claude-opus-5-5), and streaming SSE + tool-calling return in the exact choices[0].delta / tool_calls[] shape the adapter parses.
  • Tests: 39/39 pass in databricks.test.ts (2 new — gateway path + model in body; serving path leaves model out).
  • Typecheck: no new errors introduced (pre-existing baseline red in unrelated genie/sql-warehouse/mock-workspace-client files only).

Follow-ups (not in scope)

  • Markdown frontmatter model: still routes to serving endpoints; wiring gateway selection into frontmatter can be a separate change if wanted.

This pull request and its description were written by Isaac.

…mpletions

Route agents through the Databricks AI Gateway Chat Completions
endpoint (/ai-gateway/mlflow/v1/chat/completions), naming the model in
the request body (e.g. system.ai.claude-opus-5-5) instead of in the URL.
Reuses the existing Chat Completions tool loop and SSE parsing unchanged.

Additive and non-breaking: the serving-endpoint path (fromModelServing,
fromServingEndpoint, bare-string model) never sets a body model, so its
request is byte-identical to before.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: MarioCadenas <MarioCadenas@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

📦 Bundle size report

Compared against bundle-size-baseline.json (main).

@databricks/appkit

npm tarball (packed): 1.2 MB (+2.5 KB) — gzipped download (dist + bin; excludes release-only docs/NOTICE).

dist raw gzip
JS (runtime) 1.2 MB (+2.5 KB) 426 KB (+648 B)
Type declarations 446 KB (+2.4 KB) 162 KB (+674 B)
Source maps 2.3 MB (+5.3 KB) 798 KB (+1.2 KB)
Other 11 KB 3.7 KB
Total 4.0 MB (+10 KB) 1.4 MB (+2.5 KB)
Per-entry composition (own code — deps external (as shipped))
Entry Initial (gz) Lazy (gz) Total (gz) node_modules (min) Own code (min)
. 96 KB 2.5 KB 98 KB external 314 KB
./beta 93 KB (+130 B) 457 B 94 KB (+130 B) external 281 KB (+529 B)
./testing 38 KB 30 KB 69 KB external 201 KB
./tsdown 520 B 0 B 520 B external 813 B
./type-generator 23 KB 0 B 23 KB external 65 KB

Chunks:

Entry Chunk Load Size (gz)
. index.js initial 92 KB
. utils.js initial 4.0 KB
. remote-tunnel-manager.js lazy 2.5 KB
./beta beta.js initial 77 KB
./beta stream-manager.js initial 5.8 KB
./beta databricks.js initial 3.2 KB
./beta wide-event-emitter.js initial 3.2 KB
./beta configuration.js initial 2.3 KB
./beta service-context.js initial 1.3 KB
./beta client.js initial 434 B
./beta client-options.js initial 219 B
./beta supervisor-api.js lazy 192 B
./beta databricks.js lazy 142 B
./beta index.js lazy 123 B
./testing manifest.js initial 26 KB
./testing index.js initial 10.0 KB
./testing wide-event-emitter.js initial 2.9 KB
./testing index.js lazy 26 KB
./testing remote-tunnel-manager.js lazy 2.5 KB
./testing utils.js lazy 1.2 KB
./tsdown index.js initial 520 B
./type-generator index.js initial 23 KB

@databricks/appkit-ui

npm tarball (packed): 350 KB (-4 B) — gzipped download (dist + bin; excludes release-only docs/NOTICE).

dist raw gzip
JS (runtime) 395 KB 132 KB
Type declarations 229 KB 84 KB (-1 B)
Source maps 766 KB 253 KB
CSS 16 KB 3.2 KB
Total 1.4 MB 472 KB (-1 B)
Per-entry composition (consumer bundle — deps bundled, peerDeps external)
Entry Initial (gz) Lazy (gz) Total (gz) node_modules (min) Own code (min)
./js 5.3 KB 49 KB 55 KB 208 KB 14 KB
./js/beta 20 B 0 B 20 B 0 B 0 B
./react 432 KB 49 KB 481 KB 1.3 MB 177 KB
./react/beta 1.0 KB 0 B 1.0 KB 0 B 1.9 KB

Chunks:

Entry Chunk Load Size (gz)
./js index.js initial 5.2 KB
./js chunk initial 120 B
./js apache-arrow lazy 49 KB
./js/beta beta.js initial 20 B
./react index.js initial 430 KB
./react tslib initial 2.1 KB
./react apache-arrow lazy 49 KB
./react/beta beta.js initial 1.0 KB

@github-actions

Copy link
Copy Markdown
Contributor

🤖 AppKit PR bot

🔬 Run evals

Start an eval for this PR from the evals-monitor app: Go to Evals Monitor →

📦 Try this PR's app template

Scaffolds a new app from this PR's SDK build. Run it in any folder (requires the GitHub CLI — gh auth login — and the Databricks CLI):

gh run download 36149675675 -R databricks/appkit -n appkit-template-0.78.0-pr.1ed8e38-feat-agents-ai-gateway-605 -D appkit-pr-605 \
  && unzip -o "appkit-pr-605/appkit-template-0.78.0-pr.1ed8e38-feat-agents-ai-gateway-605.zip" -d "appkit-pr-605" \
  && databricks apps init --template "appkit-pr-605"

The template pins @databricks/appkit and @databricks/appkit-ui to tarballs built from this branch, so the scaffolded app runs against this PR's code.

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