Skip to content

fix(browser): accept legacy flattened act params#31359

Merged
vincentkoc merged 7 commits intoopenclaw:mainfrom
vincentkoc:vincentkoc-code/fix-cdp-act-legacy-15120
Mar 2, 2026
Merged

fix(browser): accept legacy flattened act params#31359
vincentkoc merged 7 commits intoopenclaw:mainfrom
vincentkoc:vincentkoc-code/fix-cdp-act-legacy-15120

Conversation

@vincentkoc
Copy link
Member

Summary

  • Problem: browser tool rejected legacy action="act" calls that send kind/ref/text/... at the top level and returned request required.
  • Why it matters: Existing prompts/agents and direct tool users following older examples cannot perform click/type/fill actions.
  • What changed: Added backward-compatible act request parsing so both request={...} and flattened act params work.
  • What did NOT change (scope boundary): /act route validation and Playwright action execution semantics remain unchanged.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

User-visible / Behavior Changes

  • browser(action="act", kind="type", ref="...", text="...", targetId="...") now works again.
  • request={...} remains supported and still takes precedence when both styles are provided.

Security Impact (required)

  • New permissions/capabilities? (No)
  • Secrets/tokens handling changed? (No)
  • New/changed network calls? (No)
  • Command/tool execution surface changed? (No)
  • Data access scope changed? (No)
  • If any Yes, explain risk + mitigation:

Repro + Verification

Environment

  • OS: macOS
  • Runtime/container: Node 22 + pnpm
  • Model/provider: n/a
  • Integration/channel (if any): Browser tool
  • Relevant config (redacted): default browser config

Steps

  1. Execute browser tool with action="act" and flattened params (no request).
  2. Verify call is forwarded to browser act client instead of failing with request required.
  3. Execute with both request and flattened fields; verify request is used.

Expected

  • Flattened and nested request forms both work.

Actual

  • Verified locally with new regression tests.

Evidence

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

What you personally verified (not just CI), and how:

  • Verified scenarios: Ran pnpm vitest run src/agents/tools/browser-tool.test.ts including new flattened compatibility tests.
  • Edge cases checked: Request precedence when both styles are supplied.
  • What you did not verify: End-to-end live browser session in a real channel.

Compatibility / Migration

  • Backward compatible? (Yes)
  • Config/env changes? (No)
  • Migration needed? (No)
  • If yes, exact upgrade steps:

Failure Recovery (if this breaks)

  • How to disable/revert this change quickly: Revert this PR.
  • Files/config to restore: src/agents/tools/browser-tool.ts, src/agents/tools/browser-tool.schema.ts.
  • Known bad symptoms reviewers should watch for: Unexpected act request shapes being forwarded without route-side validation errors.

Risks and Mitigations

  • Risk: Accepting flattened keys could forward malformed combinations.
    • Mitigation: /act endpoint still performs strict per-kind validation and returns explicit 400 errors.

@openclaw-barnacle openclaw-barnacle bot added agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Mar 2, 2026
@vincentkoc vincentkoc marked this pull request as ready for review March 2, 2026 06:34
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 2, 2026

Greptile Summary

This PR restores backward compatibility for legacy browser tool callers that pass act parameters (kind, ref, text, etc.) at the top level instead of inside a request={...} object. The change is tightly scoped: a new readActRequestParam helper in browser-tool.ts first checks for a request object (taking precedence) and falls back to constructing one from the well-defined LEGACY_BROWSER_ACT_REQUEST_KEYS list. The BrowserToolSchema is widened to accept the same fields so they are not stripped before reaching the tool handler. The /act backend route and Playwright execution semantics are untouched.

Key observations:

  • The request-takes-precedence invariant is correctly implemented and tested.
  • Two regression tests cover the primary cases: flattened-only and mixed (flattened + request).
  • delayMs, loadState, selector, url, and timeoutMs appear in LEGACY_BROWSER_ACT_REQUEST_KEYS and BrowserToolSchema but are absent from BrowserActSchema. Callers using the request={...} path cannot explicitly include these fields without hitting a TypeBox mismatch; if the backend accepts them, they should be added to BrowserActSchema for full parity.
  • No new security surface is introduced; field forwarding was already possible via the request path, and the /act endpoint still validates per-kind.

Confidence Score: 4/5

  • This PR is safe to merge; the fix is backward-compatible and the /act backend still enforces per-kind validation.
  • The implementation is clean, well-scoped, and the two new regression tests validate the primary behavioral contracts. The only friction is a minor schema inconsistency where delayMs, loadState, selector, url, and timeoutMs appear in the legacy key list and top-level schema but not in BrowserActSchema, leaving a small parity gap for callers using the request={...} path. This does not affect runtime correctness since backend validation is the authoritative layer.
  • src/agents/tools/browser-tool.schema.ts — the BrowserActSchema definition is missing several fields that LEGACY_BROWSER_ACT_REQUEST_KEYS forwards (delayMs, loadState, selector, url, timeoutMs).

Last reviewed commit: 46f257e

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

3 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@vincentkoc
Copy link
Member Author

Addressed in 8fe239d.

I added the missing nested request schema fields in BrowserActSchema for parity with the flattened path: delayMs, selector, url, loadState, and timeoutMs.

@vincentkoc vincentkoc merged commit e055afd into openclaw:main Mar 2, 2026
10 checks passed
robertchang-ga pushed a commit to robertchang-ga/openclaw that referenced this pull request Mar 2, 2026
* fix(browser-tool): accept flattened act params

* schema(browser-tool): add flattened act fields

* test(browser-tool): cover flattened act compatibility

* changelog: note browser act compatibility fix

* fix(schema): align browser act request fields
hanqizheng pushed a commit to hanqizheng/openclaw that referenced this pull request Mar 2, 2026
* fix(browser-tool): accept flattened act params

* schema(browser-tool): add flattened act fields

* test(browser-tool): cover flattened act compatibility

* changelog: note browser act compatibility fix

* fix(schema): align browser act request fields
execute008 pushed a commit to execute008/openclaw that referenced this pull request Mar 2, 2026
* fix(browser-tool): accept flattened act params

* schema(browser-tool): add flattened act fields

* test(browser-tool): cover flattened act compatibility

* changelog: note browser act compatibility fix

* fix(schema): align browser act request fields
dawi369 pushed a commit to dawi369/davis that referenced this pull request Mar 3, 2026
* fix(browser-tool): accept flattened act params

* schema(browser-tool): add flattened act fields

* test(browser-tool): cover flattened act compatibility

* changelog: note browser act compatibility fix

* fix(schema): align browser act request fields
OWALabuy pushed a commit to kcinzgg/openclaw that referenced this pull request Mar 4, 2026
* fix(browser-tool): accept flattened act params

* schema(browser-tool): add flattened act fields

* test(browser-tool): cover flattened act compatibility

* changelog: note browser act compatibility fix

* fix(schema): align browser act request fields
zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
* fix(browser-tool): accept flattened act params

* schema(browser-tool): add flattened act fields

* test(browser-tool): cover flattened act compatibility

* changelog: note browser act compatibility fix

* fix(schema): align browser act request fields
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CDP Browser Control - act commands failing with 'request required'

1 participant