Skip to content

Commit

Permalink
Fix Reset of Magentic-One Orchestrator (microsoft#4394)
Browse files Browse the repository at this point in the history
* fix reset magentic one

* fix infinite reset
  • Loading branch information
husseinmozannar authored Nov 27, 2024
1 parent 531ec38 commit 6184e15
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def _create_group_chat_manager_factory(
return lambda: MagenticOneOrchestrator(
group_topic_type,
output_topic_type,
self._team_id,
participant_topic_types,
participant_descriptions,
max_turns,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json
from typing import Any, List

from autogen_core.base import MessageContext
from autogen_core.base import MessageContext, AgentId
from autogen_core.components import DefaultTopicId, Image, event, rpc
from autogen_core.components.models import (
AssistantMessage,
Expand Down Expand Up @@ -42,6 +42,7 @@ def __init__(
self,
group_topic_type: str,
output_topic_type: str,
team_id: str,
participant_topic_types: List[str],
participant_descriptions: List[str],
max_turns: int | None,
Expand All @@ -51,6 +52,7 @@ def __init__(
super().__init__(description="Group chat manager")
self._group_topic_type = group_topic_type
self._output_topic_type = output_topic_type
self._team_id = team_id
if len(participant_topic_types) != len(participant_descriptions):
raise ValueError("The number of participant topic types, agent types, and descriptions must be the same.")
if len(set(participant_topic_types)) != len(participant_topic_types):
Expand Down Expand Up @@ -164,10 +166,13 @@ async def on_unhandled_message(self, message: Any, ctx: MessageContext) -> None:

async def _reenter_inner_loop(self) -> None:
# Reset the agents
await self.publish_message(
GroupChatReset(),
topic_id=DefaultTopicId(type=self._group_topic_type),
)
for participant_topic_type in self._participant_topic_types:
await self._runtime.send_message(
GroupChatReset(),
recipient=AgentId(type=participant_topic_type, key=self._team_id),
)
# Reset the group chat manager
await self.reset()
self._message_thread.clear()

# Prepare the ledger
Expand Down
5 changes: 5 additions & 0 deletions python/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6184e15

Please sign in to comment.