Skip to content

feat(appkit): shared agent types and LLM adapter implementations#301

Open
MarioCadenas wants to merge 1 commit intomainfrom
agent/v2/1-types-adapters
Open

feat(appkit): shared agent types and LLM adapter implementations#301
MarioCadenas wants to merge 1 commit intomainfrom
agent/v2/1-types-adapters

Conversation

@MarioCadenas
Copy link
Copy Markdown
Collaborator

@MarioCadenas MarioCadenas commented Apr 21, 2026

Foundation layer for the agents feature. Adds the portable type surface
that every downstream layer builds on, plus three LLM adapter
implementations so the agents plugin (later PR) can target whatever the
user has.

Shared agent types

packages/shared/src/agent.ts — no behavior, just the type vocabulary:
AgentAdapter, AgentEvent, AgentInput, AgentRunContext,
AgentToolDefinition, Message, Thread, ThreadStore, ToolAnnotations,
ToolCall, ToolProvider, ResponseStreamEvent. Exported from the
shared barrel.

Adapters

  • packages/appkit/src/agents/databricks.tsDatabricksAdapter:
    streams OpenAI-compatible completions against a Databricks Model
    Serving endpoint. The fromServingEndpoint / fromModelServing
    factories route through the shared connectors/serving/stream
    helper, which delegates to the SDK's apiClient.request({ raw: true }).
    That gives the adapter centralised URL encoding + authentication
    with the rest of the serving surface — no bespoke fetch() +
    authenticate() plumbing. The raw new DatabricksAdapter({ endpointUrl, authenticate }) constructor is preserved as an escape hatch for
    tests and for pointing the adapter at non-workspace endpoints.
  • packages/appkit/src/agents/vercel-ai.tsVercelAIAdapter:
    wraps any Vercel AI SDK streamText call. Maps Vercel SDK events to
    AppKit AgentEvents and tool calls.
  • packages/appkit/src/agents/langchain.tsLangChainAdapter:
    wraps any LangChain Runnable (AgentExecutor, compiled LangGraph,
    etc.). Subscribes to streamEvents(v2) and maps to AgentEvents.

Each adapter is self-contained and independently testable.

Package plumbing

  • Subpath exports @databricks/appkit/agents/{databricks,vercel-ai,langchain}
    so consumers pick only the adapter they want.
  • @langchain/core and ai declared as optional peer dependencies.
  • @ai-sdk/openai, @langchain/core, ai added as devDeps for tests.
  • tsdown.config.ts emits the three adapter entry points alongside the
    main bundle.

Test plan

  • 17 adapter tests (Databricks) covering raw-fetch escape hatch,
    serving-connector routing, URL encoding of endpoint names with
    special characters, streaming + tool-call dispatch. Plus Vercel AI
    and LangChain adapter coverage.
  • Full appkit vitest suite: 1552 tests passing at stack tip.

PR Stack

  1. Shared agent types + LLM adapters (this PR)
  2. Tool primitives + ToolProvider surfaces — feat(appkit): tool primitives and ToolProvider surfaces on core plugins #302
  3. Plugin infrastructure (attachContext + PluginContext) — feat(appkit): plugin infrastructure — attachContext + PluginContext mediator #303
  4. agents() plugin + createAgent(def) + markdown-driven agents — feat(appkit): agents() plugin, createAgent(def), and markdown-driven agents #304
  5. fromPlugin() DX + runAgent plugins arg + toolkit-resolver — feat(appkit): fromPlugin() DX, runAgent plugins arg, shared toolkit-resolver #305
  6. Reference app + dev-playground + docs — feat(appkit): reference agent-app, dev-playground chat UI, docs, and template #306

Demo

agent-demo.mp4

This was referenced Apr 21, 2026
@MarioCadenas MarioCadenas force-pushed the agent/v2/1-types-adapters branch from bb4efff to 5d060a6 Compare April 21, 2026 20:41
@MarioCadenas MarioCadenas force-pushed the agent/v2/1-types-adapters branch 3 times, most recently from 021cf0a to a4d0130 Compare April 22, 2026 16:19
@MarioCadenas MarioCadenas requested review from atilafassina, calvarjorge, ditadi and pkosiec and removed request for calvarjorge April 27, 2026 18:54
* importing the concrete `WorkspaceClient` type to keep the adapter free of a
* compile-time dependency on the SDK.
*/
interface WorkspaceClientLike {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any purpose to this interface? It's not being used for anything that I see, could we just use undefined when this is used, or sth like type WorkspaceClientLike = undefined;

Comment thread packages/appkit/src/agents/langchain.ts Outdated
Comment thread packages/appkit/src/agents/databricks.ts Outdated
Comment thread packages/appkit/src/agents/langchain.ts Outdated
@MarioCadenas MarioCadenas force-pushed the agent/v2/1-types-adapters branch 3 times, most recently from 8e82a62 to 492ffd6 Compare April 29, 2026 18:19
Foundation layer for the agents feature. Adds the portable type surface
that every downstream layer builds on, plus the Databricks Model Serving
adapter so the agents plugin (later PR) can target workspace-hosted
models.

### Shared agent types

`packages/shared/src/agent.ts` — no behavior, just the type vocabulary:
`AgentAdapter`, `AgentEvent`, `AgentInput`, `AgentRunContext`,
`AgentToolDefinition`, `Message`, `Thread`, `ThreadStore`,
`ToolAnnotations`, `ToolCall`, `ToolProvider`, `ResponseStreamEvent`.
Exported from the shared barrel.

### Adapter

`packages/appkit/src/agents/databricks.ts` — `DatabricksAdapter`:
streams OpenAI-compatible completions against a Databricks Model
Serving endpoint (raw fetch + SSE, no vendor SDKs). Also ships
`createDatabricksModel`, a Vercel-AI-SDK helper that returns a model
object you can pass to `streamText`/`useChat`/etc. — handles URL
rewriting (`/chat/completions` -> `/invocations`), per-request auth
refresh, and tool-name sanitization.

`@ai-sdk/openai` is a devDependency consumed by `createDatabricksModel`
via dynamic `import()`; consumers who use that helper install it
alongside `@databricks/appkit`.
@MarioCadenas MarioCadenas force-pushed the agent/v2/1-types-adapters branch from 492ffd6 to db67f51 Compare April 29, 2026 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants