Files
Geniusia_v2/docs/archive/old-summaries/FIX_WORKFLOW_MATCHING_CONFIDENCE.md
2026-03-05 00:20:25 +01:00

4.6 KiB

Fix: Confiance de Matching Trop Faible (38%)

Date: 2025-11-19
Problème: Workflows détectés mais confiance à 0.38 au lieu de > 0.80
Cause: Incompatibilité des types d'actions (mouse_click vs click)
Statut: ✓ CORRIGÉ


🐛 Problème Identifié

Symptômes dans les Logs

{"action": "workflows_matched", "num_matches": 7, "best_confidence": 0.38}
  • ✓ 7 workflows détectés
  • ✗ Confiance à 0.38 (38%)
  • ✗ Seuil requis : 0.80 (80%)
  • ✗ Aucune suggestion créée

Analyse des Workflows

Les workflows enregistrés utilisent :

{
  "action_type": "mouse_click"
}

Mais les actions capturées utilisent probablement :

{
  "action_type": "click"
}

Impact

Le WorkflowMatcher compare les types d'actions de manière stricte :

action_type_match = (
    action.get("action_type") == step.get("action_type")
)

Résultat : "mouse_click" != "click" → Pas de match sur le type → Score réduit de 40%


Solution Implémentée

Normalisation des Types d'Actions

Ajout d'une méthode _normalize_action_type() dans WorkflowMatcher :

def _normalize_action_type(self, action_type: str) -> str:
    """Normalise les types d'actions pour le matching."""
    type_mapping = {
        "mouse_click": "click",
        "mouse_move": "move",
        "key_press": "type",
        "keyboard": "type",
    }
    
    return type_mapping.get(action_type, action_type)

Modification de _calculate_step_similarity()

# Avant
action_type_match = (
    action.get("action_type") == step.get("action_type")
)

# Après
action_type = self._normalize_action_type(action.get("action_type", ""))
step_type = self._normalize_action_type(step.get("action_type", ""))

action_type_match = (action_type == step_type)

🧪 Test de la Correction

Avant

  • "mouse_click" vs "click" → Pas de match → Score -40%
  • Confiance finale : 0.38 (38%)

Après

  • "mouse_click" → normalisé → "click"
  • "click" → normalisé → "click"
  • Match réussi → Score +40%
  • Confiance attendue : ~0.78-0.85 (78-85%)

📊 Calcul du Score

Poids des Critères

  • Type d'action : 40%
  • Position : 30%
  • Fenêtre : 30%

Exemple de Calcul

Avant normalisation :

  • Type : 0% (pas de match)
  • Position : 30% (match avec tolérance)
  • Fenêtre : 30% (match)
  • Total : 60% → Avec bonus : ~0.62

Mais si plusieurs étapes ne matchent pas bien : 0.38

Après normalisation :

  • Type : 40% (match !)
  • Position : 30% (match avec tolérance)
  • Fenêtre : 30% (match)
  • Total : 100% → Avec bonus : ~1.0

Score réaliste avec petites variations de position : 0.80-0.90


🚀 Re-test

# Relancer en mode assist
python3 geniusia2/main.py --mode assist --headless

# Suivre les logs
tail -f geniusia2/data/logs/logs_$(date +%Y-%m-%d).json | grep -E "confidence|suggestion"

Résultats Attendus

{"action": "workflows_matched", "num_matches": 7, "best_confidence": 0.85}
{"action": "workflow_suggestion_created", "workflow_id": "...", "confidence": 0.85}

📝 Types d'Actions Normalisés

Type Original Type Normalisé
mouse_click click
mouse_move move
key_press type
keyboard type
Autres Inchangé

🔍 Vérification

Commandes de Debug

# Analyser les workflows
python3 debug_workflow_matching.py

# Vérifier les types d'actions dans les logs
tail -100 geniusia2/data/logs/logs_*.json | grep action_type

# Tester le matcher directement
python3 test_workflow_matcher.py

⚠️ Autres Problèmes Détectés

Erreur d'Embedding (Non Bloquante)

{"action": "context_capture_error", "error": "'VisionAnalysis' object has no attribute 'generate_embedding'"}

Impact : Empêche les suggestions d'actions classiques (FAISS), mais pas les suggestions de workflows.

Solution : À corriger séparément si besoin des suggestions classiques.


Checklist de Validation

Après le fix, vérifie que :

  • La confiance est > 0.80
  • Des suggestions sont créées
  • Les logs montrent workflow_suggestion_created
  • Le type d'action est bien normalisé

📚 Fichiers Modifiés

  • geniusia2/core/workflow_matcher.py - Ajout normalisation des types

📚 Fichiers Créés

  • debug_workflow_matching.py - Script de diagnostic
  • FIX_WORKFLOW_MATCHING_CONFIDENCE.md - Cette documentation

Fix appliqué: 2025-11-19
Testé: À re-tester
Statut: ✓ Prêt pour validation