#15071: fix(browser): default fill field type to textbox when omitted
cli
agents
stale
size: M
Cluster:
Error Handling Improvements
## 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
#14728: fix(browser): add targetUrl description and improve error messages ...
by lailoo · 2026-02-12
73.9%
#21027: fix(tests): resolve TypeScript type errors in CLI test files
by kittipond2365 · 2026-02-19
73.8%
#10367: CLI/Ops: resilient browser fill + failover hardening + operations t...
by cluster2600 · 2026-02-06
73.6%
#12642: feat(tools): typed tool schemas for xAI/Grok compatibility
by 2nd-ren · 2026-02-09
73.5%
#23075: fix(browser): merge top-level ref/targetId into act request body
by Remixer33 · 2026-02-22
73.1%
#23772: fix(ci): unblock repo-wide check gate type regressions
by SmithLabsLLC · 2026-02-22
72.7%
#23668: fix: distinguish browser validation errors from connectivity failures
by davidemanuelDEV · 2026-02-22
72.5%
#14197: fix(security): harden browser API auth, token comparisons, and hook...
by leecarollyn-gif · 2026-02-11
71.9%
#12378: feat: expose download and waitForDownload actions in browser agent ...
by vabole · 2026-02-09
71.8%
#15999: fix: handle null/undefined in activity feed filters
by pamnlambert · 2026-02-14
71.1%