Skip to content

Commit b2e1e2d

Browse files
committed
refactor(appkit): restructure supervisor-api adapter per PR #345 review
Address structural feedback from Mario Cadenas' review of PR #345 (sections 1-8). Stacked on top of the §9 defensive fixes commit. API changes (BETA surface only): - Add `DatabricksAdapter.fromSupervisorApi` static factory for discoverability alongside `.fromChatCompletions`. - Shrink `SupervisorApiAdapterOptions` to `{ model, workspaceClient? }`; tools no longer live on the adapter. - Hosted tools (`supervisorTools.*`) now return tagged `HostedSupervisorTool` records and accept named options instead of positional args. - Declare hosted tools on the agent's `tools` map (same place as function tools / sub-agents); the agents plugin and `runAgent` route them to the adapter via the new `AgentInput.extensions[SUPERVISOR_EXTENSION_KEY]`. - Add capability-negotiation fields to `AgentAdapter`: `acceptsExtensions?` + `consumesInputTools?`. The agents plugin and `runAgent` warn at registration when adapter capabilities don't match declared tools. Internals: - Extend `ResolvedToolEntry` / `StandaloneEntry` with a `hosted-supervisor` branch; `classifyTool` matches it before MCP hosted-tool rejection so standalone `runAgent` supports supervisor tools. - Defense-in-depth: both indexers throw if a `hosted-supervisor` entry is ever dispatched as a callable function. - `DatabricksAdapter.fromSupervisorApi` uses a dynamic import to avoid load-time cycles. Docs: - Rewrite supervisor-API section in docs/plugins/agents.md for the new shape. - Add cross-adapter sub-agent composition note (one-directional: chat parents can call supervisor children, not vice-versa, until SA's function-call events are routed back through `context.executeTool`). Playground: - Update dev-playground supervisor agent to the new shape (`DatabricksAdapter.fromSupervisorApi(...)` + tools on `createAgent`). Tests: - Rewrite supervisor-api.test.ts factory + adapter tests for the new shape. - Add `isSupervisorTool` and `DatabricksAdapter.fromSupervisorApi` tests. - New regression tests in `run-agent.test.ts` covering the hosted-supervisor extension-routing path and both capability-mismatch warnings. - New agents-plugin tests covering the same warning paths and the new `hosted-supervisor` tool-index branch. Signed-off-by: Hubert Zub <hubert.zub@databricks.com>
1 parent 6ee2efb commit b2e1e2d

29 files changed

Lines changed: 2104 additions & 298 deletions

apps/dev-playground/server/index.ts

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
import {
1515
agents,
1616
createAgent,
17-
fromSupervisorApi,
17+
DatabricksAdapter,
1818
tool,
1919
} from "@databricks/appkit/beta";
2020
import { WorkspaceClient } from "@databricks/sdk-experimental";
@@ -73,10 +73,12 @@ const helper = createAgent({
7373
},
7474
});
7575

76-
// Supervisor API demo agent. Tools are configured on the adapter (the SA
77-
// endpoint executes them server-side), not on the createAgent definition.
78-
// Uncomment a `supervisorTools.*` entry (and import 'supervisorTools' from
79-
// '@databricks/appkit/beta') to give the model real powers.
76+
// Supervisor API demo agent. The Databricks AI Gateway executes hosted
77+
// tools server-side; declare them via `createAgent({ tools })` like any
78+
// other agent tool — the agents plugin classifies the tagged record and
79+
// routes it to the adapter via AgentInput.extensions. Import
80+
// `supervisorTools` from '@databricks/appkit/beta' and uncomment an
81+
// entry below to give the model real powers.
8082
//
8183
// `createAgent({ model })` accepts an adapter promise, so the factory's
8284
// host/credential resolution is awaited lazily on first dispatch (via
@@ -85,18 +87,18 @@ const helper = createAgent({
8587
const supervisor = createAgent({
8688
instructions:
8789
"You are an assistant powered by the Databricks Supervisor API.",
88-
model: fromSupervisorApi({
90+
model: DatabricksAdapter.fromSupervisorApi({
8991
model: "databricks-claude-sonnet-4-5",
90-
tools: [
91-
// supervisorTools.genieSpace(
92-
// "01ABCDEF12345678",
93-
// "NYC taxi trip records and zones",
94-
// ),
95-
// supervisorTools.ucFunction(
96-
// "main.default.add",
97-
// "Adds two integers and returns the sum.",
98-
// ),
99-
],
92+
}),
93+
tools: () => ({
94+
// nyc: supervisorTools.genieSpace({
95+
// id: "01ABCDEF12345678",
96+
// description: "NYC taxi trip records and zones",
97+
// }),
98+
// add: supervisorTools.ucFunction({
99+
// name: "main.default.add",
100+
// description: "Adds two integers and returns the sum.",
101+
// }),
100102
}),
101103
});
102104

docs/docs/api/appkit/Class.DatabricksAdapter.md

Lines changed: 37 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/docs/api/appkit/Class.SupervisorApiAdapter.md

Lines changed: 141 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/docs/api/appkit/Function.fromSupervisorApi.md

Lines changed: 73 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/docs/api/appkit/Function.isSupervisorTool.md

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/docs/api/appkit/Interface.AgentAdapter.md

Lines changed: 29 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/docs/api/appkit/Interface.AgentInput.md

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)