fix(agent): P0.6 guard human corrections

This commit is contained in:
Dom
2026-05-24 21:07:12 +02:00
parent ad24d16d83
commit b1b32187ba
4 changed files with 150 additions and 8 deletions

View File

@@ -194,8 +194,33 @@ class ReplayLearner:
or target_spec.get("expected_window_before", "")
or (target_spec.get("context_hints") or {}).get("window_title", "")
)
x_pct = correction.get("x_pct", 0.0)
y_pct = correction.get("y_pct", 0.0)
x_pct = correction.get("x_pct")
y_pct = correction.get("y_pct")
last_click = correction.get("last_click")
if (x_pct is None or y_pct is None) and isinstance(last_click, dict):
x_pct = last_click.get("x_pct")
y_pct = last_click.get("y_pct")
try:
x_pct_f = float(x_pct)
y_pct_f = float(y_pct)
except (TypeError, ValueError):
logger.warning(
"[APPRENTISSAGE] Correction humaine non persistée : "
"aucune coordonnée clic exploitable pour '%s'",
by_text,
)
return
if not (0.0 < x_pct_f <= 1.0 and 0.0 < y_pct_f <= 1.0):
logger.warning(
"[APPRENTISSAGE] Correction humaine non persistée : "
"coordonnées hors bornes pour '%s' (%.4f, %.4f)",
by_text,
x_pct_f,
y_pct_f,
)
return
# Enregistrer dans le JSONL d'apprentissage
outcome = ActionOutcome(
@@ -218,8 +243,8 @@ class ReplayLearner:
stored = memory_record_success(
window_title=window_title,
target_spec=target_spec,
x_pct=float(x_pct),
y_pct=float(y_pct),
x_pct=x_pct_f,
y_pct=y_pct_f,
method="human_supervised",
confidence=1.0,
)