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
19 changes: 0 additions & 19 deletions src/backend/app_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,25 +144,6 @@ async def input_task_endpoint(input_task: InputTask, request: Request):

print(f"Plan: {plan}")

if not plan or not plan.id:
# If plan not found by session, try to extract plan ID from result
plan_id_match = re.search(r"Plan '([^']+)'", result)

if plan_id_match:
plan_id = plan_id_match.group(1)
plan = await memory_store.get_plan(plan_id)

# If still no plan found, handle the failure
if not plan or not plan.id:
track_event_if_configured(
"PlanCreationFailed",
{
"session_id": input_task.session_id,
"description": input_task.description,
}
)
raise HTTPException(status_code=400, detail="Error: Failed to create plan")

# Log custom event for successful input task processing
track_event_if_configured(
"InputTaskProcessed",
Expand Down
26 changes: 21 additions & 5 deletions src/backend/event_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,24 @@


def track_event_if_configured(event_name: str, event_data: dict):
instrumentation_key = os.getenv("APPLICATIONINSIGHTS_CONNECTION_STRING")
if instrumentation_key:
track_event(event_name, event_data)
# else:
# logging.warning(f"Skipping track_event for {event_name} as Application Insights is not configured")
"""Track an event if Application Insights is configured.
This function safely wraps the Azure Monitor track_event function
to handle potential errors with the ProxyLogger.
Args:
event_name: The name of the event to track
event_data: Dictionary of event data/dimensions
"""
try:
instrumentation_key = os.getenv("APPLICATIONINSIGHTS_CONNECTION_STRING")
if instrumentation_key:
track_event(event_name, event_data)
# else:
# logging.warning(f"Skipping track_event for {event_name} as Application Insights is not configured")
except AttributeError as e:
# Handle the 'ProxyLogger' object has no attribute 'resource' error
logging.warning(f"ProxyLogger error in track_event: {e}")
except Exception as e:
# Catch any other exceptions to prevent them from bubbling up
logging.warning(f"Error in track_event: {e}")
7 changes: 0 additions & 7 deletions src/backend/kernel_agents/agent_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ def __init__(
# Required properties for AgentGroupChat compatibility
self.name = agent_name # This is crucial for AgentGroupChat to identify agents

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

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

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

return kernel_functions

Expand Down
Loading
Loading