perf(grounding): réflexe pHash-only + max_new_tokens 64

Réflexe check : déclenché uniquement si pHash change (popup inattendu),
plus d'OCR full screen systématique à chaque step. Gain ~9s/workflow.

Serveur grounding : max_new_tokens 256→64 (la réponse fait ~20 tokens).

Validé : 5+ tests consécutifs 7/7, apprentissage actif
(CR_patient en fast_exact_text 2.2s, Feuille calcul en template 83ms).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Dom
2026-04-26 03:07:35 +02:00
parent 73cea2385e
commit 90007cc7c1
2 changed files with 25 additions and 20 deletions

View File

@@ -1235,8 +1235,12 @@ Règles:
pre = self.observe() pre = self.observe()
# --- 1b. Réflexe Check : popup/dialogue inattendu ? --- # --- 1b. Réflexe Check : popup/dialogue inattendu ? ---
# Si un dialogue connu est détecté (Enregistrer sous, Oui/Non, OK, etc.) # Déclenché UNIQUEMENT si le pHash a changé de manière inattendue
# Léa le gère immédiatement AVANT de continuer le workflow. # (= un popup est probablement apparu). Sinon → 0ms, pas d'OCR.
if i > 0 and hasattr(self, '_last_post_phash') and self._last_post_phash:
_phash_distance = self._phash_distance(pre.phash, self._last_post_phash)
if _phash_distance > 10: # Changement significatif inattendu
print(f"🧠 [ORA/réflexe] pHash changé (distance={_phash_distance}) → vérification popup")
try: try:
from core.execution.input_handler import check_screen_for_patterns, handle_detected_pattern from core.execution.input_handler import check_screen_for_patterns, handle_detected_pattern
_reflex_pattern = check_screen_for_patterns() _reflex_pattern = check_screen_for_patterns()
@@ -1248,7 +1252,6 @@ Règles:
if _handled: if _handled:
print(f"✅ [ORA/réflexe] Dialogue '{_reflex_name}' géré automatiquement") print(f"✅ [ORA/réflexe] Dialogue '{_reflex_name}' géré automatiquement")
time.sleep(0.5) time.sleep(0.5)
# Re-observer après avoir géré le dialogue
pre = self.observe() pre = self.observe()
else: else:
print(f"⚠️ [ORA/réflexe] Pattern '{_reflex_name}' détecté mais non géré") print(f"⚠️ [ORA/réflexe] Pattern '{_reflex_name}' détecté mais non géré")
@@ -1307,6 +1310,8 @@ Règles:
# --- 4. Observer l'état post-action --- # --- 4. Observer l'état post-action ---
post = self.observe() post = self.observe()
# Stocker le pHash post-action pour le réflexe check du step suivant
self._last_post_phash = post.phash
# --- 5. Vérifier --- # --- 5. Vérifier ---
verification = self.verify(pre, post, decision) verification = self.verify(pre, post, decision)

View File

@@ -360,7 +360,7 @@ def ground(req: GroundRequest):
# Inference # Inference
t0 = time.time() t0 = time.time()
with torch.no_grad(): with torch.no_grad():
gen = _model.generate(**inputs, max_new_tokens=256) gen = _model.generate(**inputs, max_new_tokens=64)
infer_ms = (time.time() - t0) * 1000 infer_ms = (time.time() - t0) * 1000
# Decoder # Decoder