π OpenHands: AI-Driven Development
Re-initialize monologue agent after reset (#1478)
Engel Nystea214d1c07b2
diff --git a/agenthub/monologue_agent/agent.py b/agenthub/monologue_agent/agent.pyindex 7f7d8dd4eb..59c5510d24 100644--- a/agenthub/monologue_agent/agent.py+++ b/agenthub/monologue_agent/agent.py@@ -136,6 +136,7 @@ class MonologueAgent(Agent):Utilizes the INITIAL_THOUGHTS list to give the agent a context for it's capabilitiesand how to navigate the WORKSPACE_MOUNT_PATH_IN_SANDBOX in `config` (e.g., /workspace by default).Short circuited to return when already initialized.+ Will execute again when called after reset.Parameters:- task (str): The initial goal statement provided by the user@@ -156,6 +157,10 @@ class MonologueAgent(Agent):else:self.memory = None+ self._add_initial_thoughts(task)+ self._initialized = True++ def _add_initial_thoughts(self, task):previous_action = ''for thought in INITIAL_THOUGHTS:thought = thought.replace('$TASK', task)@@ -207,7 +212,6 @@ class MonologueAgent(Agent):else:action = AgentThinkAction(thought=thought)self._add_event(action.to_memory())- self._initialized = Truedef step(self, state: State) -> Action:"""@@ -256,8 +260,6 @@ class MonologueAgent(Agent):def reset(self) -> None:super().reset()- self.monologue = Monologue()- if config.get(ConfigType.AGENT_MEMORY_ENABLED):- self.memory = LongTermMemory()- else:- self.memory = None++ # Reset the initial monologue and memory+ self._initialized = False