LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • Agent
  • Middleware
  • Backends
  • Sandboxes
  • Skills
  • Subagents
  • Configuration
  • 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

OverviewAgentMiddlewareBackendsSandboxesSkillsSubagentsConfigurationTypes
Modal
Daytona
Deno
Node VFS
Sandbox Standard Tests
Vitest
Language
Theme
JavaScriptdeepagentsindexSubAgent
Interfaceā—Since v1.4

SubAgent

Copy
interface SubAgent

Used in Docs

  • Subagents

Properties

View source on GitHub

Example

property
description: string
property
interruptOn: Record<string, boolean | __type>
property
middleware: readonly AgentMiddleware<any, any, any, readonly ClientTool | ServerTool[]>[]
property
model: string | LanguageModelLike
property
name: string
property
skills: string[]
property
systemPrompt: string
property
tools: StructuredTool<ToolInputSchemaBase, any, any, any>[]

Specification for a subagent that can be dynamically created.

When using createDeepAgent, subagents automatically receive a default middleware stack (todoListMiddleware, filesystemMiddleware, summarizationMiddleware, etc.) before any custom middleware specified in this spec.

Required fields:

  • name: Identifier used to select this subagent in the task tool
  • description: Shown to the model for subagent selection
  • systemPrompt: The system prompt for the subagent

Optional fields:

  • model: Override the default model for this subagent
  • tools: Override the default tools for this subagent
  • middleware: Additional middleware appended after defaults
  • interruptOn: Human-in-the-loop configuration for specific tools
  • skills: Skill source paths for SkillsMiddleware (e.g., ["/skills/user/", "/skills/project/"])

The description of the agent

Human-in-the-loop configuration for specific tools. Requires a checkpointer.

Additional middleware to append after default_middleware

The model for the agent. Defaults to defaultModel

Error name for instanceof checks and logging

Skill source paths for SkillsMiddleware.

List of paths to skill directories (e.g., ["/skills/user/", "/skills/project/"]). When specified, the subagent will have its own SkillsMiddleware that loads skills from these paths. This allows subagents to have different skill sets than the main agent.

Note: Custom subagents do NOT inherit skills from the main agent by default. Only the general-purpose subagent inherits the main agent's skills.

Optional custom system prompt override

The tools to use for the agent (tool instances, not names). Defaults to defaultTools

Copy
const researcher: SubAgent = {
  name: "researcher",
  description: "Research assistant for complex topics",
  systemPrompt: "You are a research assistant.",
  tools: [webSearchTool],
  skills: ["/skills/research/"],
};
Copy
const researcher: SubAgent = {
  name: "researcher",
  description: "Research assistant",
  systemPrompt: "You are a researcher.",
  skills: ["/skills/research/", "/skills/web-search/"],
};