openclaw - 💡(How to fix) Fix [Bug]: Browser act tool fails with OpenAI models — ref placed at top level instead of inside request object

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

When using OpenAI models (gpt-4o-mini, gpt-4.1-mini) via OpenRouter, browser act calls consistently fail with "type requires ref or selector". The model places ref at the request top level following the tool schema, but normalizeActRequest() in routes-BdSVcmd0.js reads ref from body which corresponds to the nested request inner object. Anthropic Claude models (Sonnet) work because they generate the nested request: { kind, ref, text } format natively.

Error Message

  1. Observe error: click requires ref or selector normalizeActRequest(body) receives body = request inner object, which does not contain ref (it was placed at the top level by the model). Error thrown at: if (!ref && !selector) throw new Error("type requires ref or selector");

Root Cause

When using OpenAI models (gpt-4o-mini, gpt-4.1-mini) via OpenRouter, browser act calls consistently fail with "type requires ref or selector". The model places ref at the request top level following the tool schema, but normalizeActRequest() in routes-BdSVcmd0.js reads ref from body which corresponds to the nested request inner object. Anthropic Claude models (Sonnet) work because they generate the nested request: { kind, ref, text } format natively.

Fix Action

Fix / Workaround

Workaround patch (applied locally, confirmed working):

// In /act route handler, after readBody(req):
if (body.request && typeof body.request === "object") {
    if (!body.request.ref && body.ref) body.request.ref = body.ref;
    if (!body.request.selector && body.selector) body.request.selector = body.selector;
}

Code Example

case "type": {
    const ref = toStringOrEmpty(body.ref) || void 0;  // body.ref = undefined
    if (!ref && !selector) throw new Error("type requires ref or selector");

---

{ "action": "act", "ref": "e22", "request": { "kind": "type", "text": "hello" } }

---

{ "action": "act", "targetId": "TAB_ID", "request": { "kind": "type", "ref": "e22", "text": "hello" } }

---

// In /act route handler, after readBody(req):
if (body.request && typeof body.request === "object") {
    if (!body.request.ref && body.ref) body.request.ref = body.ref;
    if (!body.request.selector && body.selector) body.request.selector = body.selector;
}
RAW_BUFFERClick to expand / collapse

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

When using OpenAI models (gpt-4o-mini, gpt-4.1-mini) via OpenRouter, browser act calls consistently fail with "type requires ref or selector". The model places ref at the request top level following the tool schema, but normalizeActRequest() in routes-BdSVcmd0.js reads ref from body which corresponds to the nested request inner object. Anthropic Claude models (Sonnet) work because they generate the nested request: { kind, ref, text } format natively.

Steps to reproduce

  1. Configure OpenClaw 2026.5.7 with openrouter/openai/gpt-4o-mini as model
  2. Enable browser tool (tools.alsoAllow: ["browser"] or profile with group:ui)
  3. Send: openclaw agent --agent main --message "Navigate to https://example.com, take a snapshot, then click on the first link"
  4. Agent calls action="act" with ref at top level and request: { kind: "click" } (without ref inside request)
  5. Observe error: click requires ref or selector

Expected behavior

Browser act should accept ref both at the top level and inside the request object, since the tool schema exposes ref as a top-level parameter that OpenAI models follow literally.

Actual behavior

normalizeActRequest(body) receives body = request inner object, which does not contain ref (it was placed at the top level by the model). Error thrown at:

case "type": {
    const ref = toStringOrEmpty(body.ref) || void 0;  // body.ref = undefined
    if (!ref && !selector) throw new Error("type requires ref or selector");

OpenAI model generates (following schema):

{ "action": "act", "ref": "e22", "request": { "kind": "type", "text": "hello" } }

Anthropic model generates (nested natively):

{ "action": "act", "targetId": "TAB_ID", "request": { "kind": "type", "ref": "e22", "text": "hello" } }

Workaround patch (applied locally, confirmed working):

// In /act route handler, after readBody(req):
if (body.request && typeof body.request === "object") {
    if (!body.request.ref && body.ref) body.request.ref = body.ref;
    if (!body.request.selector && body.selector) body.request.selector = body.selector;
}

This is backward-compatible: only executes when ref is missing inside request but present at top level. No impact on Anthropic models or calls without request object.

OpenClaw version

2026.5.7 (eeef486)

Environment

  • Arch Linux 6.18.28-1-lts, Node 26.1.0
  • OpenRouter provider (native, via --auth-choice openrouter-api-key)
  • Models tested: openrouter/openai/gpt-4o-mini, openrouter/openai/gpt-4.1-mini (both fail), custom-openrouter-ai/anthropic/claude-sonnet-4.5 (works)
  • Browser plugin enabled, managed profile "openclaw", headless and headed modes

Additional context

Also discovered that fill (with fields array) works better than type for React controlled inputs, since type keystrokes may not trigger React onChange. Combined fix (ref fallback + fill instructions in browser-automation skill override) enables full login automation with gpt-4o-mini at ~$0.002/call vs ~$0.05 with Sonnet.

Willing to submit a PR with the fix if maintainers confirm the approach.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Browser act should accept ref both at the top level and inside the request object, since the tool schema exposes ref as a top-level parameter that OpenAI models follow literally.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING