diff --git a/GramAddict/core/goap.py b/GramAddict/core/goap.py index ecf3ec9..c10addf 100644 --- a/GramAddict/core/goap.py +++ b/GramAddict/core/goap.py @@ -381,7 +381,8 @@ class GoalExecutor: else: # For interactions (like, follow) or unknown goals, use XML delta + semantic verify if ui_changed: - verification = engine.verify_success(action, post_xml, device=self.device) + score = best_node.get("score", 0.0) if best_node else 0.0 + verification = engine.verify_success(action, post_xml, device=self.device, confidence=score) if verification is True: action_success = True logger.info(f"✅ [GOAP Step] Interaction '{action}' successful.") diff --git a/GramAddict/core/perception/action_memory.py b/GramAddict/core/perception/action_memory.py index 856055d..1a2c37a 100644 --- a/GramAddict/core/perception/action_memory.py +++ b/GramAddict/core/perception/action_memory.py @@ -77,7 +77,7 @@ class ActionMemory: self._last_click_context = None - def verify_success(self, intent: str, pre_click_xml: str, post_click_xml: str, device=None) -> Optional[bool]: + def verify_success(self, intent: str, pre_click_xml: str, post_click_xml: str, device=None, confidence: float = 0.0) -> Optional[bool]: """ Structural and Visual verification: Did the UI actually change after the click? """ @@ -91,8 +91,9 @@ class ActionMemory: # State toggles (like, save, follow) rarely change XML length predictably state_toggles = ["like", "save", "follow", "heart"] if any(t in intent.lower() for t in state_toggles): - if device: - logger.info(f"👁️ [ActionMemory] Handing over verification for '{intent}' to VLM visual analysis...") + # If we are highly confident (e.g. pulled from Qdrant memory), bypass heavy VLM + if device and confidence < 0.95: + logger.info(f"👁️ [ActionMemory] Confidence ({confidence:.2f}) < 0.95. Handing over verification for '{intent}' to VLM visual analysis...") from GramAddict.core.perception.semantic_evaluator import SemanticEvaluator evaluator = SemanticEvaluator() diff --git a/GramAddict/core/telepathic_engine.py b/GramAddict/core/telepathic_engine.py index 459f0df..16498d3 100644 --- a/GramAddict/core/telepathic_engine.py +++ b/GramAddict/core/telepathic_engine.py @@ -180,11 +180,11 @@ class TelepathicEngine: def decay_click(self, intent: str = None): self._memory.reject_click(intent) # Alias to reject - def verify_success(self, intent: str, post_click_xml: str, device=None) -> bool: + def verify_success(self, intent: str, post_click_xml: str, device=None, confidence: float = 0.0) -> bool: pre_click_xml = "" if self._memory._last_click_context: pre_click_xml = self._memory._last_click_context.get("xml_context", "") - return self._memory.verify_success(intent, pre_click_xml, post_click_xml, device=device) + return self._memory.verify_success(intent, pre_click_xml, post_click_xml, device=device, confidence=confidence) # ────────────────────────────────────────────── # Semantic Evaluator Delegation