Skip to content

Commit 8bed648

Browse files
logs updated
1 parent 1c21ba9 commit 8bed648

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

src/backend/api/agent/template_agent_factory.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,21 @@ async def create_or_get_agent(cls):
2626
)
2727

2828
# Test the connection early to provide better error messages
29+
# Use a safer approach that doesn't fail if no agents exist
2930
agents_list = project_client.agents.list_agents()
30-
await agents_list.__anext__() # Try to get first agent to test connectivity
31+
try:
32+
await agents_list.__anext__() # Try to get first agent
33+
except StopAsyncIteration:
34+
# This is expected if no agents exist - connection is working
35+
pass
3136

3237
except Exception as e:
33-
error_msg = f"Failed to connect to Azure AI Project endpoint '{app_settings.azure_ai.agent_endpoint}'. "
34-
error_msg += f"Original error: {str(e)}"
35-
36-
raise Exception(error_msg)
38+
# Skip the "End of paging" error as it means connection is working but no agents exist
39+
if "End of paging" not in str(e):
40+
error_msg = f"Failed to connect to Azure AI Project endpoint '{app_settings.azure_ai.agent_endpoint}'. "
41+
error_msg += f"Original error: {str(e)}"
42+
43+
raise Exception(error_msg)
3744

3845
agent_name = f"DG-TemplateAgent-{app_settings.base_settings.solution_name}"
3946
# 1. Check if the agent already exists

0 commit comments

Comments
 (0)