@@ -121,19 +121,31 @@ async def create_agent(
121121 ) -> BaseAgent :
122122 """Create an agent of the specified type.
123123
124+ This method creates and initializes an agent instance of the specified type. If an agent
125+ of the same type already exists for the session, it returns the cached instance. The method
126+ handles the complete initialization process including:
127+ 1. Creating a memory store for the agent
128+ 2. Setting up the Semantic Kernel
129+ 3. Loading appropriate tools from JSON configuration files
130+ 4. Creating an Azure AI agent definition using the AI Project client
131+ 5. Initializing the agent with all required parameters
132+ 6. Running any asynchronous initialization if needed
133+ 7. Caching the agent for future use
134+
124135 Args:
125- agent_type: The type of agent to create
126- session_id: The session ID
127- user_id: The user ID
128- temperature: The temperature to use for the agent
129- system_message: Optional system message for the agent
136+ agent_type: The type of agent to create (from AgentType enum)
137+ session_id: The unique identifier for the current session
138+ user_id: The user identifier for the current user
139+ temperature: The temperature parameter for the agent's responses (0.0-1.0)
140+ system_message: Optional custom system message to override default
141+ response_format: Optional response format configuration for structured outputs
130142 **kwargs: Additional parameters to pass to the agent constructor
131143
132144 Returns:
133- An instance of the specified agent type
145+ An initialized instance of the specified agent type
134146
135147 Raises:
136- ValueError: If the agent type is unknown
148+ ValueError: If the agent type is unknown or initialization fails
137149 """
138150 # Check if we already have an agent in the cache
139151 if (
@@ -316,15 +328,23 @@ async def _load_tools_for_agent(
316328 async def create_all_agents (
317329 cls , session_id : str , user_id : str , temperature : float = 0.0
318330 ) -> Dict [AgentType , BaseAgent ]:
319- """Create all agent types for a session.
331+ """Create all agent types for a session in a specific order.
332+
333+ This method creates all agent instances for a session in a multi-phase approach:
334+ 1. First, it creates all basic agent types except for the Planner and GroupChatManager
335+ 2. Then it creates the Planner agent, providing it with references to all other agents
336+ 3. Finally, it creates the GroupChatManager with references to all agents including the Planner
337+
338+ This ordered creation ensures that dependencies between agents are properly established,
339+ particularly for the Planner and GroupChatManager which need to coordinate other agents.
320340
321341 Args:
322- session_id: The session ID
323- user_id: The user ID
324- temperature: The temperature to use for the agents
342+ session_id: The unique identifier for the current session
343+ user_id: The user identifier for the current user
344+ temperature: The temperature parameter for agent responses (0.0-1.0)
325345
326346 Returns:
327- Dictionary mapping agent types to agent instances
347+ Dictionary mapping agent types (from AgentType enum) to initialized agent instances
328348 """
329349
330350 # Create each agent type in two phases
0 commit comments