Skip to content

Commit ec28d83

Browse files
committed
update comments
1 parent ced399c commit ec28d83

File tree

2 files changed

+46
-16
lines changed

2 files changed

+46
-16
lines changed

src/backend/kernel_agents/agent_factory.py

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -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

src/backend/kernel_agents/human_agent.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,16 @@ def __init__(
8080
async def handle_human_feedback(self, human_feedback: HumanFeedback) -> str:
8181
"""Handle human feedback on a step.
8282
83+
This method processes feedback provided by a human user on a specific step in a plan.
84+
It updates the step with the feedback, marks the step as completed, and notifies the
85+
GroupChatManager by creating an ApprovalRequest in the memory store.
86+
8387
Args:
84-
kernel_arguments: Contains the human_feedback_json string
88+
human_feedback: The HumanFeedback object containing feedback details
89+
including step_id, session_id, and human_feedback text
8590
8691
Returns:
87-
Status message
92+
Status message indicating success or failure of processing the feedback
8893
"""
8994

9095
# Get the step
@@ -154,11 +159,16 @@ async def provide_clarification(
154159
) -> str:
155160
"""Provide clarification on a plan.
156161
162+
This method stores human clarification information for a plan associated with a session.
163+
It retrieves the plan from memory, updates it with the clarification text, and records
164+
the event in telemetry.
165+
157166
Args:
158-
kernel_arguments: Contains session_id and clarification_text
167+
human_clarification: The HumanClarification object containing the session_id
168+
and clarification_text provided by the human user
159169
160170
Returns:
161-
Status message
171+
Status message indicating success or failure of adding the clarification
162172
"""
163173
session_id = human_clarification.session_id
164174
clarification_text = human_clarification.clarification_text

0 commit comments

Comments
 (0)