Interactive engineering lab

Early stopping from failure patterns: threshold, precision and tokens saved

Early stopping from failure patterns: threshold, precision and tokens saved. Mine failure patterns from synthetic agent traces and tune when to stop a run.

By Sandeep Belgavi · Published 2026-11-06

Synthetic fixtures computed locally. No model or production service is contacted.

Experiment workspace

Decision trace

    The question this experiment answers

    Can a failing agent run be stopped after its first K steps without killing runs that would have succeeded? Training traces from a synthetic help-desk browser agent are cut to K steps; ordered subsequences of up to three steps that occur in at least the minimum share of prefixes are mined, patterns that also occur in exactly the same traces as a longer pattern are dropped, and patterns whose failure precision is below the minimum are discarded. Each test run is matched at step K; coverage is the sum of the matched patterns' precisions divided by the library size, and the run is stopped when coverage reaches the threshold.

    Change one assumption at a time

    Start from a preset and change a single control. Lower the threshold from 0.15 to 0.10 and five successful runs are killed. Shorten K to 3 and the prefix is too short to tell a recovering success from a failing loop. Raise the minimum precision to 0.8 and the smaller library raises every match's coverage, so the same threshold stops more runs. Trace lines have the form test f: NAVIGATE CLICK CLICK_VERIFY ..., with train or test, s or f, and steps from NAVIGATE, CLICK, CLICK_VERIFY, TYPE, PARSE_FAIL, SCROLL, SUBMIT, STOP, SEARCH and READ.

    Expected outcomes

    recommended (K=5, threshold 0.15): 15 patterns, 5 runs stopped, all failures, precision 1.0, 39.5% of test tokens saved. loose (0.10): 15 stopped, 5 of them successes, 62.6% saved. short_prefix (K=3): 2 patterns, precision 0.545. long_prefix (K=8): 50 patterns, precision 1.0, 33.0% saved. strict (0.30): 1 run stopped, 9.7% saved. high_precision (minimum precision 0.8): 10 patterns and 3 successes killed. shifted_agent: the same library on an agent that fails by searching and reading in circles stops nothing. These match the companion Python model.

    Read the table and the trace

    The table lists every test run with its label, its length, how many library patterns matched its first K steps, the coverage and the decision, and the tokens the stop saved under the replay cost model, where step t costs t times the tokens per step. The trace shows the mining counts, the top library patterns with their support and precision, the reason for each test decision and a summary with precision, recall, the share of successes killed and the share of tokens saved.

    Reset and export

    Reset inputs restores the selected preset and recomputes. Export JSON downloads the inputs, every test row, the metrics, the trace and the stated limits; the library itself is in the companion Python example output.

    Limits

    A small reimplementation of the idea in arXiv 2611.04142, not the authors' code: patterns are limited to three steps and mined by enumeration rather than BIDE+, and the coverage formula is this lab's own choice because the paper's main text does not give one. Traces, step symbols and token costs are invented, so the numbers show the mechanism, not the paper's results. Thresholds must be tuned on held-out runs from the same agent, and re-tuned whenever the library, the agent or its prompt changes.

    Views are my own and do not represent any employer, past or present.