Skip to content

Commit ab4ecf7

Browse files
committed
Update human_agent.py
1 parent 099f18c commit ab4ecf7

File tree

1 file changed

+64
-35
lines changed

1 file changed

+64
-35
lines changed

src/backend/kernel_agents/human_agent.py

Lines changed: 64 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -168,43 +168,72 @@ async def handle_human_feedback(self, human_feedback: HumanFeedback) -> str:
168168

169169
return "Human feedback processed successfully"
170170

171-
async def provide_clarification(
172-
self, human_clarification: HumanClarification
173-
) -> str:
174-
"""Provide clarification on a plan.
175171

176-
This method stores human clarification information for a plan associated with a session.
177-
It retrieves the plan from memory, updates it with the clarification text, and records
178-
the event in telemetry.
172+
async def handle_human_clarification(
173+
self, human_clarification: HumanClarification
174+
) -> str:
175+
"""Provide clarification on a plan.
179176
180-
Args:
181-
human_clarification: The HumanClarification object containing the session_id
182-
and clarification_text provided by the human user
183-
184-
Returns:
185-
Status message indicating success or failure of adding the clarification
186-
"""
187-
session_id = human_clarification.session_id
188-
clarification_text = human_clarification.clarification_text
177+
This method stores human clarification information for a plan associated with a session.
178+
It retrieves the plan from memory, updates it with the clarification text, and records
179+
the event in telemetry.
189180
190-
# Get the plan associated with this session
191-
plan = await self._memory_store.get_plan_by_session(session_id)
192-
if not plan:
193-
return f"No plan found for session {session_id}"
181+
Args:
182+
human_clarification: The HumanClarification object containing the session_id
183+
and human_clarification provided by the human user
194184
195-
# Update the plan with the clarification
196-
plan.human_clarification_response = clarification_text
197-
await self._memory_store.update_plan(plan)
198-
199-
# Track the event
200-
track_event_if_configured(
201-
"Human Agent - Provided clarification for plan",
202-
{
203-
"session_id": session_id,
204-
"user_id": self._user_id,
205-
"plan_id": plan.id,
206-
"clarification": clarification_text,
207-
},
185+
Returns:
186+
Status message indicating success or failure of adding the clarification
187+
"""
188+
session_id = human_clarification.session_id
189+
clarification_text = human_clarification.human_clarification
190+
191+
# Get the plan associated with this session
192+
plan = await self._memory_store.get_plan_by_session(session_id)
193+
if not plan:
194+
return f"No plan found for session {session_id}"
195+
196+
# Update the plan with the clarification
197+
plan.human_clarification_response = clarification_text
198+
await self._memory_store.update_plan(plan)
199+
await self._memory_store.add_item(
200+
AgentMessage(
201+
session_id=session_id,
202+
user_id=self._user_id,
203+
plan_id="",
204+
content=f"{clarification_text}",
205+
source=AgentType.HUMAN.value,
206+
step_id="",
208207
)
209-
210-
return f"Clarification provided for plan {plan.id}"
208+
)
209+
# Track the event
210+
track_event_if_configured(
211+
"Human Agent - Provided clarification for plan",
212+
{
213+
"session_id": session_id,
214+
"user_id": self._user_id,
215+
"plan_id": plan.id,
216+
"clarification": clarification_text,
217+
"source": AgentType.HUMAN.value,
218+
},
219+
)
220+
await self._memory_store.add_item(
221+
AgentMessage(
222+
session_id=session_id,
223+
user_id=self._user_id,
224+
plan_id="",
225+
content="Thanks. The plan has been updated.",
226+
source=AgentType.PLANNER.value,
227+
step_id="",
228+
)
229+
)
230+
track_event_if_configured(
231+
"Planner - Updated with HumanClarification and added into the cosmos",
232+
{
233+
"session_id": session_id,
234+
"user_id": self._user_id,
235+
"content": "Thanks. The plan has been updated.",
236+
"source": AgentType.PLANNER.value,
237+
},
238+
)
239+
return f"Clarification provided for plan {plan.id}"

0 commit comments

Comments
 (0)