diff --git a/src/control_backend/agents/bdi/bdi_program_manager.py b/src/control_backend/agents/bdi/bdi_program_manager.py index 7899e3c..f50fcf0 100644 --- a/src/control_backend/agents/bdi/bdi_program_manager.py +++ b/src/control_backend/agents/bdi/bdi_program_manager.py @@ -212,7 +212,6 @@ class BDIProgramManager(BaseAgent): continue self._initialize_internal_state(program) - await self._send_program_to_user_interrupt(program) await self._send_clear_llm_history() diff --git a/src/control_backend/agents/user_interrupt/user_interrupt_agent.py b/src/control_backend/agents/user_interrupt/user_interrupt_agent.py index 925e10e..462d94f 100644 --- a/src/control_backend/agents/user_interrupt/user_interrupt_agent.py +++ b/src/control_backend/agents/user_interrupt/user_interrupt_agent.py @@ -1,4 +1,3 @@ -import asyncio import json import zmq @@ -151,6 +150,15 @@ class UserInterruptAgent(BaseAgent): payload = {"type": "phase_update", "phase_id": new_phase_id} await self._send_experiment_update(payload) + case "goal_start": + goal_name = msg.body + ui_id = self._goal_reverse_map.get(goal_name) + if ui_id: + payload = {"type": "goal_update", "id": ui_id, "active": True} + await self._send_experiment_update(payload) + self.logger.info(f"UI Update: Goal {goal_name} started (ID: {ui_id})") + else: + self.logger.warning(f"Goal start received for unknown goal : {goal_name}") case "active_norms_update": asl_slugs = [s.strip() for s in msg.body.split(";")] @@ -159,23 +167,6 @@ class UserInterruptAgent(BaseAgent): case _: self.logger.debug(f"Received internal message on unhandled thread: {msg.thread}") - # moet weg!!!!! - async def test_sending_behaviour(self): - self.logger.info("Starting simple test sending behaviour...") - - while True: - try: - test_data = {"type": "heartbeat", "status": "ok"} - - await self._send_experiment_update(test_data) - - except zmq.ZMQError as ze: - self.logger.error(f"ZMQ error: {ze}") - except Exception as e: - self.logger.error(f"Error: {e}") - - await asyncio.sleep(2) - async def _broadcast_cond_norms(self, active_slugs: list[str]): """ Sends the current state of all conditional norms to the UI. @@ -209,6 +200,10 @@ class UserInterruptAgent(BaseAgent): for goal in phase.goals: self._goal_map[str(goal.id)] = AgentSpeakGenerator.slugify(goal) + self._goal_reverse_map[AgentSpeakGenerator.slugify(goal)] = str(goal.id) + + for goal, id in self._goal_reverse_map.items(): + self.logger.debug(f"Goal mapping: UI ID {goal} -> {id}") for norm in phase.norms: if not isinstance(norm, BasicNorm):