Skip to content

Commit bbb7b5f

Browse files
committed
fixing api human clarification
1 parent f9a9576 commit bbb7b5f

File tree

2 files changed

+26
-18
lines changed

2 files changed

+26
-18
lines changed

src/backend/app_kernel.py

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -329,18 +329,19 @@ async def human_clarification_endpoint(
329329
)
330330
raise HTTPException(status_code=400, detail="no user")
331331

332-
# Get the agents for this session
333-
agents = await get_agents(human_clarification.session_id, user_id)
334-
335-
# Send the clarification to the planner agent
336-
planner_agent = agents[AgentType.PLANNER.value]
332+
kernel, memory_store = await initialize_runtime_and_context(
333+
human_clarification.session_id, user_id
334+
)
335+
agents = await AgentFactory.create_all_agents(
336+
session_id=human_clarification.session_id, user_id=user_id
337+
)
337338

338-
# Convert clarification to JSON for proper processing
339-
human_clarification_json = human_clarification.json()
339+
# Send the feedback to the human agent
340+
human_agent = agents[AgentType.HUMAN.value]
340341

341-
# Use the planner to handle the clarification
342-
await planner_agent.handle_human_clarification(
343-
KernelArguments(human_clarification_json=human_clarification_json)
342+
# Use the human agent to handle the feedback
343+
await human_agent.handle_human_clarification(
344+
human_clarification=human_clarification
344345
)
345346

346347
track_event_if_configured(
@@ -523,7 +524,9 @@ async def get_plans(
523524
raise HTTPException(status_code=400, detail="no user")
524525

525526
# Initialize memory context
526-
memory_store = CosmosMemoryContext(session_id or "", user_id)
527+
kernel, memory_store = await initialize_runtime_and_context(
528+
session_id or "", user_id
529+
)
527530

528531
if session_id:
529532
plan = await memory_store.get_plan_by_session(session_id=session_id)
@@ -615,7 +618,7 @@ async def get_steps_by_plan(plan_id: str, request: Request) -> List[Step]:
615618
raise HTTPException(status_code=400, detail="no user")
616619

617620
# Initialize memory context
618-
memory_store = CosmosMemoryContext("", user_id)
621+
kernel, memory_store = await initialize_runtime_and_context("", user_id)
619622
steps = await memory_store.get_steps_for_plan(plan_id=plan_id)
620623
return steps
621624

@@ -681,7 +684,9 @@ async def get_agent_messages(session_id: str, request: Request) -> List[AgentMes
681684
raise HTTPException(status_code=400, detail="no user")
682685

683686
# Initialize memory context
684-
memory_store = CosmosMemoryContext(session_id, user_id)
687+
kernel, memory_store = await initialize_runtime_and_context(
688+
session_id or "", user_id
689+
)
685690
agent_messages = await memory_store.get_data_by_type("agent_message")
686691
return agent_messages
687692

@@ -712,7 +717,7 @@ async def delete_all_messages(request: Request) -> Dict[str, str]:
712717
raise HTTPException(status_code=400, detail="no user")
713718

714719
# Initialize memory context
715-
memory_store = CosmosMemoryContext(session_id="", user_id=user_id)
720+
kernel, memory_store = await initialize_runtime_and_context("", user_id)
716721

717722
logging.info("Deleting all plans")
718723
await memory_store.delete_all_items("plan")
@@ -773,7 +778,7 @@ async def get_all_messages(request: Request):
773778
raise HTTPException(status_code=400, detail="no user")
774779

775780
# Initialize memory context
776-
memory_store = CosmosMemoryContext(session_id="", user_id=user_id)
781+
kernel, memory_store = await initialize_runtime_and_context("", user_id)
777782
message_list = await memory_store.get_all_items()
778783
return message_list
779784

src/backend/kernel_agents/human_agent.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from models.messages_kernel import (
1111
AgentType,
1212
ApprovalRequest,
13+
HumanClarification,
1314
HumanFeedback,
1415
Step,
1516
StepStatus,
@@ -148,7 +149,9 @@ async def handle_human_feedback(self, human_feedback: HumanFeedback) -> str:
148149

149150
return "Human feedback processed successfully"
150151

151-
async def provide_clarification(self, kernel_arguments: KernelArguments) -> str:
152+
async def provide_clarification(
153+
self, human_clarification: HumanClarification
154+
) -> str:
152155
"""Provide clarification on a plan.
153156
154157
Args:
@@ -157,8 +160,8 @@ async def provide_clarification(self, kernel_arguments: KernelArguments) -> str:
157160
Returns:
158161
Status message
159162
"""
160-
session_id = kernel_arguments["session_id"]
161-
clarification_text = kernel_arguments["clarification_text"]
163+
session_id = human_clarification.session_id
164+
clarification_text = human_clarification.clarification_text
162165

163166
# Get the plan associated with this session
164167
plan = await self._memory_store.get_plan_by_session(session_id)

0 commit comments

Comments
 (0)