LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • Agent
  • Middleware
  • Backends
  • Sandboxes
  • Skills
  • Subagents
  • Types
Modal
Daytona
Deno
Node VFS
Sandbox Standard Tests
  • Vitest
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

OverviewAgentMiddlewareBackendsSandboxesSkillsSubagentsTypes
Modal
Daytona
Deno
Node VFS
Sandbox Standard Tests
Vitest
Language
Theme
JavaScriptdeepagentsnodeSkillToolResolver
Type●Since v1.15

SkillToolResolver

Copy
SkillToolResolver: (
  name: string,
  runtime: Runtime<TContext>
) => readonly ClientTool[] |
View source on GitHub
Promise
<
readonly
ClientTool
[
]
>

Example

Return the skill tools that one metadata.include_tools name stands for.

A resolver lets a skill list tools whose real names are only known at runtime, such as generated MCP tool names, and lets one name stand for a family of tools. It's called with the name and the agent's runtime, on every model call while a read or pin of a skill listing that name stays in context, and again before one of its tools runs. It may return the tools or a promise of them.

  • Return the same tools for the same name within a thread, or the prompt cache breaks: a change moves bytes at a position that has already been sent.
  • Keep it cheap, or cache, since it runs on every model call.
  • One resolver serves every thread, so scope any cache by what the tools depend on, usually something in runtime.context.
  • Names are resolved concurrently, so cache the pending promise, not only its result.
  • Exceptions propagate out of the model call or tool call. To degrade gracefully, catch inside the resolver and return [].

A name that exactly matches a tool already in the request is claimed by that tool and never passed to the resolver.

Copy
// e.g. every tool on a Linear MCP connection, whatever their generated names
const resolveSkillTools: SkillToolResolver<{ workspaceId: string }> = async (
  name,
  runtime,
) => (await toolsForWorkspace(runtime.context.workspaceId))[name] ?? [];

createSkillsMiddleware({ backend, sources: ["/skills/"], tools: resolveSkillTools });