Skip to content

[appkit plugin] [2/x] Add @databricks/appkit-agent package#384

Open
hubertzub-db wants to merge 3 commits intodatabricks:mainfrom
hubertzub-db:stack/agent-plugin-p2
Open

[appkit plugin] [2/x] Add @databricks/appkit-agent package#384
hubertzub-db wants to merge 3 commits intodatabricks:mainfrom
hubertzub-db:stack/agent-plugin-p2

Conversation

@hubertzub-db
Copy link
Copy Markdown

@hubertzub-db hubertzub-db commented Mar 19, 2026

🥞 Stacked PR


Summary

Extracts the agent plugin from the AppKit monorepo into a standalone, publishable package at integrations/appkit-agent.

This package provides:

  1. AgentInterface — a contract for writing custom agent implementations that speak the OpenAI Responses API format (streaming + non-streaming).
  2. StandardAgent — a ready-to-use LangGraph-based ReAct agent with function tools and Databricks-hosted tool integration (Genie, Vector Search, MCP servers).

Key decisions:

  • @databricks/appkit is a peer dependency — the plugin integrates via AppKit's public Plugin/toPlugin/PluginManifest API
  • LangChain packages (@databricks/langchainjs, @langchain/core, @langchain/langgraph, @langchain/mcp-adapters) are optional peer dependencies — only needed when using StandardAgent, not needed for custom agentInstance implementations
  • Internal createLogger replaced with a local minimal console logger to avoid coupling to AppKit internals
  • Added CI workflow (appkit-agent.yml) and release workflow (release-appkit-agent.yml)

@hubertzub-db hubertzub-db changed the title Agent plugin [appkit] Add @databricks/appkit-agent package Mar 19, 2026
@hubertzub-db hubertzub-db changed the title [appkit] Add @databricks/appkit-agent package [appkit plugin] Add @databricks/appkit-agent package Mar 19, 2026
Copy link
Copy Markdown
Collaborator

@smurching smurching left a comment

Choose a reason for hiding this comment

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

Looks pretty good (mostly just a copy-over of the code from databricks/appkit#166), but should we also include tests here/those seem missing in this PR?

@hubertzub-db hubertzub-db force-pushed the stack/agent-plugin-p2 branch 7 times, most recently from bc6e379 to 3cb6507 Compare March 20, 2026 10:08
@hubertzub-db
Copy link
Copy Markdown
Author

but should we also include tests here/those seem missing in this PR?

@smurching agree, let's bring over tests in this PR. Initially I wanted to bring them over in latter parts but there's no guarantee we'll get there soon - so it sounds good to colocate them here.
I've added appkit test harness, moved unit tests and added one larger integration-ish test.

@hubertzub-db hubertzub-db requested a review from smurching March 20, 2026 13:49
@hubertzub-db hubertzub-db force-pushed the stack/agent-plugin-p2 branch from 3cb6507 to d4f6651 Compare March 20, 2026 13:58
@hubertzub-db hubertzub-db changed the title [appkit plugin] Add @databricks/appkit-agent package [appkit plugin] [2/x] Add @databricks/appkit-agent package Mar 23, 2026
@hubertzub-db hubertzub-db force-pushed the stack/agent-plugin-p2 branch from d4f6651 to 0ef5b7b Compare March 23, 2026 07:56
Copy link
Copy Markdown
Collaborator

@smurching smurching left a comment

Choose a reason for hiding this comment

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

@hubertzub-db some findings from Claude Code review of the latest:

Gaps / Issues

  1. invoke-handler.ts:126 — chatHistory always includes the last message before the final user turn, not "all but last". If the input has
    only one message (a single user turn), chatHistory is [] — that's fine. But if the last message is an assistant turn (e.g. [user,
    assistant]), the assistant message gets passed as history and userMessages.at(-1) is the only user message. There's no test for an input
    that ends with an assistant message — the handler returns 400 in that case actually (no user message check passes), but the chatHistory
    still includes all items. Worth a test.
  2. agent.ts — abortActiveOperations() has no test. The MCP client close path (both success and error) is untested.
  3. agent.ts — exports().invoke uses [...messages].reverse().find(m => m.role === "user") which picks the last user message, but
    chatHistory is messages.slice(0, -1) which slices off the last message (not necessarily the last user message). For example, with [user,
    user, assistant], invoke would pick the second user message correctly, but chatHistory would be [user, user] — the last assistant turn is
    excluded. This looks like a bug, and there's no test for this case.
  4. standard-agent.ts:178 — on_chat_model_stream with non-string content is silently skipped (e.g. array content from tool-use chunks).
    There's no test verifying this doesn't leak unexpected events.
  5. invoke-handler.test.ts — non-streaming agent error path is untested. The outer catch at line 155 (res.status(500)) is never exercised.
  6. hosted-tools.test.ts — resolveHostedTools([]) empty array case is missing, though trivially covered by the "resolves multiple" test
    implicitly.

The most significant issues are #3 (likely bug in exports().invoke history slicing) and #2 (no abortActiveOperations coverage). I'd recommend requesting fixes for those before merging.

I think the conclusions generally make sense, WDYT? Case #3 seems unlikely but could happen e.g. if the agent loop is interrupted, etc, and doesn't hurt to have a test for #2. But otherwise this looks good!

@hubertzub-db
Copy link
Copy Markdown
Author

hubertzub-db commented Mar 24, 2026

@smurching
Thanks for the feedback, addressed following issues in a36b8f8:

  1. this repeats pattern from the original code, however let me reinforce the logic there + add tests
  2. added test
  3. fixed and added test
  4. added test

Move agent plugin source code into src/agent-plugin/ subfolder for
better organization when hosting multiple plugins.
Signed-off-by: Hubert Zub <hubert.zub@databricks.com>
Signed-off-by: Hubert Zub <hubert.zub@databricks.com>
@hubertzub-db hubertzub-db requested a review from bbqiu April 1, 2026 11:44
@hubertzub-db hubertzub-db force-pushed the stack/agent-plugin-p2 branch from 8c02856 to c463ebf Compare April 1, 2026 13:26
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.

2 participants