Middleware for providing subagents to an agent via a task tool.
Base spec for general-purpose subagent (caller adds model, tools, middleware).
Append text to a system message.
A single access rule for filesystem operations.
Specification for an agent.
When using create_deep_agent, subagents automatically receive
a default middleware stack before any custom middleware specified in
this spec.
A pre-compiled agent spec.
The runnable's state schema must include a 'messages' key.
This is required for the subagent to communicate results back to the main agent.
CompiledSubAgent runnables are used as provided. They do not
inherit create_deep_agent(state_schema=...); if the runnable
needs custom state fields, compile it with a compatible state
schema yourself.
When the subagent completes, the parent reads the returned state:
if structured_response is non-None, it is JSON-serialized and used as
the ToolMessage content; otherwise, the last non-empty AIMessage
text is used.
Input schema for the task tool.
Middleware for providing subagents to an agent via a task tool.
This middleware adds a task tool to the agent that can be used
to invoke subagents.
Subagents are useful for handling complex tasks that require multiple steps, or tasks that require a lot of context to resolve.
A chief benefit of subagents is that they can handle multi-step tasks, and then return a clean, concise response to the main agent.
Subagents are also great for different domains of expertise that require a narrower subset of tools and focus.
Protocol for pluggable memory backends (single, unified).
Backends can store files in different locations (state, filesystem, database, etc.) and provide a uniform interface for file operations.
All file data is represented as dicts with the following structure:
{
"content": str, # Text content (utf-8) or base64-encoded binary
"encoding": str, # "utf-8" for text, "base64" for binary data
"created_at": str, # ISO format timestamp
"modified_at": str, # ISO format timestamp
}