惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
Tailwind CSS Blog
J
Java Code Geeks
Microsoft Azure Blog
Microsoft Azure Blog
GbyAI
GbyAI
爱范儿
爱范儿
量子位
Martin Fowler
Martin Fowler
V
V2EX
博客园 - 三生石上(FineUI控件)
I
InfoQ
MongoDB | Blog
MongoDB | Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
N
Netflix TechBlog - Medium
D
DataBreaches.Net
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Last Week in AI
Last Week in AI
U
Unit 42
Apple Machine Learning Research
Apple Machine Learning Research
H
Help Net Security
T
The Blog of Author Tim Ferriss
Hugging Face - Blog
Hugging Face - Blog
美团技术团队
Engineering at Meta
Engineering at Meta

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(browser): default act timeout budget · openclaw/openc...
steipete · 2026-04-25 · via Recent Commits to openclaw:main

@@ -15,6 +15,7 @@ import {

1515

resolveProfile,

1616

wrapExternalContent,

1717

} from "./browser-tool.runtime.js";

18+

import { DEFAULT_BROWSER_ACTION_TIMEOUT_MS } from "./browser/constants.js";

18191920

const browserToolActionDeps = {

2021

browserAct,

@@ -25,6 +26,94 @@ const browserToolActionDeps = {

2526

loadConfig,

2627

};

272829+

const BROWSER_ACT_REQUEST_TIMEOUT_SLACK_MS = 5_000;

30+31+

type BrowserActRequest = Parameters<typeof browserAct>[1];

32+

type BrowserActRequestWithTimeout = BrowserActRequest & { timeoutMs?: number };

33+34+

function normalizePositiveTimeoutMs(value: unknown): number | undefined {

35+

return typeof value === "number" && Number.isFinite(value) && value > 0

36+

? Math.floor(value)

37+

: undefined;

38+

}

39+40+

function supportsBrowserActTimeout(request: BrowserActRequest): boolean {

41+

switch (request.kind) {

42+

case "click":

43+

case "type":

44+

case "hover":

45+

case "scrollIntoView":

46+

case "drag":

47+

case "select":

48+

case "fill":

49+

case "evaluate":

50+

case "wait":

51+

return true;

52+

default:

53+

return false;

54+

}

55+

}

56+57+

function existingSessionRejectsActTimeout(request: BrowserActRequest): boolean {

58+

switch (request.kind) {

59+

case "type":

60+

case "hover":

61+

case "scrollIntoView":

62+

case "drag":

63+

case "select":

64+

case "fill":

65+

case "evaluate":

66+

return true;

67+

default:

68+

return false;

69+

}

70+

}

71+72+

function usesExistingSessionProfile(profileName: string | undefined): boolean {

73+

const cfg = browserToolActionDeps.loadConfig();

74+

const resolved = resolveBrowserConfig(cfg.browser, cfg);

75+

const profile = resolveProfile(resolved, profileName ?? resolved.defaultProfile);

76+

return profile ? getBrowserProfileCapabilities(profile).usesChromeMcp : false;

77+

}

78+79+

function withConfiguredActTimeout(

80+

request: BrowserActRequest,

81+

profileName: string | undefined,

82+

): BrowserActRequest {

83+

const typedRequest = request as BrowserActRequestWithTimeout;

84+

if (normalizePositiveTimeoutMs(typedRequest.timeoutMs) !== undefined) {

85+

return request;

86+

}

87+

if (!supportsBrowserActTimeout(request)) {

88+

return request;

89+

}

90+

if (existingSessionRejectsActTimeout(request) && usesExistingSessionProfile(profileName)) {

91+

return request;

92+

}

93+94+

const cfg = browserToolActionDeps.loadConfig();

95+

const configuredTimeout =

96+

normalizePositiveTimeoutMs(cfg.browser?.actionTimeoutMs) ?? DEFAULT_BROWSER_ACTION_TIMEOUT_MS;

97+

return { ...typedRequest, timeoutMs: configuredTimeout } as BrowserActRequest;

98+

}

99+100+

function resolveActProxyTimeoutMs(request: BrowserActRequest): number | undefined {

101+

const candidateTimeouts: number[] = [];

102+

const explicitTimeout = normalizePositiveTimeoutMs(

103+

(request as BrowserActRequestWithTimeout).timeoutMs,

104+

);

105+

if (explicitTimeout !== undefined) {

106+

candidateTimeouts.push(explicitTimeout + BROWSER_ACT_REQUEST_TIMEOUT_SLACK_MS);

107+

}

108+

if (request.kind === "wait") {

109+

const waitDuration = normalizePositiveTimeoutMs(request.timeMs);

110+

if (waitDuration !== undefined) {

111+

candidateTimeouts.push(waitDuration + BROWSER_ACT_REQUEST_TIMEOUT_SLACK_MS);

112+

}

113+

}

114+

return candidateTimeouts.length ? Math.max(...candidateTimeouts) : undefined;

115+

}

116+28117

export const __testing = {

29118

setDepsForTest(

30119

overrides: Partial<{

@@ -408,32 +497,34 @@ export async function executeConsoleAction(params: {

408497

}

409498410499

export async function executeActAction(params: {

411-

request: Parameters<typeof browserAct>[1];

500+

request: BrowserActRequest;

412501

baseUrl?: string;

413502

profile?: string;

414503

proxyRequest: BrowserProxyRequest | null;

415504

onTabActivity?: (targetId: string | undefined) => void;

416505

}): Promise<AgentToolResult<unknown>> {

417506

const { request, baseUrl, profile, proxyRequest } = params;

507+

const effectiveRequest = withConfiguredActTimeout(request, profile);

418508

try {

419509

const result = proxyRequest

420510

? await proxyRequest({

421511

method: "POST",

422512

path: "/act",

423513

profile,

424-

body: request,

514+

body: effectiveRequest,

515+

timeoutMs: resolveActProxyTimeoutMs(effectiveRequest),

425516

})

426-

: await browserToolActionDeps.browserAct(baseUrl, request, {

517+

: await browserToolActionDeps.browserAct(baseUrl, effectiveRequest, {

427518

profile,

428519

});

429520

params.onTabActivity?.(

430521

readStringValue((result as { targetId?: unknown }).targetId) ??

431-

readStringValue(request.targetId),

522+

readStringValue(effectiveRequest.targetId),

432523

);

433524

return jsonResult(result);

434525

} catch (err) {

435526

if (isChromeStaleTargetError(profile, err)) {

436-

const retryRequest = stripTargetIdFromActRequest(request);

527+

const retryRequest = stripTargetIdFromActRequest(effectiveRequest);

437528

const tabs = proxyRequest

438529

? ((

439530

(await proxyRequest({

@@ -445,14 +536,15 @@ export async function executeActAction(params: {

445536

: await browserToolActionDeps.browserTabs(baseUrl, { profile }).catch(() => []);

446537

// Some user-browser targetIds can go stale between snapshots and actions.

447538

// Only retry safe read-only actions, and only when exactly one tab remains attached.

448-

if (retryRequest && canRetryChromeActWithoutTargetId(request) && tabs.length === 1) {

539+

if (retryRequest && canRetryChromeActWithoutTargetId(effectiveRequest) && tabs.length === 1) {

449540

try {

450541

const retryResult = proxyRequest

451542

? await proxyRequest({

452543

method: "POST",

453544

path: "/act",

454545

profile,

455546

body: retryRequest,

547+

timeoutMs: resolveActProxyTimeoutMs(retryRequest),

456548

})

457549

: await browserToolActionDeps.browserAct(baseUrl, retryRequest, {

458550

profile,