| Name | Type |
|---|---|
| name | str |
| description | str |
| tools | NotRequired[Sequence[BaseTool | Callable | dict[str, Any]]] |
| model | NotRequired[str | BaseChatModel] |
| middleware | NotRequired[list[AgentMiddleware]] |
| interrupt_on | NotRequired[dict[str, bool | InterruptOnConfig]] |
| skills | NotRequired[list[str]] |
| permissions | NotRequired[list[FilesystemPermission]] |
| response_format | NotRequired[ResponseFormat[Any] | type | dict[str, Any]] |
| system_prompt | NotRequired[str] |
| mode | NotRequired[Literal['isolated', 'fork']] |
Specification for a declarative subagent.
By default the subagent is isolated: it receives only the delegated task
description. Setting mode="fork" makes it continue the parent's
conversation instead.
mode="fork" is experimental and may change in a future release.
When using create_deep_agent, subagents automatically receive
a default middleware stack before any custom middleware specified in
this spec.
name and description are required; all other fields are optional.
See the individual attributes for configuration details.
Additional middleware for custom behavior, logging, or rate limiting.
Under mode="fork", inherits the parent's custom middleware list. Entries
in this list replace inherited entries with the same .name; entries with
other names are added.
Avoid middleware that rewrites the inherited system-prompt prefix in the
fork's model request or changes tool definitions unless you accept reduced
shared prompt-cache reuse and potentially higher model costs. This is
distinct from SubAgent.system_prompt, which a fork delivers with its task
message rather than in the system prompt. A wrap_model_call hook receives
the inherited prompt through request.system_message. For example, this
prepends text before the inherited
prefix in the fork's request, preventing reuse of that prefix:
from langchain_core.messages import SystemMessage
rewritten = SystemMessage(content=[
{"type": "text", "text": "You are a security auditor.\n"},
*request.system_message.content_blocks,
])
return handler(request.override(system_message=rewritten))
To restrict filesystem tools, include a FilesystemMiddleware(tools=...)
instance here to replace the subagent's default filesystem middleware.