Draft
Conversation
Add ResponseStreamEvent types alongside internal AgentEvent. The adapter contract (AgentEvent) stays unchanged; a new AgentEventTranslator converts to Responses API SSE format at the HTTP boundary. Both /api/agent/chat and future /invocations emit the same wire format. - Add Responses API types to shared/agent.ts (self-contained, no openai dep) - Add AgentEventTranslator with stateful sequence_number/output_index tracking - AppKit extension events (appkit.thinking, appkit.metadata) preserved - Update dev-playground and agent-app frontends to parse new SSE format - Fix knip config for optional peer deps used by agent adapters Signed-off-by: MarioCadenas <[email protected]>
…client Add explicit tool types alongside ToolProvider auto-discovery: - FunctionTool: user-defined tools with JSON Schema + execute callback - HostedTool: Genie, VectorSearch, custom/external MCP server configs - AppKitMcpClient: zero-dependency MCP client using raw fetch + JSON-RPC 2.0 - Discriminated ToolEntry union (source: plugin | function | mcp) - collectTools() handles all three sources with conflict resolution - addTools() for post-setup FunctionTool addition (HostedTools at setup only) - MCP client lifecycle managed in setup/shutdown Signed-off-by: MarioCadenas <[email protected]>
Wrap executeTool callback with this.execute() so all tool invocations (ToolProvider plugins, FunctionTool, MCP) get uniform telemetry tracing and 30s timeout via AppKit's interceptor chain. OBO-aware execution via asUser(req) is preserved for ToolProvider tools. Also fix main package exports for FunctionTool and HostedTool types. Signed-off-by: MarioCadenas <[email protected]>
Agent plugin accesses the server plugin from config.plugins (deferred phase)
and calls server.extend() to mount POST /invocations at the app root.
- Accepts Responses API request format ({ input, stream?, model? })
- Extracts user message from input array or string
- Delegates to the same internal chat handler flow
- No Plugin base class changes needed
Signed-off-by: MarioCadenas <[email protected]>
Add Zod schemas for both endpoint request formats: - /api/agent/chat: chatRequestSchema (message, threadId?, agent?) - /invocations: invocationsRequestSchema (input, stream?, model?) - Structured 400 error responses with field-level details - Replace manual type assertions with safe parsing Signed-off-by: MarioCadenas <[email protected]>
Add getAgents() to plugin exports and comprehensive test coverage: - event-translator tests: 13 tests covering all AgentEvent -> ResponseStreamEvent translations, sequence_number monotonicity, output_index tracking - function-tool tests: 11 tests for isFunctionTool guard and functionToolToDefinition conversion (100% coverage) - hosted-tools tests: 14 tests for isHostedTool guard and resolveHostedTools resolution for all 4 tool types (100% coverage) - Total: 38 new tests, all passing (1392 total) Signed-off-by: MarioCadenas <[email protected]>
server.extend() throws when autoStart is true (by design for external callers). The agent plugin now pushes directly into the server's serverExtensions array for internal plugin-to-plugin coordination, fixing the crash when using createAgent() which sets autoStart: true. Signed-off-by: MarioCadenas <[email protected]>
Two issues found via runtime debugging: 1. Plugin.execute() returns undefined on failure (production-safe). The executeTool callback now converts undefined to an error string so the adapter always has content for the tool message. 2. Large tool results (e.g. SHOW TABLES with 14K rows) exceeded the StreamManager 1MB event limit and blew up the model context. Tool results are now truncated at 50K chars with a notice. Also guard against SSE events without a type field in both frontends. Signed-off-by: MarioCadenas <[email protected]>
Signed-off-by: MarioCadenas <[email protected]> # Conflicts: # pnpm-lock.yaml
Replace the GET /api/agent/tools and GET /api/agent/agents HTTP endpoints
with clientConfig(), which embeds the data into the HTML page at startup.
No round-trip needed — frontends read tools and agents synchronously via
getPluginClientConfig("agent") from @databricks/appkit-ui.
Signed-off-by: MarioCadenas <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add a framework-agnostic AI agent plugin to AppKit with auto-tool-discovery from existing plugins, a Databricks Model Serving adapter, three framework adapters (Databricks, Vercel AI, LangChain), and a
createAgent()convenience API.Main changes
Agent plugin core (
packages/appkit/src/plugins/agent/):New deferred-phase plugin that scans all registered plugins for
ToolProviderimplementations, collects their tools withpluginName.toolNamenamespacing, and exposes 7 HTTP routes (chat via SSE, cancel, threads CRUD, tools list, agents list). Manages in-memory threads per userId and supports multiple named agents with a configurable default. The chat handler builds anexecuteToolclosure over the request for user-context-aware tool execution.DatabricksAdapter (
packages/appkit/src/agents/databricks.ts):Adapter that talks directly to Databricks Model Serving
/invocationsendpoints using rawfetch(). Authenticates per-request via anauthenticate()callback (no stale tokens), sanitizes tool names (dots to double-underscores) for the Databricks API, and handles both structuredtool_callsresponses and text-based tool call fallback parsing (Llama JSON format and Python-style). Includes afromServingEndpoint()async factory and acreateDatabricksModel()helper for Vercel AI SDK integration.ToolProvider on existing plugins (
packages/appkit/src/plugins/{analytics,files,genie,lakebase}/):All four existing plugins now implement the
ToolProviderinterface withgetAgentTools()andexecuteAgentTool(). Analytics exposesquery(1 tool), Files generates per-volume tools (6 per volume), Genie generates per-space tools (2 per space), and Lakebase exposesquery(1 tool).createAgent()wrapper (packages/appkit/src/core/create-agent.ts):Higher-level API that wraps
createAppwithserver()andagent()pre-configured. Supports single-agent shorthand (adapter) or multi-agent (agentsrecord), flat server config (port,host), and returns anAgentHandlewithregisterAgent,getTools,getThreads, andpluginsnamespace.Supporting infrastructure
packages/shared/src/agent.ts— Core types:ToolProvider,AgentToolDefinition,AgentAdapter,AgentEvent(7-event SSE protocol),Message,Thread,ThreadStore.packages/appkit/src/agents/vercel-ai.ts— Adapter bridging Vercel AI SDK'sstreamText().fullStreamtoAgentEvent.packages/appkit/src/agents/langchain.ts— Adapter bridging LangChain'sstreamEventsv2 toAgentEvent, with JSON Schema to Zod converter.packages/appkit/src/plugins/agent/thread-store.ts—InMemoryThreadStoreimplementation (Map-based, userId-scoped).apps/agent-app/— Standalone agent app project usingcreateAgent(), with chat UI, markdown rendering, event stream panel, and theme selector.apps/dev-playground/client/src/routes/agent.route.tsx— Agent chat page in dev-playground with inline autocomplete and event stream sidebar.Examples
2 ways of building agents
in app:
Screen.Recording.2026-03-26.at.18.17.40.mov
dedicated agent:
Screen.Recording.2026-03-26.at.18.20.03.mov