From 0941b26703f632b2f2e60c0af3e1a8f74801e7ea Mon Sep 17 00:00:00 2001 From: Storm Date: Fri, 16 Jan 2026 15:05:13 +0100 Subject: [PATCH] refactor: updated how changes are passed to bdi_core_agent after merge ref: N25B-393 --- .../visual_emotion_recognition_agent.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/control_backend/agents/perception/visual_emotion_recognition_agent/visual_emotion_recognition_agent.py b/src/control_backend/agents/perception/visual_emotion_recognition_agent/visual_emotion_recognition_agent.py index a15462b..84691ae 100644 --- a/src/control_backend/agents/perception/visual_emotion_recognition_agent/visual_emotion_recognition_agent.py +++ b/src/control_backend/agents/perception/visual_emotion_recognition_agent/visual_emotion_recognition_agent.py @@ -111,25 +111,27 @@ class VisualEmotionRecognitionAgent(BaseAgent): if not emotions_to_add and not emotions_to_remove: return - emotion_beliefs = [] + emotion_beliefs_remove = [] # Remove emotions that have disappeared for emotion in emotions_to_remove: self.logger.info(f"Emotion '{emotion}' has disappeared.") try: - emotion_beliefs.append(Belief(name="emotion", arguments=[emotion], remove=True)) + emotion_beliefs_remove.append(Belief(name="emotion", arguments=[emotion], remove=True)) except ValidationError: self.logger.warning("Invalid belief for emotion removal: %s", emotion) + emotion_beliefs_add = [] # Add new emotions that have appeared for emotion in emotions_to_add: self.logger.info(f"New emotion detected: '{emotion}'") try: - emotion_beliefs.append(Belief(name="emotion", arguments=[emotion])) + emotion_beliefs_add.append(Belief(name="emotion", arguments=[emotion])) except ValidationError: self.logger.warning("Invalid belief for new emotion: %s", emotion) - beliefs_list = [b.model_dump() for b in emotion_beliefs] - payload = {"beliefs": beliefs_list} + beliefs_list_add = [b.model_dump() for b in emotion_beliefs_add] + beliefs_list_remove = [b.model_dump() for b in emotion_beliefs_remove] + payload = {"create": beliefs_list_add, "delete": beliefs_list_remove, "replace": []} message = InternalMessage( to=settings.agent_settings.bdi_core_name,