Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
aef49d3
Prototype lazy SDK imports and lighter MLflow dependencies
jamesbxwu Nov 12, 2026
6fee149
Record measured limits of lazy import startup experiments
jamesbxwu Nov 14, 2026
e23051b
Merge import experiment into lean worker prototype
jamesbxwu Nov 14, 2026
0b9ffc4
Prototype tracing-only sandbox worker dependencies with matched demo …
jamesbxwu Nov 14, 2026
316f1e1
Record matched live worker startup results and reproducible demo setup
jamesbxwu Nov 14, 2026
9f68408
Compile template dependencies at install and avoid unused MCP startup…
jamesbxwu Nov 14, 2026
2ded21b
Avoid per-module Path allocations when recording imported files
jamesbxwu Nov 14, 2026
86af34e
Record five-second handler benchmark and installation tradeoff
jamesbxwu Nov 14, 2026
156bdec
Benchmark managed web search in fresh sandbox sessions
jamesbxwu Nov 14, 2026
e32e36d
Record matched sandbox web-search benchmarks and live source
jamesbxwu Nov 14, 2026
2967965
Consolidate lean worker demo with managed warm pool
jamesbxwu Nov 14, 2026
c394274
Merge branch 'codex/agentbricks-sandbox-warm-pool' into codex/agentbr…
jamesbxwu Nov 14, 2026
d0b243c
Merge branch 'codex/agentbricks-sandbox-warm-pool' into codex/agentbr…
jamesbxwu Nov 15, 2026
2c59ed9
Merge branch 'codex/agentbricks-sandbox-warm-pool' into codex/agentbr…
jamesbxwu Nov 15, 2026
b2eb88d
Merge branch 'codex/agentbricks-sandbox-warm-pool' into codex/agentbr…
jamesbxwu Nov 16, 2026
3cae3f5
Merge branch 'codex/agentbricks-sandbox-warm-pool' into codex/agentbr…
jamesbxwu Nov 16, 2026
fd7a8ed
Separate worker SDK packaging while retaining standard CLI dependencies
jamesbxwu Nov 16, 2026
265a961
Merge branch 'codex/agentbricks-sandbox-warm-pool' into codex/agentbr…
jamesbxwu Nov 16, 2026
7947cb7
Merge warm pool base into lean worker and preserve upstream error con…
jamesbxwu Nov 16, 2026
606723d
Merge branch 'codex/agentbricks-sandbox-warm-pool' into codex/agentbr…
jamesbxwu Nov 16, 2026
9f79b09
Merge branch 'codex/agentbricks-sandbox-warm-pool' into codex/agentbr…
jamesbxwu Nov 16, 2026
b87f2f0
Remove lean worker investigation write-up from the codebase
jamesbxwu Nov 16, 2026
7a5c06a
Merge branch 'codex/agentkit-mar-alignment-915' into codex/agentkit-m…
jamesbxwu Nov 18, 2026
f1479e7
Merge branch 'codex/agentkit-mar-alignment-915' into codex/agentkit-m…
jamesbxwu Nov 18, 2026
6f3a045
Merge branch 'codex/agentkit-mar-alignment-915' into codex/agentkit-m…
jamesbxwu Nov 18, 2026
a0bd7d8
Wire paired SDK artifacts through release stamping, deployment and su…
jamesbxwu Nov 18, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/scripts/agentbricks_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
r'(?P<suffix>")'
)
PACKAGE_PATH = Path("integrations/agentbricks/pyproject.toml")
RUNTIME_PATH = Path("integrations/agentbricks/src/pyproject.toml")
RUNTIME_DEPENDENCY_PATTERN = re.compile(
r'(?P<prefix>"databricks-agentkit-runtime==)[^"]+(?P<suffix>")'
)
TEMPLATE_BASE_PATH = Path("integrations/agentbricks/src/databricks_agentbricks/templates")
PACKAGE_ROOT = Path("integrations/agentbricks")
TAG_PREFIX = "databricks-agentbricks-v"
Expand Down Expand Up @@ -92,6 +96,15 @@ def stamp_release(root: Path, version: str, *, templates: bool = False) -> None:
parse_version(version, allow_dev=not templates)
package_path = root / PACKAGE_PATH
updates = {package_path: _replace_package_version(package_path.read_text(), version)}
runtime_path = root / RUNTIME_PATH
# The release cutter also runs on release branches predating the package split.
if runtime_path.is_file():
updates[runtime_path] = _replace_package_version(runtime_path.read_text(), version)
updates[package_path], count = RUNTIME_DEPENDENCY_PATTERN.subn(
lambda match: f"{match['prefix']}{version}{match['suffix']}", updates[package_path]
)
if count != 1:
raise ValueError("expected exactly one paired AgentKit runtime dependency")
if templates:
template_paths = sorted((root / TEMPLATE_BASE_PATH).glob("*/pyproject.toml"))
if not template_paths:
Expand Down
22 changes: 18 additions & 4 deletions .github/scripts/run_agentbricks_tests.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
#!/usr/bin/env bash
set -euo pipefail

build_wheels() {
uv build --wheel --out-dir dist ../..
runtime_packages=()
runtime_suite_args=()
# Keep the release runner usable with branches predating the SDK split.
if test -f src/pyproject.toml; then
uv build --wheel --out-dir dist src
runtime_packages=("$PWD"/dist/databricks_agentkit_runtime-*.whl)
runtime_suite_args=(--runtime-wheel "${runtime_packages[0]}")
fi
uv build --wheel --out-dir dist
}

# Run from the Agent Bricks package directory in the checkout being tested.
case "${1:-}" in
unit)
Expand All @@ -20,27 +33,28 @@ case "${1:-}" in
# `agentbricks dev` runs the app through `databricks apps run-local`, so the CLI must be on PATH.
# Any further arguments select the tests to run (default: every suite).
shift
uv build --wheel --out-dir dist ../..
uv build --wheel --out-dir dist
build_wheels
uv venv .venv-suites
uv pip install --python .venv-suites/bin/python --no-sources \
"$(ls dist/databricks_ai_bridge-*.whl)" \
"${runtime_packages[@]}" \
"$(ls dist/databricks_agentbricks-*.whl)" --group tests
# Scaffold projects next to the runner's uv cache: across filesystems uv copies every
# dependency into each project's venv instead of hardlinking, and that fills /tmp on CI.
TMPDIR="${RUNNER_TEMP:-${TMPDIR:-/tmp}}" \
.venv-suites/bin/pytest "${@:-tests/suites}" --workspace fake -n auto --dist loadgroup -v --durations=0 \
--wheel "$(ls "$PWD"/dist/databricks_agentbricks-*.whl)" \
"${runtime_suite_args[@]}" \
--bridge-wheel "$(ls "$PWD"/dist/databricks_ai_bridge-*.whl)"
;;
# Release branches cut before tests/suites ran against a fake workspace still carry
# tests/functional; the release cut runs this script from main against them.
functional)
uv build --wheel --out-dir dist ../..
uv build --wheel --out-dir dist
build_wheels
uv venv .venv-functional
uv pip install --python .venv-functional/bin/python --no-sources \
"$(ls dist/databricks_ai_bridge-*.whl)" \
"${runtime_packages[@]}" \
"$(ls dist/databricks_agentbricks-*.whl)[loadtest]" --group tests
.venv-functional/bin/python -c 'import locust'
AI_BRIDGE_WHEEL="$(ls "$PWD"/dist/databricks_ai_bridge-*.whl)" \
Expand Down
23 changes: 23 additions & 0 deletions .github/scripts/tests/test_agentbricks_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,29 @@ def test_release_stamp_updates_package_and_four_template_minimums(self) -> None:
self.assertIn('version = "0.1.0"', path.read_text())
self.assertIn('"rich>=13.7"', path.read_text())

def test_paired_sdk_and_cli_stamp_release_and_development_together(self) -> None:
runtime = self.root / release.RUNTIME_PATH
runtime.parent.mkdir(parents=True, exist_ok=True)
runtime.write_text('[project]\nname="databricks-agentkit-runtime"\nversion="0.3.0"\n')
self.package.write_text(
self.package.read_text().replace(
"dependencies = [", 'dependencies = ["databricks-agentkit-runtime==0.3.0", '
)
)
for version, templates in (("0.4.0", True), ("0.5.0.dev0", False)):
release.stamp_release(self.root, version, templates=templates)
self.assertIn(f'version="{version}"', runtime.read_text())
self.assertIn(f'"databricks-agentkit-runtime=={version}"', self.package.read_text())

def test_missing_runtime_pair_fails_without_modifying_either_package(self) -> None:
runtime = self.root / release.RUNTIME_PATH
runtime.parent.mkdir(parents=True, exist_ok=True)
runtime.write_text('[project]\nversion="0.3.0"\n')
previous = {path: path.read_bytes() for path in (self.package, runtime)}
with self.assertRaisesRegex(ValueError, "paired AgentKit runtime dependency"):
release.stamp_release(self.root, "0.4.0", templates=True)
self.assertEqual(previous, {path: path.read_bytes() for path in previous})

def test_repeated_stamp_keeps_exact_content(self) -> None:
release.stamp_release(self.root, "0.4.0", templates=True)
expected = {path: path.read_bytes() for path in (self.package, *self.templates)}
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ docs/build

# Local Agent Bricks CLI playground (editable venv, source, and live run records).
/.agentbricks-playground/
# MLflow SQLite files created by local trace tests.
**/mlflow.db
**/mlflow.db-*
5 changes: 4 additions & 1 deletion databricks_mcp/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ dependencies = [
"mcp>=1.13.0",
"databricks-sdk>=0.49.0",
"databricks-ai-bridge>=0.4.2",
"mlflow>=3.1"
"mlflow-tracing>=3.18.0"
]

[project.optional-dependencies]
model-logging = ["mlflow-skinny>=3.18.0"]

[dependency-groups]
dev = [
"typing_extensions==4.15.0",
Expand Down
38 changes: 34 additions & 4 deletions databricks_mcp/src/databricks_mcp/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,35 @@
from databricks_mcp.connector import register_mcp_server_via_dcr
from databricks_mcp.mcp import DatabricksMCPClient
from databricks_mcp.oauth_provider import DatabricksOAuthClientProvider
"""Public exports loaded on first access."""

__all__ = ["DatabricksOAuthClientProvider", "DatabricksMCPClient", "register_mcp_server_via_dcr"]
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from databricks_mcp.connector import register_mcp_server_via_dcr
from databricks_mcp.mcp import DatabricksMCPClient
from databricks_mcp.oauth_provider import DatabricksOAuthClientProvider

__all__ = [
"DatabricksOAuthClientProvider",
"DatabricksMCPClient",
"register_mcp_server_via_dcr",
]

_MODULE_BY_NAME = {
"DatabricksOAuthClientProvider": "databricks_mcp.oauth_provider",
"DatabricksMCPClient": "databricks_mcp.mcp",
"register_mcp_server_via_dcr": "databricks_mcp.connector",
}


def __getattr__(name: str) -> object:
module = _MODULE_BY_NAME.get(name)
if module is None:
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
import importlib

value = getattr(importlib.import_module(module), name)
globals()[name] = value
return value


def __dir__() -> list[str]:
return sorted(set(globals()) | set(__all__))
21 changes: 13 additions & 8 deletions databricks_mcp/src/databricks_mcp/mcp.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from __future__ import annotations

import asyncio
import json
import logging
import re
from contextlib import asynccontextmanager
from functools import wraps
from typing import Any, Callable, List, Optional
from typing import TYPE_CHECKING, Any, Callable, List, Optional
from urllib.parse import urlparse

import requests
Expand All @@ -30,16 +32,12 @@
else:
from mcp.client.session import ClientSession
from mcp.client.streamable_http import streamablehttp_client # ty:ignore[unresolved-import]
from mlflow.models.resources import (
DatabricksFunction,
DatabricksGenieSpace,
DatabricksResource,
DatabricksUCConnection,
DatabricksVectorSearchIndex,
)

from databricks_mcp.oauth_provider import DatabricksOAuthClientProvider

if TYPE_CHECKING:
from mlflow.models.resources import DatabricksResource

logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -327,6 +325,13 @@ def get_databricks_resources(self) -> List[DatabricksResource]:
Note that this method only supports detecting resources for Databricks-managed MCP servers.
For custom MCP servers or other MCP server URLs, this method returns an empty list
"""
from mlflow.models.resources import (
DatabricksFunction,
DatabricksGenieSpace,
DatabricksUCConnection,
DatabricksVectorSearchIndex,
)

try:
mcp_type = self._get_databricks_managed_mcp_url_type()
if mcp_type is None:
Expand Down
58 changes: 58 additions & 0 deletions databricks_mcp/tests/unit_tests/test_imports.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,61 @@
import subprocess
import sys

from databricks_mcp import DatabricksOAuthClientProvider

assert DatabricksOAuthClientProvider


def test_oauth_import_does_not_load_client_or_model_logging():
subprocess.run(
[
sys.executable,
"-c",
"""
import sys
import databricks_mcp as package
assert 'DatabricksOAuthClientProvider' in dir(package)
assert 'databricks_mcp.oauth_provider' not in sys.modules
from databricks_mcp import DatabricksOAuthClientProvider
from databricks_mcp.oauth_provider import DatabricksOAuthClientProvider as implementation
assert DatabricksOAuthClientProvider is implementation is package.DatabricksOAuthClientProvider
assert 'databricks_mcp.mcp' not in sys.modules
assert 'mlflow' not in sys.modules
try:
package.unknown_export
except AttributeError:
pass
else:
raise AssertionError('Unknown exports must raise AttributeError')
""",
],
check=True,
capture_output=True,
text=True,
timeout=30,
)


def test_client_import_does_not_load_model_logging():
subprocess.run(
[
sys.executable,
"-c",
"""
import sys
from databricks_mcp import DatabricksMCPClient
assert 'mlflow' not in sys.modules
""",
],
check=True,
capture_output=True,
text=True,
timeout=30,
)


def test_all_public_exports_resolve():
import databricks_mcp as package

for name in package.__all__:
assert getattr(package, name) is getattr(package, name)
25 changes: 22 additions & 3 deletions integrations/agentbricks/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ re-run:
```sh
git clone https://github.com/databricks/databricks-ai-bridge.git
cd databricks-ai-bridge
pip install -e integrations/agentbricks # editable install of the CLI
pip install -e integrations/agentbricks/src -e integrations/agentbricks # SDK and CLI
agentbricks init /tmp/scratch-agent # scaffolds from your working-tree template
cd /tmp/scratch-agent && agentbricks dev
```
Expand All @@ -65,14 +65,31 @@ rebuild or commit. Switching branches needs no reinstall, **except** when a bran
dependency in `integrations/agentbricks/pyproject.toml`:

```sh
pip install -e integrations/agentbricks # only when dependencies changed
pip install -e integrations/agentbricks/src -e integrations/agentbricks # dependencies changed
```

Editing a template in the repo only affects **future** `agentbricks init` runs. An existing scaffold has
its own copy of the template, so to iterate on a scaffolded project edit that copy (or re-init).

The SDK wheel is built from `src/pyproject.toml` as `databricks-agentkit-runtime`;
the parent project builds the CLI/templates as `databricks-agentbricks`. Both keep
their existing import namespaces. Their versions must be released together. In
this unpublished prototype, install both editable projects explicitly (`uv sync`
from this directory also resolves the SDK through `tool.uv.sources`). A worker
can depend directly on `databricks-agentkit-runtime[langgraph]` or `[openai]`;
ordinary templates retain `databricks-agentbricks[FRAMEWORK]` and management APIs.
Release stamping updates both versions and the CLI's exact SDK dependency.
Publishing both artifacts still requires paired release-workflow wiring; automated
publishing remains disabled. The suite harness builds and vendors both wheels;
when supplying `--wheel`, keep its matching SDK beside it or pass `--runtime-wheel`.
Published CLI installs stage the matching SDK from the configured package index
for sandbox deployment. Editable installs build paired source snapshots instead.

## Testing SDK / runtime changes in a scaffold

For an unpublished paired SDK override, also declare `databricks-agentkit-runtime==0.11.0.dev0`
as a direct project dependency: `uv.sources` overrides apply to direct requirements.

A scaffold uses a normal `databricks-agentbricks` PyPI dependency, so `agentbricks dev` and `agentbricks deploy`
install the **released** SDK - editing the runtime and adapter implementation under `databricks_agentkit` in your
checkout does **not** change what a scaffold runs. To exercise local or unreleased SDK changes, add a
Expand All @@ -84,6 +101,7 @@ ship it in a real deployment.
```toml
[tool.uv.sources]
databricks-agentbricks = { path = "/abs/path/to/databricks-ai-bridge/integrations/agentbricks", editable = true }
databricks-agentkit-runtime = { path = "/abs/path/to/databricks-ai-bridge/integrations/agentbricks/src", editable = true }
```

`agentbricks dev` builds the scaffold's venv from this, so your working-tree SDK edits run live. After
Expand All @@ -95,6 +113,7 @@ changing the pin or the scaffold's dependencies, rebuild once with `agentbricks
```toml
[tool.uv.sources]
databricks-agentbricks = { git = "https://github.com/<you>/databricks-ai-bridge", rev = "<pushed-sha>", subdirectory = "integrations/agentbricks" }
databricks-agentkit-runtime = { git = "https://github.com/<you>/databricks-ai-bridge", rev = "<pushed-sha>", subdirectory = "integrations/agentbricks/src" }
```

Commit and push first - the Apps build clones that commit. A `path` or `file://` pin won't resolve
Expand All @@ -105,7 +124,7 @@ override):

```sh
# local: the source uv resolved into the agent venv
cat /tmp/scratch-agent/.venv/lib/python*/site-packages/databricks_agentkit-*.dist-info/direct_url.json
cat /tmp/scratch-agent/.venv/lib/python*/site-packages/databricks_agentkit_runtime-*.dist-info/direct_url.json
# deployed: watch the build/install logs
agentbricks deployments logs agent-bricks-<name>
```
Expand Down
5 changes: 5 additions & 0 deletions integrations/agentbricks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1638,6 +1638,11 @@ Sandbox invocations use the existing `/api/invocations` request/status contract,
session preparation. Capacity defaults and hidden operator overrides are in the
[deploy reference](cli.md).

The SDK is a separate `databricks-agentkit-runtime` wheel,
built from `src/pyproject.toml`. The CLI keeps its package name and depends on it;
ordinary installs retain the CLI's management dependencies. See the
[local development instructions](CONTRIBUTING.md) for the unpublished paired install.

The deployment workflow tracks phases and readiness internally; these observations are not
logged as separate telemetry fields. Network errors are retried within the existing readiness budget; if the final probe remains unreachable,
the deployed app has unverified readiness rather than a reported application failure. These
Expand Down
4 changes: 4 additions & 0 deletions integrations/agentbricks/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -1688,6 +1688,10 @@ lockfiles are preserved; `--git-revision` requires a lockfile in the selected co
Configure private package indexes in the project's `pyproject.toml` or `uv.toml` so the
sandbox can use the same configuration with `uv sync --locked`.
Progress identifies the agent: `Deploying agent <app-name> to agentbricks runtime`.
Install the CLI with its `sandbox` extra. A published installation stages its exact
matching `databricks-agentkit-runtime[sandbox]` version from `--pip-index-url`, which
must contain that version. An editable installation builds matching SDK/CLI wheels
from its checkout. The agent project's dependencies remain defined by its lockfile.

`--sandbox-idle-timeout SECONDS` defaults to 900 (range 60–86400), and applies to new
sandboxes and existing ones on their next prepare/invoke after redeploy. It does not
Expand Down
Loading
Loading