Skip to content

Commit d64e0cb

Browse files
committed
cleaning up logs
1 parent c4930e6 commit d64e0cb

File tree

2 files changed

+23
-31
lines changed

2 files changed

+23
-31
lines changed

src/backend/kernel_agents/agent_factory.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,13 +214,12 @@ async def create_agent(
214214
if k in valid_keys
215215
}
216216
agent = agent_class(**filtered_kwargs)
217-
logger.info(f"[DEBUG] Agent object after instantiation: {agent}")
217+
218218
# Initialize the agent asynchronously if it has async_init
219219
if hasattr(agent, "async_init") and inspect.iscoroutinefunction(
220220
agent.async_init
221221
):
222222
init_result = await agent.async_init()
223-
logger.info(f"[DEBUG] Result of agent.async_init(): {init_result}")
224223

225224
except Exception as e:
226225
logger.error(

src/backend/kernel_agents/planner_agent.py

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,6 @@ def __init__(
103103
self._agent_tools_list = agent_tools_list or []
104104
self._agent_instances = agent_instances or {}
105105

106-
# Create the Azure AI Agent for planning operations
107-
# This will be initialized in async_init
108-
self._azure_ai_agent = None
109-
110106
@staticmethod
111107
def default_system_message(agent_name=None) -> str:
112108
"""Get the default system message for the agent.
@@ -130,22 +126,22 @@ async def async_init(self) -> None:
130126

131127
# Get the agent template - defined in function to allow for easy updates
132128
instructions = self._get_template()
133-
134-
# Create the Azure AI Agent using AppConfig with string instructions
135-
self._azure_ai_agent = await config.create_azure_ai_agent(
136-
kernel=self._kernel,
137-
agent_name=self._agent_name,
138-
instructions=instructions, # Pass the formatted string, not an object
139-
temperature=0.0,
140-
response_format=ResponseFormatJsonSchemaType(
141-
json_schema=ResponseFormatJsonSchema(
142-
name=PlannerResponsePlan.__name__,
143-
description=f"respond with {PlannerResponsePlan.__name__.lower()}",
144-
schema=PlannerResponsePlan.model_json_schema(),
145-
)
146-
),
147-
)
148-
logging.info("Successfully created Azure AI Agent for PlannerAgent")
129+
if not self._agent:
130+
# Create the Azure AI Agent using AppConfig with string instructions
131+
self._agent = await config.create_azure_ai_agent(
132+
kernel=self._kernel,
133+
agent_name=self._agent_name,
134+
instructions=instructions, # Pass the formatted string, not an object
135+
temperature=0.0,
136+
response_format=ResponseFormatJsonSchemaType(
137+
json_schema=ResponseFormatJsonSchema(
138+
name=PlannerResponsePlan.__name__,
139+
description=f"respond with {PlannerResponsePlan.__name__.lower()}",
140+
schema=PlannerResponsePlan.model_json_schema(),
141+
)
142+
),
143+
)
144+
logging.info("Successfully created Azure AI Agent for PlannerAgent")
149145
return True
150146
except Exception as e:
151147
logging.error(f"Failed to create Azure AI Agent for PlannerAgent: {e}")
@@ -300,22 +296,16 @@ async def _create_structured_plan(
300296
"""
301297
try:
302298
# Generate the instruction for the LLM
303-
logging.info("Generating instruction for the LLM")
304-
logging.info(f"Input: {input_task}")
305-
logging.info(f"Available agents: {self._available_agents}")
306299

307300
# Get template variables as a dictionary
308301
args = self._generate_args(input_task.description)
309-
logging.info(f"Generated args: {args}")
310-
logging.info(f"Creating plan for task: '{input_task.description}'")
311-
logging.info(f"Using available agents: {self._available_agents}")
312302

313303
# Use the Azure AI Agent instead of direct function invocation
314-
if self._azure_ai_agent is None:
304+
if self._agent is None:
315305
# Initialize the agent if it's not already done
316306
await self.async_init()
317307

318-
if self._azure_ai_agent is None:
308+
if self._agent is None:
319309
raise RuntimeError("Failed to initialize Azure AI Agent for planning")
320310

321311
# Log detailed information about the instruction being sent
@@ -336,7 +326,7 @@ async def _create_structured_plan(
336326
# )
337327
thread = None
338328
# thread = self.client.agents.create_thread(thread_id=input_task.session_id)
339-
async_generator = self._azure_ai_agent.invoke(
329+
async_generator = self._agent.invoke(
340330
arguments=kernel_args,
341331
settings={
342332
"temperature": 0.0, # Keep temperature low for consistent planning
@@ -705,6 +695,9 @@ def _generate_args(self, objective: str) -> any:
705695
)
706696

707697
# Convert the tools list to a string representation
698+
logging.info(f"Tools list: {len(tools_list)}")
699+
logging
700+
708701
tools_str = str(tools_list)
709702

710703
# Return a dictionary with template variables

0 commit comments

Comments
 (0)