Replying to activity: AAMkAGFmMDY4Njg3LTUwZjMtNGMwMi05ODEyLWRlYTEwZmU5N2QyNwBGAAAAAABAB6JzYS9qSYCtlLQp01P1BwDOpRR-vAClSqv215qqRzxqAAAAAAEMAADOpRR-vAClSqv215qqRzxqAAAOPZYwAAA= in conversation: x5Nj0gAAAKLwNZMBpWVtYWls2ZhBQU1rQUdGbU1EWTROamczTFRVd1pqTXROR013TWkwNU9ERXlMV1JsWVRFd1ptVTVOMlF5TndCR0FBAgDwH0JBQjZKellTOXFTWUN0bExRcDAxUDFCd0RPcFJSLX. Activity type is message
INFO:microsoft_agents.hosting.core.connector.client.connector_client:Replying to activity: AAMkAGFmMDY4Njg3LTUwZjMtNGMwMi05ODEyLWRlYTEwZmU5N2QyNwBGAAAAAABAB6JzYS9qSYCtlLQp01P1BwDOpRR-vAClSqv215qqRzxqAAAAAAEMAADOpRR-vAClSqv215qqRzxqAAAOPZYwAAA= in conversation: x5Nj0gAAAKLwNZMBpWVtYWls2ZhBQU1rQUdGbU1EWTROamczTFRVd1pqTXROR013TWkwNU9ERXlMV1JsWVRFd1ptVTVOMlF5TndCR0FBAgDwH0JBQjZKellTOXFTWUN0bExRcDAxUDFCd0RPcFJSLX. Activity type is message
Error replying to activity: 502
Stack (most recent call last):
File "/Users/zeyi.f/AgentsToolkitProjects/Agent365-Samples/python/agent-framework/sample-agent/start_with_generic_host.py", line 41, in <module>
exit(main())
File "/Users/zeyi.f/AgentsToolkitProjects/Agent365-Samples/python/agent-framework/sample-agent/start_with_generic_host.py", line 28, in main
create_and_run_host(AgentFrameworkAgent)
File "/Users/zeyi.f/AgentsToolkitProjects/Agent365-Samples/python/agent-framework/sample-agent/host_agent_server.py", line 76, in create_and_run_host
host.start_server(auth_config)
File "/Users/zeyi.f/AgentsToolkitProjects/Agent365-Samples/python/agent-framework/sample-agent/host_agent_server.py", line 321, in start_server
run_app(app, host="localhost", port=port, handle_signals=True)
File "/Users/zeyi.f/.cache/uv/archive-v0/qlFyE0rMtgmOM-gDkYB9l/lib/python3.12/site-packages/aiohttp/web.py", line 510, in run_app
loop.run_until_complete(main_task)
File "/Users/zeyi.f/.local/share/uv/python/cpython-3.12.0-macos-aarch64-none/lib/python3.12/asyncio/base_events.py", line 651, in run_until_complete
self.run_forever()
File "/Users/zeyi.f/.local/share/uv/python/cpython-3.12.0-macos-aarch64-none/lib/python3.12/asyncio/base_events.py", line 618, in run_forever
self._run_once()
File "/Users/zeyi.f/.local/share/uv/python/cpython-3.12.0-macos-aarch64-none/lib/python3.12/asyncio/base_events.py", line 1951, in _run_once
handle._run()
File "/Users/zeyi.f/.local/share/uv/python/cpython-3.12.0-macos-aarch64-none/lib/python3.12/asyncio/events.py", line 84, in _run
self._context.run(self._callback, *self._args)
File "/Users/zeyi.f/.cache/uv/archive-v0/qlFyE0rMtgmOM-gDkYB9l/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 510, in _handle_request
resp = await request_handler(request)
File "/Users/zeyi.f/.cache/uv/archive-v0/qlFyE0rMtgmOM-gDkYB9l/lib/python3.12/site-packages/aiohttp/web_app.py", line 569, in _handle
return await handler(request)
File "/Users/zeyi.f/.cache/uv/archive-v0/qlFyE0rMtgmOM-gDkYB9l/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 117, in impl
return await handler(request)
File "/Users/zeyi.f/AgentsToolkitProjects/Agent365-Samples/python/agent-framework/sample-agent/host_agent_server.py", line 288, in anonymous_claims
return await handler(request)
File "/Users/zeyi.f/AgentsToolkitProjects/Agent365-Samples/python/agent-framework/sample-agent/host_agent_server.py", line 260, in entry_point
return await start_agent_process(
File "/Users/zeyi.f/AgentsToolkitProjects/Agent365-Samples/python/agent-framework/sample-agent/.venv/lib/python3.12/site-packages/microsoft_agents/hosting/aiohttp/_start_agent_process.py", line 23, in start_agent_process
return await adapter.process(
File "/Users/zeyi.f/AgentsToolkitProjects/Agent365-Samples/python/agent-framework/sample-agent/.venv/lib/python3.12/site-packages/microsoft_agents/hosting/aiohttp/cloud_adapter.py", line 101, in process
invoke_response = await self.process_activity(
File "/Users/zeyi.f/.cache/uv/archive-v0/qlFyE0rMtgmOM-gDkYB9l/lib/python3.12/site-packages/microsoft_agents/hosting/core/channel_service_adapter.py", line 419, in process_activity
await self.run_pipeline(context, callback)
File "/Users/zeyi.f/.cache/uv/archive-v0/qlFyE0rMtgmOM-gDkYB9l/lib/python3.12/site-packages/microsoft_agents/hosting/core/channel_adapter.py", line 242, in run_pipeline
return await self.middleware_set.receive_activity_with_status(
File "/Users/zeyi.f/.cache/uv/archive-v0/qlFyE0rMtgmOM-gDkYB9l/lib/python3.12/site-packages/microsoft_agents/hosting/core/middleware_set.py", line 56, in receive_activity_with_status
return await self.receive_activity_internal(context, callback)
File "/Users/zeyi.f/.cache/uv/archive-v0/qlFyE0rMtgmOM-gDkYB9l/lib/python3.12/site-packages/microsoft_agents/hosting/core/middleware_set.py", line 66, in receive_activity_internal
return await callback(context)
File "/Users/zeyi.f/.cache/uv/archive-v0/qlFyE0rMtgmOM-gDkYB9l/lib/python3.12/site-packages/microsoft_agents/hosting/core/app/agent_application.py", line 679, in on_turn
await self._start_long_running_call(context, self._on_turn)
File "/Users/zeyi.f/.cache/uv/archive-v0/qlFyE0rMtgmOM-gDkYB9l/lib/python3.12/site-packages/microsoft_agents/hosting/core/app/agent_application.py", line 865, in _start_long_running_call
return await func(context)
File "/Users/zeyi.f/.cache/uv/archive-v0/qlFyE0rMtgmOM-gDkYB9l/lib/python3.12/site-packages/microsoft_agents/hosting/core/app/agent_application.py", line 722, in _on_turn
await self._on_activity(context, turn_state)
File "/Users/zeyi.f/.cache/uv/archive-v0/qlFyE0rMtgmOM-gDkYB9l/lib/python3.12/site-packages/microsoft_agents/hosting/core/app/agent_application.py", line 842, in _on_activity
await route.handler(context, state)
File "/Users/zeyi.f/AgentsToolkitProjects/Agent365-Samples/python/agent-framework/sample-agent/host_agent_server.py", line 178, in on_message
await context.send_activity(response)
File "/Users/zeyi.f/.cache/uv/archive-v0/qlFyE0rMtgmOM-gDkYB9l/lib/python3.12/site-packages/microsoft_agents/hosting/core/turn_context.py", line 210, in send_activity
result = await self.send_activities([activity_or_text])
File "/Users/zeyi.f/.cache/uv/archive-v0/qlFyE0rMtgmOM-gDkYB9l/lib/python3.12/site-packages/microsoft_agents/hosting/core/turn_context.py", line 263, in send_activities
return await self._emit(self._on_send_activities, output, logic())
File "/Users/zeyi.f/.cache/uv/archive-v0/qlFyE0rMtgmOM-gDkYB9l/lib/python3.12/site-packages/microsoft_agents/hosting/core/turn_context.py", line 341, in _emit
return await logic
File "/Users/zeyi.f/.cache/uv/archive-v0/qlFyE0rMtgmOM-gDkYB9l/lib/python3.12/site-packages/microsoft_agents/hosting/core/turn_context.py", line 258, in logic
responses = await self.adapter.send_activities(self, output)
File "/Users/zeyi.f/.cache/uv/archive-v0/qlFyE0rMtgmOM-gDkYB9l/lib/python3.12/site-packages/microsoft_agents/hosting/core/channel_service_adapter.py", line 103, in send_activities
response = await connector_client.conversations.reply_to_activity(
File "/Users/zeyi.f/.cache/uv/archive-v0/qlFyE0rMtgmOM-gDkYB9l/lib/python3.12/site-packages/microsoft_agents/hosting/core/connector/client/connector_client.py", line 216, in reply_to_activity
logger.error(
ERROR:microsoft_agents.hosting.core.connector.client.connector_client:Error replying to activity: 502
Stack (most recent call last):
File "/Users/zeyi.f/AgentsToolkitProjects/Agent365-Samples/python/agent-framework/sample-agent/start_with_generic_host.py", line 41, in <module>
exit(main())
File "/Users/zeyi.f/AgentsToolkitProjects/Agent365-Samples/python/agent-framework/sample-agent/start_with_generic_host.py", line 28, in main
create_and_run_host(AgentFrameworkAgent)
File "/Users/zeyi.f/AgentsToolkitProjects/Agent365-Samples/python/agent-framework/sample-agent/host_agent_server.py", line 76, in create_and_run_host
host.start_server(auth_config)
File "/Users/zeyi.f/AgentsToolkitProjects/Agent365-Samples/python/agent-framework/sample-agent/host_agent_server.py", line 321, in start_server
run_app(app, host="localhost", port=port, handle_signals=True)
File "/Users/zeyi.f/.cache/uv/archive-v0/qlFyE0rMtgmOM-gDkYB9l/lib/python3.12/site-packages/aiohttp/web.py", line 510, in run_app
loop.run_until_complete(main_task)
File "/Users/zeyi.f/.local/share/uv/python/cpython-3.12.0-macos-aarch64-none/lib/python3.12/asyncio/base_events.py", line 651, in run_until_complete
self.run_forever()
File "/Users/zeyi.f/.local/share/uv/python/cpython-3.12.0-macos-aarch64-none/lib/python3.12/asyncio/base_events.py", line 618, in run_forever
self._run_once()
File "/Users/zeyi.f/.local/share/uv/python/cpython-3.12.0-macos-aarch64-none/lib/python3.12/asyncio/base_events.py", line 1951, in _run_once
handle._run()
File "/Users/zeyi.f/.local/share/uv/python/cpython-3.12.0-macos-aarch64-none/lib/python3.12/asyncio/events.py", line 84, in _run
self._context.run(self._callback, *self._args)
File "/Users/zeyi.f/.cache/uv/archive-v0/qlFyE0rMtgmOM-gDkYB9l/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 510, in _handle_request
resp = await request_handler(request)
File "/Users/zeyi.f/.cache/uv/archive-v0/qlFyE0rMtgmOM-gDkYB9l/lib/python3.12/site-packages/aiohttp/web_app.py", line 569, in _handle
return await handler(request)
File "/Users/zeyi.f/.cache/uv/archive-v0/qlFyE0rMtgmOM-gDkYB9l/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 117, in impl
return await handler(request)
File "/Users/zeyi.f/AgentsToolkitProjects/Agent365-Samples/python/agent-framework/sample-agent/host_agent_server.py", line 288, in anonymous_claims
return await handler(request)
File "/Users/zeyi.f/AgentsToolkitProjects/Agent365-Samples/python/agent-framework/sample-agent/host_agent_server.py", line 260, in entry_point
return await start_agent_process(
File "/Users/zeyi.f/AgentsToolkitProjects/Agent365-Samples/python/agent-framework/sample-agent/.venv/lib/python3.12/site-packages/microsoft_agents/hosting/aiohttp/_start_agent_process.py", line 23, in start_agent_process
return await adapter.process(
File "/Users/zeyi.f/AgentsToolkitProjects/Agent365-Samples/python/agent-framework/sample-agent/.venv/lib/python3.12/site-packages/microsoft_agents/hosting/aiohttp/cloud_adapter.py", line 101, in process
invoke_response = await self.process_activity(
File "/Users/zeyi.f/.cache/uv/archive-v0/qlFyE0rMtgmOM-gDkYB9l/lib/python3.12/site-packages/microsoft_agents/hosting/core/channel_service_adapter.py", line 419, in process_activity
await self.run_pipeline(context, callback)
File "/Users/zeyi.f/.cache/uv/archive-v0/qlFyE0rMtgmOM-gDkYB9l/lib/python3.12/site-packages/microsoft_agents/hosting/core/channel_adapter.py", line 242, in run_pipeline
return await self.middleware_set.receive_activity_with_status(
File "/Users/zeyi.f/.cache/uv/archive-v0/qlFyE0rMtgmOM-gDkYB9l/lib/python3.12/site-packages/microsoft_agents/hosting/core/middleware_set.py", line 56, in receive_activity_with_status
return await self.receive_activity_internal(context, callback)
File "/Users/zeyi.f/.cache/uv/archive-v0/qlFyE0rMtgmOM-gDkYB9l/lib/python3.12/site-packages/microsoft_agents/hosting/core/middleware_set.py", line 66, in receive_activity_internal
return await callback(context)
File "/Users/zeyi.f/.cache/uv/archive-v0/qlFyE0rMtgmOM-gDkYB9l/lib/python3.12/site-packages/microsoft_agents/hosting/core/app/agent_application.py", line 679, in on_turn
await self._start_long_running_call(context, self._on_turn)
File "/Users/zeyi.f/.cache/uv/archive-v0/qlFyE0rMtgmOM-gDkYB9l/lib/python3.12/site-packages/microsoft_agents/hosting/core/app/agent_application.py", line 865, in _start_long_running_call
return await func(context)
File "/Users/zeyi.f/.cache/uv/archive-v0/qlFyE0rMtgmOM-gDkYB9l/lib/python3.12/site-packages/microsoft_agents/hosting/core/app/agent_application.py", line 722, in _on_turn
await self._on_activity(context, turn_state)
File "/Users/zeyi.f/.cache/uv/archive-v0/qlFyE0rMtgmOM-gDkYB9l/lib/python3.12/site-packages/microsoft_agents/hosting/core/app/agent_application.py", line 842, in _on_activity
await route.handler(context, state)
File "/Users/zeyi.f/AgentsToolkitProjects/Agent365-Samples/python/agent-framework/sample-agent/host_agent_server.py", line 178, in on_message
await context.send_activity(response)
File "/Users/zeyi.f/.cache/uv/archive-v0/qlFyE0rMtgmOM-gDkYB9l/lib/python3.12/site-packages/microsoft_agents/hosting/core/turn_context.py", line 210, in send_activity
result = await self.send_activities([activity_or_text])
File "/Users/zeyi.f/.cache/uv/archive-v0/qlFyE0rMtgmOM-gDkYB9l/lib/python3.12/site-packages/microsoft_agents/hosting/core/turn_context.py", line 263, in send_activities
return await self._emit(self._on_send_activities, output, logic())
File "/Users/zeyi.f/.cache/uv/archive-v0/qlFyE0rMtgmOM-gDkYB9l/lib/python3.12/site-packages/microsoft_agents/hosting/core/turn_context.py", line 341, in _emit
return await logic
File "/Users/zeyi.f/.cache/uv/archive-v0/qlFyE0rMtgmOM-gDkYB9l/lib/python3.12/site-packages/microsoft_agents/hosting/core/turn_context.py", line 258, in logic
responses = await self.adapter.send_activities(self, output)
File "/Users/zeyi.f/.cache/uv/archive-v0/qlFyE0rMtgmOM-gDkYB9l/lib/python3.12/site-packages/microsoft_agents/hosting/core/channel_service_adapter.py", line 103, in send_activities
response = await connector_client.conversations.reply_to_activity(
File "/Users/zeyi.f/.cache/uv/archive-v0/qlFyE0rMtgmOM-gDkYB9l/lib/python3.12/site-packages/microsoft_agents/hosting/core/connector/client/connector_client.py", line 216, in reply_to_activity
logger.error(
ERROR:host_agent_server:❌ Error: 502, message='Bad Gateway', url='https://smba.trafficmanager.net/amer/f6158b50-3c1f-4d22-93b4-b38cd9f4289c/v3/conversations/x5Nj0gAAAKLwNZMBpWVtYWls2ZhBQU1rQUdGbU1EWTROamczTFRVd1pqTXROR013TWkwNU9ERXlMV1JsWVRFd1ptVTVOMlF5TndCR0FBAgDwH0JBQjZKellTOXFTWUN0bExRcDAxUDFCd0RPcFJSLX/activities/AAMkAGFmMDY4Njg3LTUwZjMtNGMwMi05ODEyLWRlYTEwZmU5N2QyNwBGAAAAAABAB6JzYS9qSYCtlLQp01P1BwDOpRR-vAClSqv215qqRzxqAAAAAAEMAADOpRR-vAClSqv215qqRzxqAAAOPZYwAAA='
Hi, I am testing the Python sample project in https://github.com/microsoft/Agent365-Samples/tree/main/python/agent-framework/sample-agent with a testing Azure account with A365 enabled, but it runs into issues when trying to generate a reply.
Error Message:
Full Stack Trace
Setup
I made some changes to the sample project attempting to get it working. Here are all the changes:
I can see in the logs that the agent was able to acquire all necessary scopes it needed but
McpToolRegistrationService(I'm guessing we probably don't have access to that).So I have this modification in
agent.pyI have also disabled
TypingIndicatorinhost_agent_server.pyas it is a bit noisy and suffers from the same error:+ self.agent_app.options.start_typing_timer = False self.agent_notification = AgentNotification(self.agent_app) self._setup_handlers()For
ChatClient, I replacedAzureOpenAIChatClientwith a dummyChatClient:In
.env.samplethere isn't aCONNECTIONS__SERVICE_CONNECTION__SETTINGS__CLIENTIDbut it seems to be required. I set it to our client ID.I am testing by sending the Agent user in my directory an email from Outlook. I am able to see my service receiving this event and mostly processed correctly by the agent in the sample project.
The above error happens when it attempts to send back a response.
Environment
uv tree --prerelease=allowI have also tested by building wheels from
mainoff this repository and still gets the same error.Please let me know if there is anything I can do / missing / misconfigured on my end. Appreciate any help. Thanks!