Skip to content

Commit 658bc27

Browse files
authored
Merge pull request #110 from Fr4nc3/main
Fixing Planner Agent
2 parents 7f2f4af + 2587b57 commit 658bc27

File tree

4 files changed

+350
-94
lines changed

4 files changed

+350
-94
lines changed

src/backend/app_kernel.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -144,25 +144,6 @@ async def input_task_endpoint(input_task: InputTask, request: Request):
144144

145145
print(f"Plan: {plan}")
146146

147-
if not plan or not plan.id:
148-
# If plan not found by session, try to extract plan ID from result
149-
plan_id_match = re.search(r"Plan '([^']+)'", result)
150-
151-
if plan_id_match:
152-
plan_id = plan_id_match.group(1)
153-
plan = await memory_store.get_plan(plan_id)
154-
155-
# If still no plan found, handle the failure
156-
if not plan or not plan.id:
157-
track_event_if_configured(
158-
"PlanCreationFailed",
159-
{
160-
"session_id": input_task.session_id,
161-
"description": input_task.description,
162-
}
163-
)
164-
raise HTTPException(status_code=400, detail="Error: Failed to create plan")
165-
166147
# Log custom event for successful input task processing
167148
track_event_if_configured(
168149
"InputTaskProcessed",

src/backend/event_utils.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,24 @@
44

55

66
def track_event_if_configured(event_name: str, event_data: dict):
7-
instrumentation_key = os.getenv("APPLICATIONINSIGHTS_CONNECTION_STRING")
8-
if instrumentation_key:
9-
track_event(event_name, event_data)
10-
# else:
11-
# logging.warning(f"Skipping track_event for {event_name} as Application Insights is not configured")
7+
"""Track an event if Application Insights is configured.
8+
9+
This function safely wraps the Azure Monitor track_event function
10+
to handle potential errors with the ProxyLogger.
11+
12+
Args:
13+
event_name: The name of the event to track
14+
event_data: Dictionary of event data/dimensions
15+
"""
16+
try:
17+
instrumentation_key = os.getenv("APPLICATIONINSIGHTS_CONNECTION_STRING")
18+
if instrumentation_key:
19+
track_event(event_name, event_data)
20+
# else:
21+
# logging.warning(f"Skipping track_event for {event_name} as Application Insights is not configured")
22+
except AttributeError as e:
23+
# Handle the 'ProxyLogger' object has no attribute 'resource' error
24+
logging.warning(f"ProxyLogger error in track_event: {e}")
25+
except Exception as e:
26+
# Catch any other exceptions to prevent them from bubbling up
27+
logging.warning(f"Error in track_event: {e}")

src/backend/kernel_agents/agent_base.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,6 @@ def __init__(
110110
# Required properties for AgentGroupChat compatibility
111111
self.name = agent_name # This is crucial for AgentGroupChat to identify agents
112112

113-
# Log initialization
114-
logging.info(f"Initialized {agent_name} with {len(self._tools)} tools")
115113

116114
# Register the handler functions
117115
self._register_functions()
@@ -541,11 +539,6 @@ def get_tools_from_config(cls, kernel: sk.Kernel, agent_type: str, config_path:
541539
except Exception as e:
542540
logging.error(f"Failed to create tool '{tool.get('name', 'unknown')}': {str(e)}")
543541

544-
# Log the total number of tools created
545-
if kernel_functions:
546-
logging.info(f"Created {len(kernel_functions)} tools for agent type '{agent_type}'")
547-
else:
548-
logging.info(f"No tools were successfully created for agent type '{agent_type}'")
549542

550543
return kernel_functions
551544

0 commit comments

Comments
 (0)