FailAlign: Failure-Aligned Bootstrapping for Long-Horizon HTML Based Code Generation Agents
Abstract
AbstractLLM-based web agents automate browser interactions by generating structured action sequences, yet their deployment in long-horizon tasks is hindered by fragile error propagation in noisy DOM trees. Critically, existing training paradigms rely exclusively on positive supervision from gold demonstrations, teaching models **what** is correct but never **why** plausible alternatives fail, leaving agents unable to distinguish between subtly different yet critically divergent choices. We propose **FailAlign**, a failure-aligned learning framework that systematically integrates error signals as first-class training supervision. We mine a Failure Index from model rollouts by pinpointing first-error steps, then leverage these instances across a three-stage pipeline: (i) action-grounded context compression distills verbose HTML into compact DOM snippets; (ii) hard-negative DPO pairs gold actions with semantically similar incorrect alternatives to sharpen decision boundaries; (iii) trajectory-level GRPO mitigates error cascades by re-simulating corrected trajectories. On Mind2Web with Qwen3-32B, FailAlign achieves **49.7% SSR** and **5.6% SR**, surpassing models 15× larger (Qwen3-Coder-480B: 37.0% SSR) and commercial systems (Claude Opus-4.5: 39.4% SSR), validating the efficacy of learning from failures.