Skip to content

fix(browser): budget sequential action watchdogs - #104659

Merged
steipete merged 2 commits into
mainfrom
codex/fix-browser-action-budgets
Jul 11, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/fix-browser-action-budgets

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Composite browser waits and nested batches execute their phases serially, but direct, CLI, browser-proxy, and node-invoke watchdogs were sized from one phase, a maximum, or a fixed 20/30/60 second deadline. Valid work could be aborted midway and a retry could repeat already-completed page side effects. The agent tool also omitted batch/actions from its model-facing schema, and malformed permissive batch input could crash timeout calculation before the browser route returned its normal validation error.

Closes #104457.

Why This Change Was Made

One recursive, saturating action-budget policy now mirrors the actual sequential runtime phases, including per-action Playwright timeouts, bounded delays, navigation grace, composite wait conditions, nested batches, and the wider scroll/evaluate timeout contract. Direct requests, CLI waits, browser proxy calls, and paired-node calls reuse that owner; the computed deadline is propagated through both browser.proxy and the separate node.invoke watchdog. Explicit caller timeout overrides remain authoritative, the existing whole-request floor remains, and transport watchdogs stay enabled.

The flat provider-compatible agent schema now advertises batch, actions, and stopOnError without introducing recursive JSON Schema. Runtime budgeting tolerates malformed permissive children long enough for the browser route to return its canonical validation error.

User Impact

Long composite waits and nested batches can finish once across host, CLI, and paired-node browser automation instead of failing at an unrelated outer deadline. Genuine Playwright locator errors still surface, and invalid batch input now returns an actionable validation error rather than a JavaScript .reduce() crash. This does not parallelize actions, remove timeout protection, widen browser/navigation permissions, or change the per-agent trust boundary.

Evidence

  • Blacksmith Testbox-through-Crabbox tbx_01kx9742wgnqkm9m5v1yqjaaqd: 140/140 focused browser tests.
  • Same Testbox: changed typecheck, lint, format, database-first, media, sidecar, and import-cycle gates passed.
  • Real isolated Gateway + openai/gpt-5.4 + managed browser:
    • composite 8s + condition/function wait returned COMPOSITE_SUCCESS Budget Proof (cc3b1457-7973-45b7-95f3-7d8f24e5e907; 3 Browser calls, 0 failures, no fallback);
    • 63s nested host batch returned ordered DIRECT_BATCH A,B,C,D (e483fc58-9107-49f6-b7c7-cf7e77565b39; 2 Browser calls, 0 failures);
    • 63s paired-node batch crossed the former 30s node-invoke deadline and returned ordered NODE_BATCH A,B,C,D (e8f206d5-6181-4aa9-8596-598b8058873a; 2 Browser calls, 0 failures);
    • impossible locator after an 8s delay returned Playwright's 7s locator timeout at 16.071s, not a generic transport timeout;
    • malformed {kind:"batch",requests:[]} returned actions are required, not a runtime crash.
  • Official Playwright 1.61.1 source inspected for locator/action/wait timeout and mouse delay sequencing.
  • Fresh autoreview: clean, no accepted/actionable findings (0.91 overall confidence).

AI-assisted implementation and review. No agent transcript attached.

@openclaw-barnacle openclaw-barnacle Bot added size: L maintainer Maintainer-authored PR labels Jul 11, 2026
@steipete

steipete commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor Author

Land-ready verification for final head 61a36d637ef (runtime patch is byte-identical to tested parent 47c125b938580cdf94b67fcc5205bfe5205bcd1b; the final commit only removes the release-owned changelog line required by the native prepare guard):

Automated proof

  • Blacksmith Testbox-through-Crabbox tbx_01kx9742wgnqkm9m5v1yqjaaqd:

    corepack pnpm test extensions/browser/src/browser/act-policy.test.ts extensions/browser/src/browser/client.test.ts extensions/browser/src/browser-tool.test.ts extensions/browser/src/browser-tool.schema.test.ts extensions/browser/src/cli/browser-cli-actions-input/register.form-wait-eval.test.ts extensions/browser/src/browser/pw-tools-core.interactions.batch.test.ts

    Result: 6 files, 140/140 tests passed.

  • Same Testbox:

    env OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 OPENCLAW_CHANGED_LANES_RAW_SYNC=1 corepack pnpm check:changed

    Result: extension production/test tsgo, format, oxlint (0 warnings/errors), database-first guard, media helper guard, runtime-sidecar guard, and import-cycle check all passed.

  • Fresh autoreview: clean, no accepted/actionable findings; overall confidence 0.91.

Live Gateway / agent / browser proof

I started a real isolated Gateway with a managed Chromium profile, paired a real browser node, supplied the OpenAI credential through the approved secret path without printing it, and talked to the agent on openai/gpt-5.4. The isolated fixture temporarily allowed loopback navigation only for this proof; all processes were stopped and ports closed afterward.

  • Composite wait: one request performed an 8s delay, waited for delayed text, and evaluated a delayed function with timeoutMs=7000; run cc3b1457-7973-45b7-95f3-7d8f24e5e907 returned COMPOSITE_SUCCESS Budget Proof with 3 Browser calls, 0 failures, and no model fallback.
  • Direct host batch: a recursively nested batch with three 21s waits completed and read back exact ordered markers DIRECT_BATCH A,B,C,D; run e483fc58-9107-49f6-b7c7-cf7e77565b39, 2 Browser calls, 0 failures.
  • Paired-node batch: the same 63s batch crossed the former 30s node.invoke deadline and read back NODE_BATCH A,B,C,D; run e8f206d5-6181-4aa9-8596-598b8058873a, 2 Browser calls, 0 failures.
  • Inner error precedence: an 8s delay followed by an impossible text wait failed after 16.071s with Playwright locator.waitFor: Timeout 7000ms exceeded, not an outer browser-control or node-invoke timeout.
  • Malformed input: top-level requests returned route-owned actions are required; malformed nested wait/unknown-kind children returned route-owned kind is required. Neither crashed in the estimator.

The first black-box pass exposed two adjacent gaps that are fixed in this PR: batch fields were absent from the model-facing flat schema, and the computed proxy deadline was not propagated to the separate node.invoke watchdog. Both were reproduced before the fix and passed on the final code.

I also inspected Playwright 1.61.1 source for locator/action/wait timeout behavior and mouse delay sequencing. No proof gaps remain for the touched host, CLI, browser-proxy, or paired-node watchdog paths.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 47c125b938

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

command: "browser.proxy",
// node.invoke owns a separate watchdog from browser.proxy. Keep both
// bounded, with enough outer slack for the proxy result to cross back.
timeoutMs: gatewayTimeoutMs,

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.

P2 Badge Keep the outer Gateway timeout above node.invoke

This sets the node.invoke watchdog to the same value that callGatewayTool uses as the outer Gateway request timeout (see src/agents/tools/gateway.ts:506 and src/gateway/node-registry.ts:620-657). When browser.proxy legitimately consumes its budget and the node response arrives near the invoke deadline, the agent-side Gateway call can time out at the same moment instead of delivering the result/error; the intended second slack window needs to make the outer call longer than node.invoke, not equal to it.

Useful? React with 👍 / 👎.

@steipete
steipete merged commit 84a52b3 into main Jul 11, 2026
107 of 151 checks passed
@steipete
steipete deleted the codex/fix-browser-action-budgets branch July 11, 2026 19:56
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 12, 2026
* fix(browser): budget sequential action watchdogs

* chore: leave browser release note to release flow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Browser composite waits and nested batches time out before all steps can finish

1 participant