fix(agent): prevent duplicate form submissions

Merged
KD
5d ago
+778-52

What and why

  • In the reported run, agent.act clicked Update Product twice after the first click left the screen unchanged. The built-in agent now checks the current screen before repeating the same commit by any route, including Enter. It retries when the screen shows the first press did not commit or when the tap only dismissed the keyboard.
  • While a save is in progress, consecutive observe and screenshot calls have their own limits. A change to the listing, location, or tabs resets the unchanged-look count. The step still needs visible evidence to pass.
  • e2e explore keeps its charter to retry and revisit on purpose.
flowchart LR
  A[Press the commit control] --> B{What does the screen show?}
  B -->|Still saving| C[Observe again]
  C --> B
  B -->|Commit failed or tap only closed keyboard| D[Retry when ready]
  B -->|Saved or outcome unclear| E[Run the requested check and conclude]

Issue

Closes ENG-932

Verified

Ran it locally: yes

  • pnpm --filter @e2e-dev/testbed test ran the default suite with the rebuilt packages and Chromium.
Test Files  48 passed (48)
     Tests  595 passed | 1 skipped (596)
  • The shipping run replayed 26 of 34 web agent tests with CI=1 and --strict-cache. The other eight failed when a cache miss or handoff needed an authenticated model call.

  • The implementation session ran the live product-form repro below. The main column used the same build with the prompt rules from 309f6907. Later branch runs covered toast, silent, late, blind, and slow saves.

Product-form repromain rulesthis branch
Luna Fast, blind save9 of 11 runs double-submitted, with 2 to 4 submissions each1 of 11 on the first version, then zero duplicate submissions across dozens of runs and all variants
Sonnet 5.5Zero duplicate submissionsZero duplicate submissions
Luna Fast, 8-second save0 of 3 passed with the old three-look warning2 of 3, then 5 of 5, 4 of 4, and 3 of 3 passed after the wait-limit changes
  • In the same live session, both models passed the testbed todo flow that asks for two commits in one step. The two live web benchmark pairs passed 34 of 34 on each side. The implementation session also recorded 34 of 34 in strict-cache replay with the same cache modes as the main rules.
  • The shipping run had no AI Gateway key, so it used those earlier runs for live model verification.

bench-ab: 309f6907 (merge base with 309f6907) vs 148163ae

apps/web-benchmark: e2e run --workers 1 --config e2e.agent.config.ts tests-agent --no-cache. 2 pairs in random order, stopped at the 2-pair budget, unresolved. Threshold ±5% and 10 ms. darwin arm64, Apple M5 Pro x18, Node 26.13.1, load 2.5.

Behavior

These tests are left out of the timing rows below.

  • unstable on base (2 different step sequences) tests-agent/planted-bugs.e2e.ts › wishlist: a judgment catches the lost saved items (web)

Timings

Every row but the process wall clock covers the 33 tests whose behavior matched.

Metricbase median (IQR)head median (IQR)change (95% CI)verdict
wall (process)269.26 s (256.80 s-281.72 s)251.30 s (249.91 s-252.68 s)-6.3% (-15.5% to +4.0%)unresolved
suite (sum of attempts)260.48 s (249.03 s-271.93 s)244.50 s (243.25 s-245.75 s)-5.8% (-14.6% to +4.0%)unresolved
observe (events)29.12 s (26.84 s-31.41 s)28.39 s (27.98 s-28.79 s)-1.3% (-18.2% to +18.9%)unresolved
action (events)21.52 s (21.33 s-21.70 s)24.94 s (23.20 s-26.68 s)+14.8% (-1.9% to +34.4%)unresolved
model (events)254.28 s (242.86 s-265.71 s)238.12 s (236.86 s-239.38 s)-6.0% (-15.0% to +4.0%)unresolved
step agent.act253.55 s (242.16 s-264.94 s)237.71 s (236.42 s-238.99 s)-5.9% (-14.9% to +4.1%)unresolved
step agent.assert3.86 s (3.81 s-3.90 s)3.61 s (3.58 s-3.64 s)-6.4% (-6.7% to -6.1%)faster
step app.open2.45 s (2.43 s-2.47 s)2.63 s (2.63 s-2.63 s)+7.2% (+5.3% to +9.2%)slower
step expect.toHaveText163 ms (156 ms-169 ms)134 ms (128 ms-140 ms)-17.6% (-18.1% to -17.0%)faster
step expect.toContainText5 ms (4 ms-5 ms)2 ms (2 ms-2 ms)-52.9% (-66.7% to -33.3%)same, under the floor
step expect.toHaveURL1 ms (1 ms-1 ms)1 ms (0 ms-1 ms)0.0% (0.0% to 0.0%)same

Counters

Counterbasehead
events engine96-10998-99
events model123-132126-129
events observation605-613607-608
events policy7-88
model calls123-132126-129
model tokens668805-721520733528-752821
observed bytes1124639-11290771111450-1126446
observed nodes34643-3474234212-34691
steps103-104103
Tests outside the threshold: 14 of 33
Testbase median (IQR)head median (IQR)change (95% CI)verdict
tests-agent/control-inventory.e2e.ts › control inventory › a right-click opens the file menu and Rename renames the file (web)13.20 s (13.19 s-13.20 s)11.43 s (11.02 s-11.84 s)-13.6% (-19.7% to -7.0%)faster
tests-agent/control-inventory.e2e.ts › control inventory › back returns from the details view to the inventory (web)4.94 s (4.89 s-5.00 s)4.49 s (4.46 s-4.52 s)-9.1% (-9.9% to -8.4%)faster
tests-agent/control-inventory.e2e.ts › control inventory › check picks a radio the pick replaces with its summary (web)3.90 s (3.79 s-4.02 s)2.72 s (2.68 s-2.77 s)-30.2% (-31.9% to -28.4%)faster
tests-agent/control-inventory.e2e.ts › control inventory › upload attaches the named project files (web)3.61 s (3.44 s-3.77 s)2.89 s (2.82 s-2.97 s)-19.5% (-30.1% to -7.4%)faster
tests-agent/planted-bugs.e2e.ts › cart totals: a judgment catches the stale order summary (web)5.15 s (5.07 s-5.23 s)6.48 s (6.34 s-6.62 s)+25.6% (+16.6% to +35.4%)slower
tests-agent/scenarios.e2e.ts › act completes debounced-search (web)7.48 s (7.22 s-7.73 s)6.31 s (6.16 s-6.46 s)-15.5% (-17.1% to -13.8%)faster
tests-agent/scenarios.e2e.ts › act completes drag-and-drop (web)5.73 s (5.61 s-5.85 s)5.10 s (5.06 s-5.13 s)-11.0% (-13.4% to -8.4%)faster
tests-agent/scenarios.e2e.ts › act completes infinite-scroll (web)9.47 s (9.23 s-9.70 s)7.85 s (7.69 s-8.01 s)-17.0% (-24.2% to -9.2%)faster
tests-agent/scenarios.e2e.ts › act completes kanban-board (web)7.68 s (7.63 s-7.73 s)6.29 s (6.13 s-6.45 s)-18.2% (-21.3% to -15.0%)faster
tests-agent/scenarios.e2e.ts › act completes overlay-trap (web)6.90 s (6.80 s-6.99 s)5.33 s (5.23 s-5.43 s)-22.7% (-23.4% to -22.0%)faster
tests-agent/scenarios.e2e.ts › act completes stale-dom (web)7.51 s (7.44 s-7.58 s)6.59 s (6.47 s-6.71 s)-12.3% (-13.8% to -10.8%)faster
tests-agent/scenarios.e2e.ts › act completes sticky-chrome (web)8.68 s (8.31 s-9.06 s)7.72 s (7.59 s-7.86 s)-10.8% (-15.2% to -6.1%)faster
tests-agent/scenarios.e2e.ts › act filters the list and the URL carries the filter (web)3.44 s (3.41 s-3.46 s)3.05 s (3.04 s-3.06 s)-11.3% (-12.1% to -10.5%)faster
tests-agent/unique-cache.e2e.ts › act adds an address with a run-unique label (web)5.61 s (5.39 s-5.84 s)4.75 s (4.68 s-4.82 s)-15.2% (-19.4% to -10.7%)faster

With 33 tests compared at 95%, about 1.7 could land outside by chance.

The fresh reviewer found that a location containing part of a heading could suppress a wait reset. The guard now matches the renderer's status at the end of the heading, with regression coverage for tree recovery and truncated listings. The earlier review kept substring assertions for prompt text because they follow the test file's convention and the live runs check behavior.

🤖 Generated with Claude Code