feat(appkit): fromPlugin() DX, runAgent plugins arg, shared toolkit-resolver#305
Open
MarioCadenas wants to merge 1 commit intoagent/v2/4-agents-pluginfrom
Open
feat(appkit): fromPlugin() DX, runAgent plugins arg, shared toolkit-resolver#305MarioCadenas wants to merge 1 commit intoagent/v2/4-agents-pluginfrom
MarioCadenas wants to merge 1 commit intoagent/v2/4-agents-pluginfrom
Conversation
This was referenced Apr 21, 2026
3c7c35e to
cb7fe2b
Compare
162e970 to
29e3534
Compare
cb7fe2b to
0afea5e
Compare
29e3534 to
b462716
Compare
0afea5e to
983461c
Compare
539487e to
dac73b5
Compare
a7b0444 to
623792d
Compare
624f2a0 to
0dd07a4
Compare
623792d to
2f752a0
Compare
2f752a0 to
dd583ad
Compare
becc889 to
f290fe5
Compare
11981f7 to
acb9094
Compare
f290fe5 to
a02bacf
Compare
…esolver
DX centerpiece. Introduces the symbol-marker pattern that collapses
plugin tool references in code-defined agents from a three-touch dance
to a single line, and extracts the shared resolver that the agents
plugin, auto-inherit, and standalone runAgent all now go through.
`packages/appkit/src/plugins/agents/from-plugin.ts`. Returns a spread-
friendly `{ [Symbol()]: FromPluginMarker }` record. The symbol key is
freshly generated per call, so multiple spreads of the same plugin
coexist safely. The marker's brand is a globally-interned
`Symbol.for("@databricks/appkit.fromPluginMarker")` — stable across
module boundaries.
`packages/appkit/src/plugins/agents/toolkit-resolver.ts`. Single source
of truth for "turn a ToolProvider into a keyed record of `ToolkitEntry`
markers". Prefers `provider.toolkit(opts)` when available (core plugins
implement it), falls back to walking `getAgentTools()` and synthesizing
namespaced keys (`${pluginName}.${localName}`) for third-party
providers, honoring `only` / `except` / `rename` / `prefix` the same
way.
Used by three call sites, previously all copy-pasted:
1. `AgentsPlugin.buildToolIndex` — fromPlugin marker resolution pass
2. `AgentsPlugin.applyAutoInherit` — markdown auto-inherit path
3. `runAgent` — standalone-mode plugin tool dispatch
Before the existing string-key iteration, `buildToolIndex` now walks
`Object.getOwnPropertySymbols(def.tools)`. For each `FromPluginMarker`,
it looks up the plugin by name in `PluginContext.getToolProviders()`,
calls `resolveToolkitFromProvider`, and merges the resulting entries
into the per-agent index. Missing plugins throw at setup time with a
clear `Available: ...` listing — wiring errors surface on boot, not
mid-request.
`hasExplicitTools` now counts symbol keys too, so a
`tools: { ...fromPlugin(x) }` record correctly disables auto-inherit
on code-defined agents.
- `AgentTools` type: `{ [key: string]: AgentTool } & { [key: symbol]:
FromPluginMarker }`. Preserves string-key autocomplete while
accepting marker spreads under strict TS.
- `AgentDefinition.tools` switched to `AgentTools`.
`packages/appkit/src/core/run-agent.ts`. When an agent def contains
`fromPlugin` markers, the caller passes plugins via
`RunAgentInput.plugins`. A local provider cache constructs each plugin
and dispatches tool calls via `provider.executeAgentTool()`. Runs as
service principal (no OBO — there's no HTTP request). If a def
contains markers but `plugins` is absent, throws with guidance.
`fromPlugin`, `FromPluginMarker`, `isFromPluginMarker`, `AgentTools`
added to the main barrel.
- 14 new tests: marker shape, symbol uniqueness, type guard,
factory-without-pluginName error, fromPlugin marker resolution in
AgentsPlugin, fallback to getAgentTools for providers without
.toolkit(), symbol-only tools disables auto-inherit, runAgent
standalone marker resolution via `plugins` arg, guidance error when
missing.
- Full appkit vitest suite: 1311 tests passing.
- Typecheck clean.
Signed-off-by: MarioCadenas <MarioCadenas@users.noreply.github.com>
acb9094 to
807142c
Compare
a02bacf to
a15aa42
Compare
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.
DX centerpiece. Introduces the symbol-marker pattern that collapses
plugin tool references in code-defined agents from a three-touch dance
to a single line, and extracts the shared resolver that the agents
plugin, auto-inherit, and standalone runAgent all now go through.
fromPlugin(factory, opts?)— the markerpackages/appkit/src/plugins/agents/from-plugin.ts. Returns a spread-friendly
{ [Symbol()]: FromPluginMarker }record. The symbol key isfreshly generated per call, so multiple spreads of the same plugin
coexist safely. The marker's brand is a globally-interned
Symbol.for("@databricks/appkit.fromPluginMarker")— stable acrossmodule boundaries.
resolveToolkitFromProvider(pluginName, provider, opts?)packages/appkit/src/plugins/agents/toolkit-resolver.ts. Single sourceof truth for "turn a ToolProvider into a keyed record of
ToolkitEntrymarkers". Prefers
provider.toolkit(opts)when available (core pluginsimplement it), falls back to walking
getAgentTools()and synthesizingnamespaced keys (
${pluginName}.${localName}) for third-partyproviders, honoring
only/except/rename/prefixthe sameway.
Used by three call sites, previously all copy-pasted:
AgentsPlugin.buildToolIndex— fromPlugin marker resolution passAgentsPlugin.applyAutoInherit— markdown auto-inherit pathrunAgent— standalone-mode plugin tool dispatchAgentsPlugin.buildToolIndex— symbol-key resolution passBefore the existing string-key iteration,
buildToolIndexnow walksObject.getOwnPropertySymbols(def.tools). For eachFromPluginMarker,it looks up the plugin by name in
PluginContext.getToolProviders(),calls
resolveToolkitFromProvider, and merges the resulting entriesinto the per-agent index. Missing plugins throw at setup time with a
clear
Available: ...listing — wiring errors surface on boot, notmid-request.
hasExplicitToolsnow counts symbol keys too, so atools: { ...fromPlugin(x) }record correctly disables auto-inheriton code-defined agents.
Type plumbing
AgentToolstype:{ [key: string]: AgentTool } & { [key: symbol]: FromPluginMarker }. Preserves string-key autocomplete whileaccepting marker spreads under strict TS.
AgentDefinition.toolsswitched toAgentTools.runAgentgainsplugins?: PluginData[]packages/appkit/src/core/run-agent.ts. When an agent def containsfromPluginmarkers, the caller passes plugins viaRunAgentInput.plugins. A local provider cache constructs each pluginand dispatches tool calls via
provider.executeAgentTool(). Runs asservice principal (no OBO — there's no HTTP request). If a def
contains markers but
pluginsis absent, throws with guidance.Exports
fromPlugin,FromPluginMarker,isFromPluginMarker,AgentToolsadded to the main barrel.
Test plan
factory-without-pluginName error, fromPlugin marker resolution in
AgentsPlugin, fallback to getAgentTools for providers without
.toolkit(), symbol-only tools disables auto-inherit, runAgent
standalone marker resolution via
pluginsarg, guidance error whenmissing.
Signed-off-by: MarioCadenas MarioCadenas@users.noreply.github.com
PR Stack
agents()plugin +createAgent(def)+ markdown-driven agents — feat(appkit): agents() plugin, createAgent(def), and markdown-driven agents #304fromPlugin()DX +runAgentplugins arg + toolkit-resolver (this PR)This 6-PR stack is a redesign of the earlier 13-PR stack (#282-#286, #293-#300), reorganized to eliminate mid-stack API churn. Reviewers never see code in this stack that later PRs delete. The old 13 PRs have been closed with references back here.