← Back to PRs

#15071: fix(browser): default fill field type to textbox when omitted

by Ayush10 open 2026-02-12 23:57 View on GitHub →
cli agents stale size: M
## Summary - `browser.act` with `kind: "fill"` fails with `"fields are required"` when field objects omit the `type` property, even though `type` is only used to differentiate checkbox/radio from text inputs - Default `type` to `"textbox"` when missing or empty across the server route, Playwright layer, and CLI validation - Update the TypeBox schema to document the expected field shape (`ref`, `type?`, `value?`) so callers know what properties to provide ## Root Cause Each field in a fill request silently requires both `ref` and `type`. When `type` is omitted (the common case for text inputs), `toStringOrEmpty(undefined)` returns `""`, the field is filtered out, and an empty array triggers the error. ## Changes - `src/browser/routes/agent.act.ts` - default `type` to `"textbox"` in fill field parsing - `src/browser/pw-tools-core.interactions.ts` - defensive null guard for `field.type` - `src/cli/browser-cli-actions-input/shared.ts` - same default in CLI-side `readFields` - `src/agents/tools/browser-tool.schema.ts` - define `ref`/`type`/`value` in field schema - `src/browser/server.agent-contract-form-layout-act-commands.test.ts` - 10 new integration tests - `src/cli/browser-cli-actions-input/shared.readFields.test.ts` - 22 new unit tests ## Test plan - [x] Existing fill test (with explicit `type`) still passes - [x] Fill without `type` defaults to textbox - [x] Mixed fields (some with type, some without) - [x] Empty/missing/non-array fields rejected - [x] Fields without `ref` filtered out - [x] Invalid entries (null, strings) filtered while valid kept - [x] Empty string and whitespace-only `type` defaults to textbox - [x] Explicit types (checkbox, radio, textarea) preserved - [x] CLI `readFields` validates and defaults correctly - [x] All 36 tests pass, 0 regressions in related suites Closes #15046 <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR fixes `browser.act` `kind: "fill"` failing when callers omit `fields[].type` by defaulting missing/empty types to `"textbox"` in the server route (`src/browser/routes/agent.act.ts`), the Playwright interaction layer (`src/browser/pw-tools-core.interactions.ts`), and the CLI input parser (`src/cli/browser-cli-actions-input/shared.ts`). It also tightens the tool schema for `fields` and adds a fairly comprehensive set of server/CLI tests covering omitted/empty types and mixed/invalid field entries. The change integrates cleanly with the existing flow: client/CLI build a `fill` request → server parses and filters fields → Playwright layer executes checkbox/radio vs text fill based on `type`. <h3>Confidence Score: 4/5</h3> - Mostly safe to merge, but schema mismatch can block valid fill requests. - Runtime changes for defaulting missing `type` are straightforward and well-covered by tests. The main remaining risk is the updated TypeBox tool schema still declaring `fields[].value` as string-only, which conflicts with the accepted runtime types (number/boolean) and can cause tool-level validation failures for valid payloads. - src/agents/tools/browser-tool.schema.ts <sub>Last reviewed commit: f8b1fa8</sub> <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs