66from deepagents import CompiledSubAgent , SubAgent
77from deepagents import create_deep_agent as _create_deep_agent
88from deepagents .backends import BackendProtocol
9- from deepagents .backends .filesystem import FilesystemBackend
109from deepagents .backends .protocol import BackendFactory
1110from langchain .agents .structured_output import ResponseFormat
1211from langchain_core .language_models import BaseChatModel
1312from langchain_core .messages import HumanMessage
13+ from langchain_core .runnables .config import RunnableConfig
1414from langchain_core .tools import BaseTool
1515from langgraph .graph import END , START
1616from langgraph .graph .state import CompiledStateGraph , StateGraph
2323from .utils import (
2424 MEMORY_INDEX_VIRTUAL_PATH ,
2525 create_state_with_input ,
26+ is_workspace_filesystem_backend ,
2627 resolve_input_attachments ,
2728)
2829
@@ -62,22 +63,24 @@ def create_advanced_agent_graph(
6263 input_schema : type [BaseModel ] | None ,
6364 output_schema : type [BaseModel ],
6465 build_user_message : Callable [[dict [str , Any ]], str ],
66+ subagents : Sequence [SubAgent | CompiledSubAgent ] = (),
6567) -> StateGraph [Any , Any , Any , Any ]:
6668 """Wrap the advanced agent in a parent graph that maps typed I/O to/from messages.
6769
68- With a ``FilesystemBackend`` , attachment-shaped inputs are downloaded into the
69- workspace and given a ``FilePath`` before the user message is built. A
70- ``FilesystemBackend`` also enables workspace memory: deepagents'
70+ With a filesystem workspace backend , attachment-shaped inputs are downloaded
71+ into the workspace and given a ``FilePath`` before the user message is built.
72+ Filesystem workspaces also enable workspace memory: deepagents'
7173 ``MemoryMiddleware`` reads ``/memory/MEMORY.md`` from the backend each turn.
72- Memory stays disabled for non-filesystem backends, which carry no workspace.
74+ Memory stays disabled for backends which carry no workspace.
7375 """
7476 memory_sources = (
75- [MEMORY_INDEX_VIRTUAL_PATH ] if isinstance (backend , FilesystemBackend ) else []
77+ [MEMORY_INDEX_VIRTUAL_PATH ] if is_workspace_filesystem_backend (backend ) else []
7678 )
7779
7880 inner_graph = create_advanced_agent (
7981 model = model ,
8082 tools = tools ,
83+ subagents = subagents ,
8184 system_prompt = system_prompt ,
8285 backend = backend ,
8386 response_format = response_format ,
@@ -90,7 +93,10 @@ def create_advanced_agent_graph(
9093 get_job_attachment_paths (input_schema ) if input_schema is not None else []
9194 )
9295
93- async def transform_input_async (state : BaseModel ) -> dict [str , Any ]:
96+ async def transform_input_async (
97+ state : BaseModel ,
98+ config : RunnableConfig ,
99+ ) -> dict [str , Any ]:
94100 state_data = state .model_dump ()
95101 input_data = {k : v for k , v in state_data .items () if k not in internal_fields }
96102 input_args = (
@@ -100,7 +106,11 @@ async def transform_input_async(state: BaseModel) -> dict[str, Any]:
100106 )
101107 if attachment_paths :
102108 input_args = await resolve_input_attachments (
103- backend , attachment_paths , input_args
109+ backend ,
110+ attachment_paths ,
111+ input_args ,
112+ state = state ,
113+ config = config ,
104114 )
105115 user_text = build_user_message (input_args )
106116 return {"messages" : [HumanMessage (content = user_text , id = "user-input" )]}
@@ -128,6 +138,7 @@ def create_conversational_advanced_agent_graph(
128138 tools : Sequence [BaseTool ],
129139 system_prompt : str ,
130140 backend : BackendProtocol | BackendFactory | None ,
141+ subagents : Sequence [SubAgent | CompiledSubAgent ] = (),
131142) -> StateGraph [Any , Any , Any , Any ]:
132143 """Wrap the advanced agent in a parent graph that speaks the conversational contract.
133144
@@ -141,12 +152,13 @@ def create_conversational_advanced_agent_graph(
141152 from uipath_langchain .runtime .messages import UiPathChatMessagesMapper
142153
143154 memory_sources = (
144- [MEMORY_INDEX_VIRTUAL_PATH ] if isinstance (backend , FilesystemBackend ) else []
155+ [MEMORY_INDEX_VIRTUAL_PATH ] if is_workspace_filesystem_backend (backend ) else []
145156 )
146157
147158 inner_graph = create_advanced_agent (
148159 model = model ,
149160 tools = tools ,
161+ subagents = subagents ,
150162 system_prompt = system_prompt ,
151163 backend = backend ,
152164 memory = memory_sources ,
0 commit comments