Skip to content

fix(browser): fit reflex dropdowns by offered options, pin the 512 total - #36729

Merged
bolichen97 merged 1 commit into
mainfrom
fix/32573-reflex-target-fit
Nov 18, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/32573-reflex-target-fit

Conversation

@bolichen97

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A reflex decision request offers every dropdown whose offered options fit in its target head, and the test that guards Laya's option limits fails as soon as a cap that sizes the request is raised past them.

The browser reflex loop asks the model to pick a target from a head of at most 100 options, and a dropdown that does not fit is skipped whole. The fit check counted all of a dropdown's options, including the ones the loop had already withdrawn or judged risky and would never offer. So with 90 options in the head, a 50-option dropdown with 45 options withdrawn was hidden, although its 5 remaining options fit.

Separately, a whole request must stay within Laya's 100 options per question and 512 per request. That held only because separate caps add up to 465, and the test that checked it used a fixed 40 keys and 20 values, so it would keep passing if any cap were raised.

Why it matters

On a dense page, such as a long form, the model can lose a dropdown it could still use, so the loop cannot reach that choice and ends early. And if someone raises a cap (more moves, more values, bigger heads), Laya starts refusing every reflex request again, the failure #32246 fixed, while the test stays green.

Not a goal

  • Changing any cap (MAX_ACTIONS, the values cap, TARGET_CAP) or Laya's limits.
  • Enforcing the 512 total at request time: the caps bound it and the test pins it.
  • Changing which moves are withdrawn or judged risky.

What changed (motivation → approach → change)

Gap Cause Change
A dropdown that fits is hidden the fit check ran before the offer filter reflex_space.build filters a row's options through offer first, then checks the fit on what will be offered; a row that still does not fit is skipped whole and its new moves are not kept
The 512 total is not pinned the test built fixed inputs the values cap is named MAX_VALUES in reflex.py, and the largest-request test builds the largest request the caps allow and checks its exact size against them

The fit check now sees the same options the request sends. An option the loop withdrew, or judged too risky to offer, takes no room, so a mostly withdrawn dropdown on a long form stays reachable. An element the loop already knows is still refreshed before the filter, and its risk judged again when its words changed; that now also happens in a row the head then skips, which is safe because an answer is checked against the guard its own request saw.

The largest-request test asks for MAX_ACTIONS moves, WAIT, every targeted operation and MAX_VALUES values, on a page that fills every target head to TARGET_CAP. It checks that the request has exactly the sizes those caps allow, then that it fits Laya's 100 and 512. Raising any cap grows the request, and past Laya's limits the test fails. The reflex Request row in docs/system-specs/modules/browser.md says the fit counts only offered options.

Backwards compatibility

Compatible: a request gains only the dropdowns whose offered options fit; every cap, the request's shape and the 465-option bound are unchanged.

Removes nothing: the values cap keeps its value of 20 under a name, and the fit check only lets through rows the old check skipped.

Tests

  • test_a_dropdown_fits_by_the_options_it_offers (new): with 90 options in the head, a dropdown with 45 of its 50 options withdrawn offers its other 5; the next dropdown, which does not fit, adds no moves to the loop's memory.
  • test_the_largest_request_keeps_within_laya_s_option_limits (rewritten): builds the request from MAX_ACTIONS, MAX_VALUES, TARGET_CAP and TARGETED, asserts the exact sizes, then Laya's 100 per question and 512 per request.
  • test_a_dropdown_that_does_not_fit_does_not_hide_the_ones_after_it: unchanged behaviour, now using the shared _dropdown helper.

Proof: PROVEN test/test_browser_reflex.py::test_a_dropdown_fits_by_the_options_it_offers (head 3cf0c37)

Determinism: test/test_browser_reflex.py (49 tests) passed 20 runs in a row with -n0, once with -n 4 --dist loadgroup, and once in a shuffled order (seed 30892, node ids passed in that order).

Manual verification

Reproduced and smoke-tested on Linux (Ubuntu 24.04, x86_64). The product path needs a live decision provider, but the request is built by pure code, so the runs drive reflex_space.build and the largest-request test directly.

  • Before: with 90 options in the select head and 45 of a 50-option dropdown's options withdrawn, build offered none of that dropdown (e3 offered: []). With MAX_ACTIONS raised to 90, or the values cap raised to 70, the old largest-request test still passed although the request would carry 515 options.
  • After: the same table offers e3:45 to e3:49 (95 options) and the next 50-option dropdown is skipped whole with none of its moves kept. The rewritten test fails with MAX_ACTIONS = 90 and with MAX_VALUES = 70 (515 > 512), passes with MAX_ACTIONS = 50 (475) and unchanged (465).
  • Nearby: all 49 tests in test/test_browser_reflex.py pass, including the unchanged dropdown-skip test.

Screenshots / video

N/A — no frontend or user-visible UI change.

Related Issues

Closes #32573

Builds on #32246.

Sibling sweep

Swept: git grep -nE "TARGET_CAP|MAX_OPTIONS|_space.build" -- src/kiro_crew/browser_harness/
Sibling: src/kiro_crew/browser_harness/decide.py:152 -- not affected -- _prefilter keeps the best-matching options and filters nothing after its count

Pattern harvest

Rule candidate: review-prompt
Pattern: a test that pins a limit derived from several caps builds its inputs from literals instead of those caps, so raising a cap keeps it green

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

A reflex target head holds at most TARGET_CAP options, and a dropdown
that does not fit is skipped whole. The fit check counted every option
the row has, before the offer filter dropped the risky and withdrawn
ones, so a dense page could hide a dropdown whose few offered options
would have fit. The check now counts only what the row will offer; a
row that still does not fit is skipped whole and its new moves are not
kept.

A whole request must stay within Laya's 100 options per Choice and 512
per request. That held only because separate constants add up (40
moves, WAIT and 4 targeted operations, 20 values, 4 heads of 100), and
the test that checked it built a fixed 40 keys and 20 values, so it
kept passing whatever the caps said. The values cap is named
(MAX_VALUES) and the test builds the largest request the caps allow,
from MAX_ACTIONS, MAX_VALUES, TARGET_CAP and TARGETED, so raising any
of them past Laya's limits turns it red.

Closes #32573
@github-actions

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 3cf0c378feae6ca36e4740c2ee746bb0436c02f4 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 3cf0c378feae6ca36e4740c2ee746bb0436c02f4 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks. The fit check now counts only the options the loop will offer, which fixes the cause. The rewritten test is built from the caps themselves, so raising any cap past Laya's limits turns it red.

What this change ships

Inventory (5 items) — 4 justified

Intent: let the reflex loop offer every dropdown whose offerable options fit the 100-option head, and make the 512-total test fail when a cap is raised past Laya's limits. This is a FIX.

  1. A dropdown with mostly withdrawn or risky options now appears in the target head when its offered options fit — justified
  2. The moves of a dropdown row skipped for not fitting are no longer remembered for later steps — justified
  3. A row the head skips now still refreshes known elements and re-judges their risk — rides along, declared, harm-free
  4. The values cap of 20 is now named MAX_VALUES and parse reads it — justified
  5. The largest-request test builds its inputs from MAX_ACTIONS, MAX_VALUES, TARGET_CAP and TARGETED, and checks the exact sizes — justified

[FIRST-PRINCIPLES-REVIEWED] 3cf0c37

Description read

[DESCRIPTION-READ] 5fc4f45223c2723afb0a194f4e23f4bab69d61391f0a4e0d449efac093c98353

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 3cf0c378feae6ca36e4740c2ee746bb0436c02f4 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: the fit check now counts the same options the request sends, and the limit test is built from the caps themselves.

Notes

  • When offer refuses a new move, that move is no longer stored in known, even in a row that fits. This is safe today because offer depends only on the move's own risky value and the dropped set, which is keyed by move. If offer ever starts depending on what known holds, this assumption breaks.

[DESIGN-REVIEWED] 3cf0c37

Description read

[DESCRIPTION-READ] 3239b53ee43aae3ab14f38e4f358de6fa24470f93153b58bfa30402bc41c7316

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 3cf0c378feae6ca36e4740c2ee746bb0436c02f4 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 3cf0c37

Verdict parsed from the review's SHA-scoped output markers for commit 3cf0c378feae6ca36e4740c2ee746bb0436c02f4.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 3cf0c378feae6ca36e4740c2ee746bb0436c02f4 false-positive: <reason, 20 to 500 characters>

@github-actions

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 3cf0c378feae6ca36e4740c2ee746bb0436c02f4 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 3cf0c37

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 3cf0c378feae6ca36e4740c2ee746bb0436c02f4 false-positive: <reason, 20 to 500 characters>

@bolichen97
bolichen97 enabled auto-merge (squash) November 13, 2026 16:21
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 13, 2026

@buluoray buluoray left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve on 3cf0c37. The reflex loop now checks whether a dropdown fits its target head by counting only the options it will actually offer, so a mostly withdrawn dropdown on a long form stays reachable. A dropdown that still does not fit is skipped whole and none of its new moves are kept. The largest-request test is now built from the caps themselves, so raising the moves cap or the values cap past 512 options turns it red. Each guard has a test that fails without it. Nothing reads page text into a selector: a select target is still a ref plus an integer option index, and the executor re-checks the guard before input. One backend shard lost its runner and produced no test result, so the coverage gate failed closed; that shard needs a rerun before merge. Decisive lines: src/kiro_crew/browser_harness/reflex_space.py:154-173, test/test_browser_reflex.py:700-710, test/test_browser_reflex.py:667-698

@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97] The one blocking readiness item on 3cf0c378feae belongs to main, not to this PR. Backend Tests (3.12, 7) ended while Run tests (shard 7/8) was still in progress, with "The self-hosted runner lost communication with the server"; Coverage Gate then failed closed on it, and PR Readiness folds both.

A red that is also red on main is not pushed over and not overridden: this PR waits for that fix and rebases onto it when it lands. Shard 7 already carries several reports from today, so the job is not re-run again either. Everything else on this head is green: Design and First Principles PASS, no blocking review findings, no unresolved threads, approval recorded, and auto-merge is armed.

@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Nov 18, 2026
@bolichen97
bolichen97 merged commit 458753b into main Nov 18, 2026
151 of 154 checks passed
@github-actions github-actions Bot added the readiness: passed Eligible automated validation passed for the current revision label Nov 18, 2026
@bolichen97
bolichen97 deleted the fix/32573-reflex-target-fit branch November 18, 2026 22:38
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

browser reflex: target-head cap counts withdrawn options, and the 512-option request total is not pinned against its inputs

2 participants