Skip to content

Commit

Permalink
In the original orchestrator, all agents get the entire message histo…
Browse files Browse the repository at this point in the history
…ry, and the message history never gets reset. Make this the default behavior, but give the option to only pass the task to the agent and give the option to reset the agent's history after it accomplishes the task.
  • Loading branch information
merlin.von-trott committed Nov 25, 2024
1 parent 8b56549 commit a3a65ce
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions autogen/agentchat/contrib/orchestrator_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ def __init__(
max_replans: int = 3,
return_final_answer: bool = False,
user_agent: Optional[UserProxyAgent] = None,
agent_whole_history: bool = True,
reset_agent_after_task: bool = False,
**kwargs
):
super().__init__(
Expand Down Expand Up @@ -117,6 +119,8 @@ def __init__(
self._return_final_answer = return_final_answer
self._max_rounds = max_rounds
self._current_round = 0
self._agent_whole_history = agent_whole_history
self._reset_agent_after_task = reset_agent_after_task

self._team_description = ""
self._task = ""
Expand Down Expand Up @@ -399,9 +403,10 @@ def _select_next_agent(self, task: str) -> Optional[ConversableAgent]:
self._task, self._team_description, self._facts, self._plan
)

# Share new plan with all agents
for agent in self._agents:
self.send(synthesized_prompt, agent)
# Share new plan with all agents if whole history enabled
if self._agent_whole_history:
for agent in self._agents:
self.send(synthesized_prompt, agent)

logger.info(
f"(thought) New plan:\n{synthesized_prompt}"
Expand Down Expand Up @@ -466,8 +471,8 @@ def generate_reply(
# Execute through executor agent
chat_result = self.executor.initiate_chat(
recipient=next_agent,
message=last_message, # Pass full message dict
clear_history=True # Clear history each time to avoid context pollution
#message=last_message, # Pass full message dict
clear_history=self._reset_agent_after_task # Clear history based on reset_agent_after_task setting
)

if chat_result and chat_result.summary:
Expand Down

0 comments on commit a3a65ce

Please sign in to comment.