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

推荐订阅源

Apple Machine Learning Research
Apple Machine Learning Research
AWS News Blog
AWS News Blog
Google DeepMind News
Google DeepMind News
U
Unit 42
博客园 - 叶小钗
博客园 - 聂微东
GbyAI
GbyAI
Stack Overflow Blog
Stack Overflow Blog
有赞技术团队
有赞技术团队
aimingoo的专栏
aimingoo的专栏
D
DataBreaches.Net
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Jina AI
Jina AI
美团技术团队
The Cloudflare Blog
M
MIT News - Artificial intelligence
Microsoft Azure Blog
Microsoft Azure Blog
I
InfoQ
S
Schneier on Security
C
Check Point Blog
Project Zero
Project Zero
The Hacker News
The Hacker News
Scott Helme
Scott Helme
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Cisco Talos Blog
Cisco Talos Blog
P
Privacy International News Feed
SecWiki News
SecWiki News
Latest news
Latest news
MongoDB | Blog
MongoDB | Blog
S
Secure Thoughts
Google Online Security Blog
Google Online Security Blog
F
Fortinet All Blogs
博客园 - 三生石上(FineUI控件)
H
Help Net Security
TaoSecurity Blog
TaoSecurity Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Last Week in AI
Last Week in AI
P
Privacy & Cybersecurity Law Blog
Forbes - Security
Forbes - Security
G
GRAHAM CLULEY
N
Netflix TechBlog - Medium
L
Lohrmann on Cybersecurity
A
About on SuperTechFans
T
The Exploit Database - CXSecurity.com
C
Cisco Blogs
PCI Perspectives
PCI Perspectives
大猫的无限游戏
大猫的无限游戏
T
Troy Hunt's Blog
H
Hacker News: Front Page
Vercel News
Vercel News

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 test: trim doctor command hotspots · openclaw/openclaw@c66f16a test: isolate agent auth and spawn hotspots · openclaw/openclaw@9285935 test: stabilize MCP startup disposal race · openclaw/openclaw@dd9d2eb test: merge browser contract server suites · openclaw/openclaw@5817a76 test: narrow ollama provider discovery setup · openclaw/openclaw@a0d9598 build: declare qa-lab aimock runtime dependency · openclaw/openclaw@24431e5 test: speed up safe-bins exec harness · openclaw/openclaw@ee856ab test: preserve tool helpers in embedded runner mocks · openclaw/openclaw@acd86a0 refactor: move memory embeddings into provider plugins · openclaw/openclaw@77e6e4c test: reuse system-run temp fixtures · openclaw/openclaw@7e9ff0f test: trim hotspot wait overhead · openclaw/openclaw@12a59b0 Check: avoid duplicate boundary prep · openclaw/openclaw@baf11b8 test: reduce hotspot fixture overhead · openclaw/openclaw@3a59edd feat(ui): overhaul settings and slash command UX (#67819) thanks @Bun… · openclaw/openclaw@2cfb660 QA Matrix: exit cleanly on failure · openclaw/openclaw@42805d2 QA Matrix: isolate scenario coverage · openclaw/openclaw@7e659e1 Matrix: refresh crypto bootstrap state · openclaw/openclaw@94081d8 QA Lab: add provider registry · openclaw/openclaw@bb7e982 Matrix: add plugin changelog · openclaw/openclaw@4acab55 test: trim more hotspot overhead · openclaw/openclaw@f485311 test: trim remaining hotspot tests · openclaw/openclaw@6ba8626 test: narrow hotspot mocks · openclaw/openclaw@dbc8179 test: isolate gemini embedding request helpers · openclaw/openclaw@cd330f5 test: trim memory and mcp hotspots · openclaw/openclaw@fd48dfa test: slim provider registry mocks · openclaw/openclaw@2e08c77 test: harden Parallels update smoke · openclaw/openclaw@1a98090 feat: default Anthropic to Opus 4.7 · openclaw/openclaw@628b454 fix: harden node-host shell payload mutability checks · openclaw/openclaw@75c551e fix: land node-host approval binding for native binaries (#66731) (th… · openclaw/openclaw@29919bb CI: add daily schedule to CodeQL workflow (#67645) · openclaw/openclaw@69d25f5 fix(gateway): capture config hash after plugin auto-enable to prevent… · openclaw/openclaw@8c11210 fix: repair sanitized replay tool results before send (#67620) (thank… · openclaw/openclaw@c3c7a99 fix: restrict HTML timeout short-circuit to transient statuses · openclaw/openclaw@de129a6 fix: keep TUI watchdog bound to active run (#67401) (thanks @xantorres) · openclaw/openclaw@3525273 Gateway/skills: dedupe skills prefix-match + drop dead fallback on log · openclaw/openclaw@d7f489f Extensions/lmstudio: back off inference preload after consecutive fai… · openclaw/openclaw@b555214 TUI/streaming: add watchdog that resets the activity indicator after … · openclaw/openclaw@f44ab20 Agents/tool-loop: enable unknown-tool stream guard by default · openclaw/openclaw@36ed367 Gateway/skills: invalidate session skills snapshot on config write · openclaw/openclaw@b23d59a fix: classify HTML provider error pages correctly (#67642) (thanks @s… · openclaw/openclaw@e588e90 fix(skills): remove unused model-usage import (#67641) · openclaw/openclaw@55f05df docs(changelog): credit codex fix superseded PRs · openclaw/openclaw@e485f24 fix(openai-codex): normalize stale transport metadata in resolution a… · openclaw/openclaw@90801ba CI: pin Docker-related GitHub Actions (#67632) · openclaw/openclaw@f697b01 Android: modernize WebView and discovery API usage (#67627) · openclaw/openclaw@44a6e50 fix(deps): bump hono to 4.12.14 and @hono/node-server to 1.19.14 (GHS… · openclaw/openclaw@fbccc18 fix(deps): bump dompurify to 3.4.0 (#67614) · openclaw/openclaw@2c2dc00 CI: add explicit permissions to all workflow jobs (fixes code-scannin… · openclaw/openclaw@01b7516 fix: register bundled TTS providers and route overrides correctly (#6… · openclaw/openclaw@6ea3cdd fix: align host tilde paths with OS home (#62804) (thanks @stainlu) · openclaw/openclaw@ecfaf64 fix: flush creds queue before reconnect socket open (#67464) (thanks … · openclaw/openclaw@405c63f fix: strip standalone <function> tool call tags from visible text (#6… · openclaw/openclaw@78df859 fix(agents): preserve cli session metadata before transcript persist … · openclaw/openclaw@898fd04 docs(changelog): move cli transcript entry · openclaw/openclaw@c1817c6 fix(agents): normalize cli transcript api field · openclaw/openclaw@3a3fae0 docs(changelog): note cli transcript persistence · openclaw/openclaw@6c343f1 fix(agents): persist cli transcript turns · openclaw/openclaw@b8ef507 fix(msteams): harden security-sensitive flows (#65841) · openclaw/openclaw@c56b56e [Dashboard] Fix exec approval modal overflow for long command content… · openclaw/openclaw@053c5b0 Docs: remove QA changelog entry · openclaw/openclaw@7fd5771 QA: fix private runtime source loading (#67428) · openclaw/openclaw@d5933af docs(gateway): correct protocol.md schema path, hello-ok example, aut… · openclaw/openclaw@489404d CI: pin Node 22 runners to 22.18.0 · openclaw/openclaw@4ffa621 models.authStatus: normalize provider ids + tighten env-backed escape… · openclaw/openclaw@f2fdb9d Update CHANGELOG.md · openclaw/openclaw@7694a92 test(parallels): clean up npm update guard jobs · openclaw/openclaw@045ea7b Plugins: prefer scanDir override paths · openclaw/openclaw@b2974da fix(dreaming): default storage.mode to "separate" so phase blocks sto… · openclaw/openclaw@8c392f0 fix(memory-core): skip dreaming transcript ingestion via session stor… · openclaw/openclaw@a1b01f0 fix: dedupe replayed exec.finished node events (#67281) · openclaw/openclaw@5dcf526
refactor: centralize timer-safe timeout bounds · openclaw/openclaw@bf3921d
steipete · 2026-05-30 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

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

44

formatPluginConfigIssue,

55

mapPluginConfigIssues,

66

} from "openclaw/plugin-sdk/extension-shared";

7+

import { MAX_TIMER_TIMEOUT_SECONDS } from "openclaw/plugin-sdk/number-runtime";

78

import { z } from "zod";

89
910

type OpenShellPluginConfig = {

@@ -42,7 +43,6 @@ const DEFAULT_SOURCE = "openclaw";

4243

const DEFAULT_REMOTE_WORKSPACE_DIR = "/sandbox";

4344

const DEFAULT_REMOTE_AGENT_WORKSPACE_DIR = "/agent";

4445

const DEFAULT_TIMEOUT_MS = 120_000;

45-

const MAX_OPEN_SHELL_TIMEOUT_SECONDS = 2_147_000;

4646

const OPEN_SHELL_MANAGED_REMOTE_ROOTS = [

4747

DEFAULT_REMOTE_WORKSPACE_DIR,

4848

DEFAULT_REMOTE_AGENT_WORKSPACE_DIR,

@@ -92,11 +92,11 @@ const OpenShellPluginConfigSchema = z.strictObject({

9292

).optional(),

9393

timeoutSeconds: z

9494

.number({

95-

error: `timeoutSeconds must be a number between 1 and ${MAX_OPEN_SHELL_TIMEOUT_SECONDS}`,

95+

error: `timeoutSeconds must be a number between 1 and ${MAX_TIMER_TIMEOUT_SECONDS}`,

9696

})

9797

.min(1, { error: "timeoutSeconds must be a number >= 1" })

98-

.max(MAX_OPEN_SHELL_TIMEOUT_SECONDS, {

99-

error: `timeoutSeconds must be a number <= ${MAX_OPEN_SHELL_TIMEOUT_SECONDS}`,

98+

.max(MAX_TIMER_TIMEOUT_SECONDS, {

99+

error: `timeoutSeconds must be a number <= ${MAX_TIMER_TIMEOUT_SECONDS}`,

100100

})

101101

.optional(),

102102

});

Original file line numberDiff line numberDiff line change

@@ -1,8 +1,6 @@

1+

import { MAX_TIMER_TIMEOUT_MS } from "openclaw/plugin-sdk/number-runtime";

12

import { describe, expect, it } from "vitest";

2-

import {

3-

DEFAULT_RESPONSE_TIMEOUT_MS,

4-

resolveResponseTimeoutMs,

5-

} from "./response-timeout.js";

3+

import { DEFAULT_RESPONSE_TIMEOUT_MS, resolveResponseTimeoutMs } from "./response-timeout.js";

64
75

describe("resolveResponseTimeoutMs", () => {

86

it("falls back to the historical 5-minute floor when no timeouts configured", () => {

@@ -12,17 +10,17 @@ describe("resolveResponseTimeoutMs", () => {

1210

});

1311
1412

it("honors longer agents.defaults.timeoutSeconds", () => {

15-

expect(

16-

resolveResponseTimeoutMs({ agents: { defaults: { timeoutSeconds: 900 } } }),

17-

).toBe(900_000);

13+

expect(resolveResponseTimeoutMs({ agents: { defaults: { timeoutSeconds: 900 } } })).toBe(

14+

900_000,

15+

);

1816

});

1917
2018

it("ignores agents.defaults.timeoutSeconds shorter than the historical floor", () => {

2119

// Issue #85267: a configured 60s agent timeout must not undercut the

2220

// historical 5-minute watchdog floor for previously-working setups.

23-

expect(

24-

resolveResponseTimeoutMs({ agents: { defaults: { timeoutSeconds: 60 } } }),

25-

).toBe(DEFAULT_RESPONSE_TIMEOUT_MS);

21+

expect(resolveResponseTimeoutMs({ agents: { defaults: { timeoutSeconds: 60 } } })).toBe(

22+

DEFAULT_RESPONSE_TIMEOUT_MS,

23+

);

2624

});

2725
2826

it("honors models.providers.<id>.timeoutSeconds for slow local providers (#85267)", () => {

@@ -65,11 +63,11 @@ describe("resolveResponseTimeoutMs", () => {

6563

).toBe(DEFAULT_RESPONSE_TIMEOUT_MS);

6664

});

6765
68-

it("clamps to MAX_SAFE_TIMEOUT_MS for absurd inputs", () => {

66+

it("clamps to MAX_TIMER_TIMEOUT_MS for absurd inputs", () => {

6967

const huge = resolveResponseTimeoutMs({

7068

models: { providers: { ollama: { timeoutSeconds: 10_000_000 } } },

7169

});

72-

expect(huge).toBeLessThanOrEqual(2_147_000_000);

70+

expect(huge).toBeLessThanOrEqual(MAX_TIMER_TIMEOUT_MS);

7371

expect(huge).toBeGreaterThan(DEFAULT_RESPONSE_TIMEOUT_MS);

7472

});

7573

});

Original file line numberDiff line numberDiff line change

@@ -1,3 +1,8 @@

1+

import {

2+

finiteSecondsToTimerSafeMilliseconds,

3+

MAX_TIMER_TIMEOUT_MS,

4+

} from "openclaw/plugin-sdk/number-runtime";

5+
16

/**

27

* QQBot outbound response watchdog timeout resolver.

38

*

@@ -18,7 +23,7 @@

1823

* already configured:

1924

* - `agents.defaults.timeoutSeconds`

2025

* - `models.providers.<id>.timeoutSeconds` (max across configured providers)

21-

* Take the maximum and clamp to `[DEFAULT_RESPONSE_TIMEOUT_MS, MAX_SAFE_TIMEOUT_MS]`.

26+

* Take the maximum and clamp to `[DEFAULT_RESPONSE_TIMEOUT_MS, MAX_TIMER_TIMEOUT_MS]`.

2227

* The default floor preserves the existing 5-minute guard for users

2328

* that have not configured any longer ceiling — i.e. a no-op for

2429

* typical cloud-model deployments.

@@ -31,13 +36,6 @@

3136

*/

3237

export const DEFAULT_RESPONSE_TIMEOUT_MS = 300_000;

3338
34-

/**

35-

* Upper bound to keep the watchdog inside the safe `setTimeout` range

36-

* (approximately 24.8 days). Mirrors `MAX_SAFE_TIMEOUT_MS` in

37-

* `src/agents/embedded-agent-runner/run/llm-idle-timeout.ts`.

38-

*/

39-

const MAX_SAFE_TIMEOUT_MS = 2_147_000_000;

40-
4139

interface AgentsDefaultsLike {

4240

timeoutSeconds?: unknown;

4341

}

@@ -59,13 +57,6 @@ interface CfgShape {

5957

models?: ModelsBlockLike;

6058

}

6159
62-

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

63-

if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {

64-

return undefined;

65-

}

66-

return Math.floor(value * 1000);

67-

}

68-
6960

/**

7061

* Resolve the QQBot outbound response watchdog (ms).

7162

*

@@ -75,29 +66,31 @@ function positiveSecondsToMs(value: unknown): number | undefined {

7566

* - the maximum `cfg.models.providers.<id>.timeoutSeconds` across

7667

* configured providers, converted to ms

7768

*

78-

* Returns at most `MAX_SAFE_TIMEOUT_MS` so the chosen value is always

69+

* Returns at most `MAX_TIMER_TIMEOUT_MS` so the chosen value is always

7970

* a safe `setTimeout` argument.

8071

*/

8172

export function resolveResponseTimeoutMs(cfg: unknown): number {

8273

const candidates: number[] = [DEFAULT_RESPONSE_TIMEOUT_MS];

8374
8475

const typed = (cfg ?? {}) as CfgShape;

8576
86-

const agentDefaultMs = positiveSecondsToMs(typed.agents?.defaults?.timeoutSeconds);

77+

const agentDefaultMs = finiteSecondsToTimerSafeMilliseconds(

78+

typed.agents?.defaults?.timeoutSeconds,

79+

);

8780

if (agentDefaultMs !== undefined) {

8881

candidates.push(agentDefaultMs);

8982

}

9083
9184

const providers = typed.models?.providers;

9285

if (providers && typeof providers === "object") {

9386

for (const entry of Object.values(providers)) {

94-

const providerMs = positiveSecondsToMs(entry?.timeoutSeconds);

87+

const providerMs = finiteSecondsToTimerSafeMilliseconds(entry?.timeoutSeconds);

9588

if (providerMs !== undefined) {

9689

candidates.push(providerMs);

9790

}

9891

}

9992

}

10093
10194

const chosen = Math.max(...candidates);

102-

return Math.min(chosen, MAX_SAFE_TIMEOUT_MS);

95+

return Math.min(chosen, MAX_TIMER_TIMEOUT_MS);

10396

}

Original file line numberDiff line numberDiff line change

@@ -1,11 +1,10 @@

11

import type { OpenClawConfig } from "../../config/types.openclaw.js";

22

import type { CompactResult, ContextEngine } from "../../context-engine/types.js";

33

import { withTimeout } from "../../node-host/with-timeout.js";

4+

import { finiteSecondsToTimerSafeMilliseconds } from "../../shared/number-coercion.js";

45
56

export const EMBEDDED_COMPACTION_TIMEOUT_MS = 900_000;

67
7-

const MAX_SAFE_TIMEOUT_MS = 2_147_000_000;

8-
98

function createAbortError(signal: AbortSignal): Error {

109

const reason = "reason" in signal ? signal.reason : undefined;

1110

if (reason instanceof Error) {

@@ -55,11 +54,11 @@ function composeAbortSignals(...signals: Array<AbortSignal | undefined>): {

5554

}

5655
5756

export function resolveCompactionTimeoutMs(cfg?: OpenClawConfig): number {

58-

const raw = cfg?.agents?.defaults?.compaction?.timeoutSeconds;

59-

if (typeof raw === "number" && Number.isFinite(raw) && raw > 0) {

60-

return Math.min(Math.floor(raw) * 1000, MAX_SAFE_TIMEOUT_MS);

61-

}

62-

return EMBEDDED_COMPACTION_TIMEOUT_MS;

57+

return (

58+

finiteSecondsToTimerSafeMilliseconds(cfg?.agents?.defaults?.compaction?.timeoutSeconds, {

59+

floorSeconds: true,

60+

}) ?? EMBEDDED_COMPACTION_TIMEOUT_MS

61+

);

6362

}

6463
6564

export async function compactWithSafetyTimeout<T>(

Original file line numberDiff line numberDiff line change

@@ -1,6 +1,7 @@

11

import type { AssistantMessageEventStream } from "openclaw/plugin-sdk/llm";

22

import { afterEach, describe, expect, it, vi } from "vitest";

33

import type { OpenClawConfig } from "../../../config/config.js";

4+

import { MAX_TIMER_TIMEOUT_MS } from "../../../shared/number-coercion.js";

45

import {

56

DEFAULT_LLM_IDLE_TIMEOUT_MS,

67

resolveLlmIdleTimeoutMs,

@@ -40,7 +41,7 @@ describe("resolveLlmIdleTimeoutMs", () => {

4041

});

4142
4243

it("disables the idle watchdog when an explicit run timeout disables timeouts", () => {

43-

expect(resolveLlmIdleTimeoutMs({ runTimeoutMs: 2_147_000_000 })).toBe(0);

44+

expect(resolveLlmIdleTimeoutMs({ runTimeoutMs: MAX_TIMER_TIMEOUT_MS })).toBe(0);

4445

});

4546
4647

it("honors an explicit models.providers.<id>.timeoutSeconds for cloud providers (#77744, #78361)", () => {

@@ -66,7 +67,7 @@ describe("resolveLlmIdleTimeoutMs", () => {

6667

it("caps provider request timeout at the max safe timeout", () => {

6768

expect(

6869

resolveLlmIdleTimeoutMs({ trigger: "cron", modelRequestTimeoutMs: 10_000_000_000 }),

69-

).toBe(2_147_000_000);

70+

).toBe(MAX_TIMER_TIMEOUT_MS);

7071

});

7172
7273

it("ignores invalid provider request timeout values", () => {

Original file line numberDiff line numberDiff line change

@@ -1,5 +1,10 @@

11

import { DEFAULT_LLM_IDLE_TIMEOUT_SECONDS } from "../../../config/agent-timeout-defaults.js";

22

import type { OpenClawConfig } from "../../../config/types.openclaw.js";

3+

import {

4+

finiteSecondsToTimerSafeMilliseconds,

5+

clampTimerTimeoutMs,

6+

MAX_TIMER_TIMEOUT_MS,

7+

} from "../../../shared/number-coercion.js";

38

import type { StreamFn } from "../../runtime/index.js";

49

import type { MutableAssistantMessageEventStream } from "../../stream-compat.js";

510

import { createStreamIteratorWrapper } from "../../stream-iterator-wrapper.js";

@@ -10,11 +15,6 @@ import type { EmbeddedRunTrigger } from "./params.js";

1015

*/

1116

export const DEFAULT_LLM_IDLE_TIMEOUT_MS = DEFAULT_LLM_IDLE_TIMEOUT_SECONDS * 1000;

1217
13-

/**

14-

* Maximum safe timeout value (approximately 24.8 days).

15-

*/

16-

const MAX_SAFE_TIMEOUT_MS = 2_147_000_000;

17-
1818

/**

1919

* Detects loopback / private-network / `.local` base URLs. Local providers

2020

* (Ollama, LM Studio, llama.cpp) legitimately stay silent for many minutes

@@ -119,30 +119,25 @@ export function resolveLlmIdleTimeoutMs(params?: {

119119

modelRequestTimeoutMs?: number;

120120

model?: { baseUrl?: string; id?: string; provider?: string };

121121

}): number {

122-

const clampTimeoutMs = (valueMs: number) => Math.min(Math.floor(valueMs), MAX_SAFE_TIMEOUT_MS);

122+

const clampTimeoutMs = (valueMs: number) => clampTimerTimeoutMs(valueMs) ?? 1;

123123

const clampImplicitTimeoutMs = (valueMs: number) =>

124124

clampTimeoutMs(Math.min(valueMs, DEFAULT_LLM_IDLE_TIMEOUT_MS));

125125
126126

const runTimeoutMs = params?.runTimeoutMs;

127127

if (typeof runTimeoutMs === "number" && Number.isFinite(runTimeoutMs) && runTimeoutMs > 0) {

128-

if (runTimeoutMs >= MAX_SAFE_TIMEOUT_MS) {

128+

if (runTimeoutMs >= MAX_TIMER_TIMEOUT_MS) {

129129

return 0;

130130

}

131131

}

132132
133133

const agentTimeoutSeconds = params?.cfg?.agents?.defaults?.timeoutSeconds;

134-

const agentTimeoutMs =

135-

typeof agentTimeoutSeconds === "number" &&

136-

Number.isFinite(agentTimeoutSeconds) &&

137-

agentTimeoutSeconds > 0

138-

? agentTimeoutSeconds * 1000

139-

: undefined;

134+

const agentTimeoutMs = finiteSecondsToTimerSafeMilliseconds(agentTimeoutSeconds);

140135

const timeoutBounds = [runTimeoutMs, agentTimeoutMs].filter(

141136

(value): value is number =>

142137

typeof value === "number" &&

143138

Number.isFinite(value) &&

144139

value > 0 &&

145-

value < MAX_SAFE_TIMEOUT_MS,

140+

value < MAX_TIMER_TIMEOUT_MS,

146141

);

147142
148143

const modelRequestTimeoutMs = params?.modelRequestTimeoutMs;

Original file line numberDiff line numberDiff line change

@@ -3,6 +3,7 @@ import fs from "node:fs/promises";

33

import os from "node:os";

44

import path from "node:path";

55

import { afterEach, beforeAll, describe, expect, it, vi } from "vitest";

6+

import { MAX_TIMER_TIMEOUT_MS } from "../shared/number-coercion.js";

67
78

const FAKE_STARTTIME = 12345;

89

let testing: typeof import("./session-write-lock.js").testing;

@@ -602,9 +603,9 @@ describe("acquireSessionWriteLock", () => {

602603

it("clamps max hold for effectively no-timeout runs", () => {

603604

expect(

604605

resolveSessionLockMaxHoldFromTimeout({

605-

timeoutMs: 2_147_000_000,

606+

timeoutMs: MAX_TIMER_TIMEOUT_MS,

606607

}),

607-

).toBe(2_147_000_000);

608+

).toBe(MAX_TIMER_TIMEOUT_MS);

608609

});

609610
610611

it("cleans stale .jsonl lock files in sessions directories", async () => {

Original file line numberDiff line numberDiff line change

@@ -4,6 +4,7 @@ import fs from "node:fs/promises";

44

import path from "node:path";

55

import { createFileLockManager } from "../infra/file-lock-manager.js";

66

import { readGatewayProcessArgsSync as readProcessArgsSync } from "../infra/gateway-processes.js";

7+

import { MAX_TIMER_TIMEOUT_MS } from "../shared/number-coercion.js";

78

import { getProcessStartTime, isPidAlive } from "../shared/pid-alive.js";

89

import { SessionWriteLockTimeoutError } from "./session-write-lock-error.js";

910

@@ -53,7 +54,6 @@ function yieldEventLoop(): Promise<void> {

5354

// A payload-less lock can be left behind if shutdown lands between open("wx")

5455

// and the owner metadata write. Keep the grace short so 10s callers recover.

5556

const ORPHAN_LOCK_PAYLOAD_GRACE_MS = 5_000;

56-

const MAX_LOCK_HOLD_MS = 2_147_000_000;

5757
5858

type CleanupState = {

5959

registered: boolean;

@@ -253,10 +253,10 @@ export function resolveSessionLockMaxHoldFromTimeout(params: {

253253

const minMs = resolvePositiveMs(params.minMs, DEFAULT_SESSION_WRITE_LOCK_MAX_HOLD_MS);

254254

const timeoutMs = resolvePositiveMs(params.timeoutMs, minMs, { allowInfinity: true });

255255

if (timeoutMs === Number.POSITIVE_INFINITY) {

256-

return MAX_LOCK_HOLD_MS;

256+

return MAX_TIMER_TIMEOUT_MS;

257257

}

258258

const graceMs = resolvePositiveMs(params.graceMs, DEFAULT_TIMEOUT_GRACE_MS);

259-

return Math.min(MAX_LOCK_HOLD_MS, Math.max(minMs, timeoutMs + graceMs));

259+

return Math.min(MAX_TIMER_TIMEOUT_MS, Math.max(minMs, timeoutMs + graceMs));

260260

}

261261
262262

/**

Original file line numberDiff line numberDiff line change

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

1515

import { deriveSessionChatTypeFromKey } from "../sessions/session-chat-type-shared.js";

1616

import { isCronRunSessionKey, isCronSessionKey } from "../sessions/session-key-utils.js";

1717

import { isNonTerminalAgentRunStatus } from "../shared/agent-run-status.js";

18+

import { clampTimerTimeoutMs } from "../shared/number-coercion.js";

1819

import { normalizeOptionalLowercaseString } from "../shared/string-coerce.js";

1920

import { normalizeStringEntries, uniqueStrings } from "../shared/string-normalization.js";

2021

import { mergeDeliveryContext, normalizeDeliveryContext } from "../utils/delivery-context.js";

@@ -67,7 +68,6 @@ import { resolveRequesterStoreKey } from "./subagent-requester-store-key.js";

6768

import type { SpawnSubagentMode } from "./subagent-spawn.types.js";

6869
6970

const DEFAULT_SUBAGENT_ANNOUNCE_TIMEOUT_MS = 120_000;

70-

const MAX_TIMER_SAFE_TIMEOUT_MS = 2_147_000_000;

7171

type SubagentAnnounceDeliveryDeps = {

7272

dispatchGatewayMethodInProcess: typeof dispatchGatewayMethodInProcess;

7373

getRuntimeConfig: typeof getRuntimeConfig;

@@ -319,10 +319,7 @@ async function resolveActiveWakeWithRetries(

319319
320320

export function resolveSubagentAnnounceTimeoutMs(cfg: OpenClawConfig): number {

321321

const configured = cfg.agents?.defaults?.subagents?.announceTimeoutMs;

322-

if (typeof configured !== "number" || !Number.isFinite(configured)) {

323-

return DEFAULT_SUBAGENT_ANNOUNCE_TIMEOUT_MS;

324-

}

325-

return Math.min(Math.max(1, Math.floor(configured)), MAX_TIMER_SAFE_TIMEOUT_MS);

322+

return clampTimerTimeoutMs(configured) ?? DEFAULT_SUBAGENT_ANNOUNCE_TIMEOUT_MS;

326323

}

327324
328325

export function isInternalAnnounceRequesterSession(sessionKey: string | undefined): boolean {

Original file line numberDiff line numberDiff line change

@@ -1,4 +1,5 @@

11

import { beforeEach, describe, expect, it, vi } from "vitest";

2+

import { clampTimerTimeoutMs } from "../shared/number-coercion.js";

23

import { createSubagentAnnounceDeliveryRuntimeMock } from "./subagent-announce.test-support.js";

34
45

type GatewayCall = {

@@ -130,13 +131,7 @@ vi.mock("./subagent-announce-delivery.js", () => ({

130131

},

131132

});

132133

const timeoutMs =

133-

typeof configOverride.agents?.defaults?.subagents?.announceTimeoutMs === "number" &&

134-

Number.isFinite(configOverride.agents.defaults.subagents.announceTimeoutMs)

135-

? Math.min(

136-

Math.max(1, Math.floor(configOverride.agents.defaults.subagents.announceTimeoutMs)),

137-

2_147_000_000,

138-

)

139-

: 120_000;

134+

clampTimerTimeoutMs(configOverride.agents?.defaults?.subagents?.announceTimeoutMs) ?? 120_000;

140135

const retryDelaysMs =

141136

process.env.OPENCLAW_TEST_FAST === "1" ? [8, 16, 32] : [5_000, 10_000, 20_000];

142137

let retryIndex = 0;

@@ -168,10 +163,7 @@ vi.mock("./subagent-announce-delivery.js", () => ({

168163

params.requesterOrigin,

169164

resolveSubagentAnnounceTimeoutMs: (cfg: typeof configOverride) => {

170165

const configured = cfg.agents?.defaults?.subagents?.announceTimeoutMs;

171-

if (typeof configured !== "number" || !Number.isFinite(configured)) {

172-

return 120_000;

173-

}

174-

return Math.min(Math.max(1, Math.floor(configured)), 2_147_000_000);

166+

return clampTimerTimeoutMs(configured) ?? 120_000;

175167

},

176168

runAnnounceDeliveryWithRetry: async <T>(params: { run: () => Promise<T> }) => await params.run(),

177169

}));