Skip to content

Commit 4f538bc

Browse files
committed
fixing last part of agent names, removing un use code
1 parent b795ad3 commit 4f538bc

File tree

5 files changed

+33
-71
lines changed

5 files changed

+33
-71
lines changed

src/backend/app_config.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,14 @@ async def create_azure_ai_agent(
217217
else:
218218
# Assume these are already proper tool definitions for create_agent
219219
tool_definitions = tools
220-
220+
logging.info("\n\n\n\n\n")
221+
logging.info("Tool definitions: %s", tool_definitions)
222+
logging.info("\n\n\n\n\n")
221223
# Create the agent using the project client
222224
if response_format is not None:
225+
logging.info("\n\n\n\n\n")
223226
logging.info("Response format provided: %s", response_format)
227+
logging.info("\n\n\n\n\n")
224228

225229

226230
agent_definition = await project_client.agents.create_agent(

src/backend/kernel_agents/agent_base.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -474,14 +474,14 @@ def load_tools_config(filename: str, config_path: Optional[str] = None) -> Dict[
474474

475475
# Normalize filename to avoid issues with spaces and capitalization
476476
# Convert "Hr Agent" to "hr" and "TechSupport Agent" to "tech_support"
477-
logging.debug(f"Normalizing filename: {filename}")
477+
logging.info(f"Normalizing filename: {filename}")
478478
normalized_filename = filename.replace(" ", "_").replace("-", "_").lower()
479479
# If it ends with "_agent", remove it
480480
if normalized_filename.endswith("_agent"):
481481
normalized_filename = normalized_filename[:-6]
482-
logging
482+
483483
config_path = os.path.join(backend_dir, "tools", f"{normalized_filename}_tools.json")
484-
logging.debug(f"Looking for tools config at: {config_path}")
484+
logging.info(f"Looking for tools config at: {config_path}")
485485

486486
try:
487487
with open(config_path, "r") as f:
@@ -540,12 +540,12 @@ def get_tools_from_config(cls, kernel: sk.Kernel, agent_type: str, config_path:
540540

541541
# Set this parameter in the function's metadata
542542
if param_name:
543-
logging.debug(f"Adding parameter '{param_name}' to function '{function_name}'")
543+
logging.info(f"Adding parameter '{param_name}' to function '{function_name}'")
544544

545545
# Register the function with the kernel
546546
kernel.add_function(plugin_name, kernel_func)
547547
kernel_functions.append(kernel_func)
548-
logging.debug(f"Successfully created dynamic tool '{function_name}' for {agent_type}")
548+
logging.info(f"Successfully created dynamic tool '{function_name}' for {agent_type}")
549549
except Exception as e:
550550
logging.error(f"Failed to create tool '{tool.get('name', 'unknown')}': {str(e)}")
551551

src/backend/kernel_agents/agent_factory.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -228,13 +228,13 @@ async def create_agent(
228228
if k in valid_keys
229229
}
230230
agent = agent_class(**filtered_kwargs)
231-
logger.debug(f"[DEBUG] Agent object after instantiation: {agent}")
231+
logger.info(f"[DEBUG] Agent object after instantiation: {agent}")
232232
# Initialize the agent asynchronously if it has async_init
233233
if hasattr(agent, "async_init") and inspect.iscoroutinefunction(
234234
agent.async_init
235235
):
236236
init_result = await agent.async_init()
237-
logger.debug(f"[DEBUG] Result of agent.async_init(): {init_result}")
237+
logger.info(f"[DEBUG] Result of agent.async_init(): {init_result}")
238238
# Register tools with Azure AI Agent for LLM function calls
239239
if (
240240
hasattr(agent, "_agent")
@@ -363,16 +363,15 @@ async def create_all_agents(
363363
# Create agent name to instance mapping for the planner
364364
agent_instances = {}
365365
for agent_type, agent in agents.items():
366-
agent_name = (
367-
cls._agent_type_strings.get(agent_type).replace("_", "") + "Agent"
368-
)
369-
agent_name = (
370-
agent_name[0].upper() + agent_name[1:]
371-
) # Capitalize first letter
366+
agent_name = agent_type.value
367+
368+
logging.info(
369+
f"Creating agent instance for {agent_name} with type {agent_type}"
370+
)
372371
agent_instances[agent_name] = agent
373372

374373
# Log the agent instances for debugging
375-
logger.debug(
374+
logger.info(
376375
f"Created {len(agent_instances)} agent instances for planner: {', '.join(agent_instances.keys())}"
377376
)
378377

src/backend/kernel_agents/group_chat_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ async def run_group_chat(self, user_input: str, plan_id: str = "", step_id: str
553553
messages = []
554554
if isinstance(result, str):
555555
# If it's just a string response
556-
logging.debug(f"Group chat returned a string: {result[:100]}...")
556+
logging.info(f"Group chat returned a string: {result[:100]}...")
557557
await self._memory_store.add_item(
558558
AgentMessage(
559559
session_id=self._session_id,

src/backend/kernel_agents/planner_agent.py

Lines changed: 14 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def __init__(
9393
AgentType.HUMAN.value,
9494
AgentType.HR.value,
9595
AgentType.MARKETING.value,
96-
AgentType.PRODUCT,
96+
AgentType.PRODUCT.value,
9797
AgentType.PROCUREMENT.value,
9898
AgentType.TECH_SUPPORT.value,
9999
AgentType.GENERIC.value,
@@ -105,48 +105,6 @@ def __init__(
105105
# This will be initialized in async_init
106106
self._azure_ai_agent = None
107107

108-
def _get_response_format_schema(self) -> dict:
109-
"""
110-
Returns a JSON schema that defines the expected structure of the response.
111-
This ensures responses from the agent will match the required format exactly.
112-
"""
113-
return {
114-
"type": "object",
115-
"properties": {
116-
"initial_goal": {
117-
"type": "string",
118-
"description": "The primary goal extracted from the user's input task",
119-
},
120-
"steps": {
121-
"type": "array",
122-
"description": "List of steps required to complete the task",
123-
"items": {
124-
"type": "object",
125-
"properties": {
126-
"action": {
127-
"type": "string",
128-
"description": "A clear instruction for the agent including the function name to use",
129-
},
130-
"agent": {
131-
"type": "string",
132-
"description": "The name of the agent responsible for this step",
133-
},
134-
},
135-
"required": ["action", "agent"],
136-
},
137-
},
138-
"summary_plan_and_steps": {
139-
"type": "string",
140-
"description": "A concise summary of the overall plan and its steps in less than 50 words",
141-
},
142-
"human_clarification_request": {
143-
"type": ["string", "null"],
144-
"description": "Optional request for additional information needed from the user",
145-
},
146-
},
147-
"required": ["initial_goal", "steps", "summary_plan_and_steps"],
148-
}
149-
150108
async def async_init(self) -> None:
151109
"""Asynchronously initialize the PlannerAgent.
152110
@@ -331,12 +289,12 @@ async def _create_structured_plan(
331289
try:
332290
# Generate the instruction for the LLM
333291
logging.info("Generating instruction for the LLM")
334-
logging.debug(f"Input: {input_task}")
335-
logging.debug(f"Available agents: {self._available_agents}")
292+
logging.info(f"Input: {input_task}")
293+
logging.info(f"Available agents: {self._available_agents}")
336294

337295
# Get template variables as a dictionary
338296
args = self._generate_args(input_task.description)
339-
297+
logging.info(f"Generated args: {args}")
340298
logging.info(f"Creating plan for task: '{input_task.description}'")
341299
logging.info(f"Using available agents: {self._available_agents}")
342300

@@ -355,10 +313,10 @@ async def _create_structured_plan(
355313
kernel_args = KernelArguments(**args)
356314
# kernel_args["input"] = f"TASK: {input_task.description}\n\n{instruction}"
357315

358-
logging.debug(f"Kernel arguments: {kernel_args}")
316+
logging.info(f"Kernel arguments: {kernel_args}")
359317

360318
# Get the schema for our expected response format
361-
response_format_schema = self._get_response_format_schema()
319+
362320

363321
# Ensure we're using the right pattern for Azure AI agents with semantic kernel
364322
# Properly handle async generation
@@ -367,10 +325,6 @@ async def _create_structured_plan(
367325
settings={
368326
"temperature": 0.0, # Keep temperature low for consistent planning
369327
"max_tokens": 10096, # Ensure we have enough tokens for the full plan
370-
"response_format": {
371-
"type": "json_object",
372-
"schema": response_format_schema,
373-
},
374328
},
375329
)
376330

@@ -382,8 +336,9 @@ async def _create_structured_plan(
382336
if chunk is not None:
383337
response_content += str(chunk)
384338

339+
logging.info(f"\n\n\n\n")
385340
logging.info(f"Response content length: {len(response_content)}")
386-
logging.debug(f"Response content: {response_content[:500]}...")
341+
logging.info(f"\n\n\n\n")
387342

388343
# Check if response is empty or whitespace
389344
if not response_content or response_content.isspace():
@@ -398,6 +353,9 @@ async def _create_structured_plan(
398353
try:
399354
parsed_result = PlannerResponsePlan.parse_raw(response_content)
400355
logging.info("Successfully parsed response with direct parsing")
356+
logging.info(f"\n\n\n\n")
357+
logging.info(f"Parsed result: {parsed_result}")
358+
logging.info(f"\n\n\n\n")
401359
except Exception as parse_error:
402360
logging.warning(f"Failed direct parse: {parse_error}")
403361

@@ -727,6 +685,7 @@ def _generate_args(self, objective: str) -> any:
727685
if hasattr(self, "_agent_instances") and self._agent_instances:
728686
# Process each agent to get their tools
729687
for agent_name, agent in self._agent_instances.items():
688+
730689
if hasattr(agent, "_tools") and agent._tools:
731690
# Add each tool from this agent
732691
for tool in agent._tools:
@@ -814,7 +773,7 @@ def _generate_args(self, objective: str) -> any:
814773

815774
tools_list.append(tool_entry)
816775

817-
logging.debug(f"Generated {len(tools_list)} tools from agent instances")
776+
logging.info(f"Generated {len(tools_list)} tools from agent instances")
818777

819778
# If we couldn't extract tools from agent instances, create a simplified format
820779
if not tools_list:
@@ -833,7 +792,7 @@ def _generate_args(self, objective: str) -> any:
833792
# Extract agent name if format is "Agent: AgentName"
834793
agent_name = agent_part.replace("Agent", "").strip()
835794
if not agent_name:
836-
agent_name = "GenericAgent"
795+
agent_name = AgentType.GENERIC.value
837796

838797
tools_list.append(
839798
{

0 commit comments

Comments
 (0)