You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Agent plugin for [Databricks AppKit](https://github.com/databricks/appkit). You can define an agent using one of the following approaches:
3
+
Plugins for [Databricks AppKit](https://github.com/databricks/appkit):
4
4
5
-
1. Declaratively define an agent by specifying `model`, `tools,` and `instructions`
6
-
2. Implement a custom agent loop using **`AgentInterface`** — a contract for writing custom agent implementations that speak the OpenAI Responses API format (streaming + non-streaming).
5
+
-**Agent plugin** — define an AI agent declaratively (model + tools + instructions) or bring a custom `AgentInterface` implementation. Speaks the OpenAI Responses API format with streaming.
6
+
-**Chat plugin** — full-featured chat server with streaming, session management, optional PostgreSQL persistence, feedback via MLflow Traces, and stream resumption.
7
7
8
8
## Installation
9
9
@@ -23,26 +23,52 @@ If you use hosted tools (Genie, Vector Search, custom/external MCP servers):
23
23
npm install @langchain/mcp-adapters
24
24
```
25
25
26
+
For chat persistence (optional — without it the chat plugin runs in ephemeral mode):
27
+
28
+
```bash
29
+
npm install pg
30
+
```
31
+
26
32
## Quick Start
27
33
34
+
### Agent only
35
+
28
36
```typescript
29
37
import { createApp, server } from"@databricks/appkit";
30
38
import { agent } from"@databricks/appkit-agent";
31
39
32
40
const app =awaitcreateApp({
33
41
plugins: [
34
-
server(),
42
+
server({ autoStart: true }),
35
43
agent({
36
44
model: "databricks-claude-sonnet-4-5",
37
45
systemPrompt: "You are a helpful assistant.",
38
46
}),
39
47
],
40
48
});
49
+
```
41
50
42
-
app.server.start();
51
+
### Agent + Chat
52
+
53
+
```typescript
54
+
import { createApp, server } from"@databricks/appkit";
The plugin registers `POST /api/agent`which accepts the [OpenAI Responses API](https://platform.openai.com/docs/api-reference/responses) request format with SSE streaming.
71
+
The agent plugin registers `POST /api/agent`(OpenAI Responses API format with SSE streaming). The chat plugin registers routes under `/api/chat/` for streaming chat, history, feedback, and more.
46
72
47
73
## Environment Variables
48
74
@@ -216,23 +242,105 @@ agent({ agentInstance: new MyAgent() });
216
242
217
243
The `StandardAgent` class (exported from this package) is the built-in implementation used when you pass `model` instead of `agentInstance`. It translates the underlying agent's stream events into Responses API format.
218
244
245
+
## Chat Plugin
246
+
247
+
The chat plugin provides a streaming chat server that can be wired to the agent plugin or to a remote Databricks serving endpoint.
When `autoMigrate: true` is set, the plugin creates the `ai_chatbot` schema and tables (`Chat`, `Message`, `Vote`) on startup using [Drizzle migrations](https://orm.drizzle.team/docs/migrations). Migration SQL is generated from the Drizzle schema definition, so it stays in sync automatically.
291
+
292
+
### Session Resolution
293
+
294
+
In production on Databricks Apps, sessions are resolved from headers set by the platform proxy (`x-forwarded-user`, `x-forwarded-email`). In local development, the plugin falls back to the SCIM `/Me` API (if Databricks auth is configured) or `process.env.USER`.
295
+
296
+
You can override this entirely with a custom `getSession` callback.
297
+
298
+
### Feedback
299
+
300
+
When feedback is enabled, thumbs up/down votes are submitted as assessments to the [MLflow Traces API](https://docs.databricks.com/en/mlflow/llm-tracing.html). Votes are also persisted in the database when a pool is configured.
ALTERTABLE"ai_chatbot"."Message" ADD CONSTRAINT"Message_chatId_Chat_id_fk"FOREIGN KEY ("chatId") REFERENCES"ai_chatbot"."Chat"("id") ON DELETE no action ONUPDATE no action;--> statement-breakpoint
30
+
ALTERTABLE"ai_chatbot"."Vote" ADD CONSTRAINT"Vote_chatId_Chat_id_fk"FOREIGN KEY ("chatId") REFERENCES"ai_chatbot"."Chat"("id") ON DELETE no action ONUPDATE no action;--> statement-breakpoint
31
+
ALTERTABLE"ai_chatbot"."Vote" ADD CONSTRAINT"Vote_messageId_Message_id_fk"FOREIGN KEY ("messageId") REFERENCES"ai_chatbot"."Message"("id") ON DELETE no action ONUPDATE no action;
0 commit comments