88from langchain_core .language_models import BaseChatModel
99from langchain_core .tools import BaseTool
1010from langgraph .checkpoint .base import BaseCheckpointSaver
11- from langchain .agents import create_agent
1211from langgraph .store .base import BaseStore
1312from langchain_core .messages import BaseMessage
1413from langgraph .graph .state import CompiledStateGraph
@@ -56,11 +55,7 @@ def memory_to_xml(memory):
5655 items .append (f"<{ key } >{ value } </{ key } >" )
5756 return f"<memory>{ '' .join (items )} </memory>"
5857
59- formatted_memories = (
60- "\n " .join (memory_to_xml (memory ) for memory in memories )
61- if memories
62- else "No memories found."
63- )
58+ formatted_memories = "\n " .join (memory_to_xml (memory ) for memory in memories ) if memories else "No memories found."
6459
6560 return (
6661 "You have the following general memories "
@@ -173,9 +168,7 @@ async def init_tools(
173168 tools_list = tools_list + await mcp_client .get_tools ()
174169 if user_id :
175170 for tool in tools :
176- items = await service_context .tool_service .tool_repo .search (
177- filter = {"name" : tool }
178- )
171+ items = await service_context .tool_service .tool_repo .search (filter = {"name" : tool })
179172 if items :
180173 structured_tool = items [0 ]
181174 tool_metadata = {structured_tool .name : structured_tool .metadata }
@@ -187,21 +180,15 @@ async def init_tools(
187180 return tools_list
188181
189182
190- async def init_subagents (
191- subagents : list [Assistant ], service_context : ServiceContext
192- ) -> list [SubAgent ]:
183+ async def init_subagents (subagents : list [Assistant ], service_context : ServiceContext ) -> list [SubAgent ]:
193184 result = []
194185 for subagent in subagents :
195- system_prompt = subagent .system_prompt or init_system_prompt (
196- DEFAULT_SYSTEM_PROMPT , {}, subagent .instructions
197- )
186+ system_prompt = subagent .system_prompt or init_system_prompt (DEFAULT_SYSTEM_PROMPT , {}, subagent .instructions )
198187 subagent_dict = {
199188 "name" : subagent .slug ,
200189 "description" : subagent .description ,
201190 "system_prompt" : system_prompt ,
202- "tools" : await init_tools (
203- subagent .tools , subagent .a2a , subagent .mcp , service_context
204- ),
191+ "tools" : await init_tools (subagent .tools , subagent .a2a , subagent .mcp , service_context ),
205192 }
206193
207194 if getattr (subagent , "model" , None ) is not None :
@@ -375,9 +362,7 @@ async def construct_agent(
375362 model = model ,
376363 tools = tools ,
377364 subagents = subagents ,
378- system_prompt = init_system_prompt (
379- system_prompt , service_context .config or {}, instructions
380- ),
365+ system_prompt = init_system_prompt (system_prompt , service_context .config or {}, instructions ),
381366 checkpointer = checkpointer ,
382367 store = service_context .store ,
383368 middleware = middleware ,
@@ -449,6 +434,4 @@ def astream(
449434 config : RunnableConfig = None ,
450435 context : dict [str , Any ] = None ,
451436 ) -> AsyncGenerator [BaseMessage , None ]:
452- return self .graph .astream (
453- messages , config = config , stream_mode = stream_mode , context = context
454- )
437+ return self .graph .astream (messages , config = config , stream_mode = stream_mode , context = context )
0 commit comments