Merge pull request #3528 from SailorJoe6/Issue_#3527_studio_forever_error_loop

Fix for Issue #3527 - Studio - Never Ending Error Loop
This commit is contained in:
Victor Dibia 2024-09-27 16:21:14 -07:00 committed by GitHub
commit 8bcb720e0a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 3 deletions

View File

@ -46,7 +46,13 @@ def message_handler():
logger.info(
f"Sending message to connection_id: {message['connection_id']}. Connection ID: {socket_client_id}"
)
asyncio.run(websocket_manager.send_message(message, connection))
coro = websocket_manager.send_message(message, connection)
try:
loop = asyncio.get_running_loop()
asyncio.run_coroutine_threadsafe(coro, loop)
except RuntimeError:
asyncio.run(coro)
else:
logger.info(
f"Skipping message for connection_id: {message['connection_id']}. Connection ID: {socket_client_id}"

View File

@ -930,7 +930,7 @@ class ExtendedConversableAgent(autogen.ConversableAgent):
request_reply: Optional[bool] = None,
silent: Optional[bool] = False,
):
if self.message_processor:
if self.message_processor and not self.a_human_input_function:
self.message_processor(sender, self, message, request_reply, silent, sender_type="agent")
super().receive(message, sender, request_reply, silent)
@ -1015,7 +1015,7 @@ class ExtendedGroupChatManager(autogen.GroupChatManager):
request_reply: Optional[bool] = None,
silent: Optional[bool] = False,
):
if self.message_processor:
if self.message_processor and not self.a_human_input_function:
self.message_processor(sender, self, message, request_reply, silent, sender_type="groupchat")
super().receive(message, sender, request_reply, silent)