|
| 1 | +# Class: SupervisorApiAdapter |
| 2 | + |
| 3 | +Adapter that calls the Databricks AI Gateway Responses API |
| 4 | +(`/ai-gateway/mlflow/v1/responses`). |
| 5 | + |
| 6 | +Streams SSE events in the OpenAI Responses API wire format and maps them |
| 7 | +to the AppKit `AgentEvent` protocol. Tool execution is handled |
| 8 | +server-side, so the adapter ignores the agents-plugin tool index. |
| 9 | + |
| 10 | +Authentication is handled via the Databricks SDK credential chain — the |
| 11 | +same mechanism used by `DatabricksAdapter.fromModelServing`. The transport |
| 12 | +is injected via [SupervisorApiAdapterCtorOptions.streamBody](Interface.SupervisorApiAdapterCtorOptions.md#streambody); the |
| 13 | +[fromSupervisorApi](Function.fromSupervisorApi.md) factory wires it through the SDK's |
| 14 | +`apiClient.request({ raw: true })`. |
| 15 | + |
| 16 | +Set `DEBUG=appkit:agents:supervisor-api` to log the outbound request |
| 17 | +shape (model, instructions length, input shape, tool count) and to be |
| 18 | +notified when the recovery path engages (no incremental deltas, text |
| 19 | +pulled from `response.completed.output[]`). The no-delta warning includes |
| 20 | +a per-turn event-type histogram and the SA-reported status/error/ |
| 21 | +incomplete_details, so it's already actionable without DEBUG. |
| 22 | + |
| 23 | +Tools are not configured on the adapter. Declare them via |
| 24 | +`createAgent({ tools: () => ({ key: supervisorTools.genieSpace({...}) }) })` |
| 25 | +(or markdown frontmatter referencing an ambient `supervisorTools.*` entry); |
| 26 | +the agents plugin / standalone `runAgent` aggregates hosted-supervisor |
| 27 | +entries and routes them to the adapter via |
| 28 | +`AgentInput.extensions[SUPERVISOR_EXTENSION_KEY]`. Advanced callers |
| 29 | +invoking `adapter.run(...)` directly populate that key themselves. |
| 30 | + |
| 31 | +## Example |
| 32 | + |
| 33 | +```ts |
| 34 | +import { createApp, createAgent } from "@databricks/appkit"; |
| 35 | +import { |
| 36 | + agents, |
| 37 | + DatabricksAdapter, |
| 38 | + supervisorTools, |
| 39 | +} from "@databricks/appkit/beta"; |
| 40 | + |
| 41 | +await createApp({ |
| 42 | + plugins: [ |
| 43 | + agents({ |
| 44 | + agents: { |
| 45 | + assistant: createAgent({ |
| 46 | + instructions: "You are a helpful assistant.", |
| 47 | + model: DatabricksAdapter.fromSupervisorApi({ |
| 48 | + model: "databricks-claude-sonnet-4", |
| 49 | + }), |
| 50 | + tools: () => ({ |
| 51 | + nyc: supervisorTools.genieSpace({ |
| 52 | + id: "01ABCDEF12345678", |
| 53 | + description: "NYC taxi trip records and zones", |
| 54 | + }), |
| 55 | + }), |
| 56 | + }), |
| 57 | + }, |
| 58 | + }), |
| 59 | + ], |
| 60 | +}); |
| 61 | +``` |
| 62 | + |
| 63 | +## Implements |
| 64 | + |
| 65 | +- [`AgentAdapter`](Interface.AgentAdapter.md) |
| 66 | + |
| 67 | +## Constructors |
| 68 | + |
| 69 | +### Constructor |
| 70 | + |
| 71 | +```ts |
| 72 | +new SupervisorApiAdapter(options: SupervisorApiAdapterCtorOptions): SupervisorApiAdapter; |
| 73 | +``` |
| 74 | + |
| 75 | +#### Parameters |
| 76 | + |
| 77 | +| Parameter | Type | |
| 78 | +| ------ | ------ | |
| 79 | +| `options` | [`SupervisorApiAdapterCtorOptions`](Interface.SupervisorApiAdapterCtorOptions.md) | |
| 80 | + |
| 81 | +#### Returns |
| 82 | + |
| 83 | +`SupervisorApiAdapter` |
| 84 | + |
| 85 | +## Properties |
| 86 | + |
| 87 | +### acceptsExtensions |
| 88 | + |
| 89 | +```ts |
| 90 | +readonly acceptsExtensions: readonly ["databricks.supervisor"]; |
| 91 | +``` |
| 92 | + |
| 93 | +Capability negotiation: the adapter reads its hosted-tool payload |
| 94 | +from [AgentInput.extensions](Interface.AgentInput.md#extensions) under [SUPERVISOR\_EXTENSION\_KEY](Variable.SUPERVISOR_EXTENSION_KEY.md). |
| 95 | +The agents plugin uses this list to warn at registration when the tool |
| 96 | +index produces extensions the adapter wouldn't consume. |
| 97 | + |
| 98 | +#### Implementation of |
| 99 | + |
| 100 | +[`AgentAdapter`](Interface.AgentAdapter.md).[`acceptsExtensions`](Interface.AgentAdapter.md#acceptsextensions) |
| 101 | + |
| 102 | +*** |
| 103 | + |
| 104 | +### consumesInputTools |
| 105 | + |
| 106 | +```ts |
| 107 | +readonly consumesInputTools: false = false; |
| 108 | +``` |
| 109 | + |
| 110 | +Capability negotiation: the adapter does not consume `input.tools`. |
| 111 | +Tool execution is owned by the Databricks AI Gateway server-side, so |
| 112 | +any function tools or local sub-agents declared on this agent would |
| 113 | +be silently dropped — the agents plugin warns at registration when |
| 114 | +that combination is detected. |
| 115 | + |
| 116 | +#### Implementation of |
| 117 | + |
| 118 | +[`AgentAdapter`](Interface.AgentAdapter.md).[`consumesInputTools`](Interface.AgentAdapter.md#consumesinputtools) |
| 119 | + |
| 120 | +## Methods |
| 121 | + |
| 122 | +### run() |
| 123 | + |
| 124 | +```ts |
| 125 | +run(input: AgentInput, context: AgentRunContext): AsyncGenerator<AgentEvent, void, unknown>; |
| 126 | +``` |
| 127 | + |
| 128 | +#### Parameters |
| 129 | + |
| 130 | +| Parameter | Type | |
| 131 | +| ------ | ------ | |
| 132 | +| `input` | [`AgentInput`](Interface.AgentInput.md) | |
| 133 | +| `context` | [`AgentRunContext`](Interface.AgentRunContext.md) | |
| 134 | + |
| 135 | +#### Returns |
| 136 | + |
| 137 | +`AsyncGenerator`\<[`AgentEvent`](TypeAlias.AgentEvent.md), `void`, `unknown`\> |
| 138 | + |
| 139 | +#### Implementation of |
| 140 | + |
| 141 | +[`AgentAdapter`](Interface.AgentAdapter.md).[`run`](Interface.AgentAdapter.md#run) |
0 commit comments