Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions src/backend/app_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,14 @@ def get_ai_project_client(self):
self._ai_project_client = AIProjectClient.from_connection_string(
credential=credential, conn_str=connection_string
)
logging.info("Successfully created AIProjectClient using connection string")

return self._ai_project_client
except Exception as exc:
logging.error("Failed to create AIProjectClient: %s", exc)
raise

async def create_azure_ai_agent(
self,
kernel: Kernel,
agent_name: str,
instructions: str,
tools: Optional[List[KernelFunction]] = None,
Expand Down Expand Up @@ -221,21 +220,15 @@ async def create_azure_ai_agent(

# First try to get an existing agent with this name as assistant_id
try:
logging.info(f"Trying to retrieve existing agent with ID: {agent_name}")
existing_definition = await project_client.agents.get_agent(agent_name)
logging.info(f"Found existing agent with ID: {agent_name}")

existing_definition = await project_client.agents.get_agent(agent_name)
# Create the agent instance directly with project_client and existing definition
agent = AzureAIAgent(
client=project_client,
definition=existing_definition,
kernel=kernel,
plugins=tools,
)

logging.info(
f"Successfully loaded existing Azure AI Agent for {agent_name}"
)
return agent
except Exception as e:
# The Azure AI Projects SDK throws an exception when the agent doesn't exist
Expand Down Expand Up @@ -263,7 +256,6 @@ async def create_azure_ai_agent(
agent = AzureAIAgent(
client=project_client,
definition=agent_definition,
kernel=kernel,
plugins=tools,
)

Expand Down
9 changes: 1 addition & 8 deletions src/backend/app_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,13 @@ async def input_task_endpoint(input_task: InputTask, request: Request):
agents = await AgentFactory.create_all_agents(
session_id=input_task.session_id,
user_id=user_id,
kernel=kernel,
memory_store=memory_store,
)

group_chat_manager = agents[AgentType.GROUP_CHAT_MANAGER.value]

# Convert input task to JSON for the kernel function, add user_id here

logging.info(f"Input task: {input_task}")
# Use the planner to handle the task
result = await group_chat_manager.handle_input_task(input_task)

Expand Down Expand Up @@ -252,10 +250,7 @@ async def human_feedback_endpoint(human_feedback: HumanFeedback, request: Reques
human_feedback.session_id, user_id
)
agents = await AgentFactory.create_all_agents(
session_id=human_feedback.session_id,
user_id=user_id,
memory_store=memory_store,
kernel=kernel,
session_id=human_feedback.session_id, user_id=user_id, memory_store=memory_store
)

# Send the feedback to the human agent
Expand Down Expand Up @@ -342,7 +337,6 @@ async def human_clarification_endpoint(
session_id=human_clarification.session_id,
user_id=user_id,
memory_store=memory_store,
kernel=kernel,
)

# Send the feedback to the human agent
Expand Down Expand Up @@ -436,7 +430,6 @@ async def approve_step_endpoint(
agents = await AgentFactory.create_all_agents(
session_id=human_feedback.session_id,
user_id=user_id,
kernel=kernel,
memory_store=memory_store,
)

Expand Down
Loading