fix: parse embedded abort settle timeout strictly · openclaw/openclaw@df4475d
steipete
·
2026-05-29
·
via Recent Commits to openclaw:main
File tree
src/agents/embedded-agent-runner/run
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +import { describe, expect, it } from "vitest"; |
| 2 | +import { resolveEmbeddedAbortSettleTimeoutMs } from "./attempt.abort-settle-timeout.js"; |
| 3 | + |
| 4 | +describe("resolveEmbeddedAbortSettleTimeoutMs", () => { |
| 5 | +it("uses a positive decimal integer override", () => { |
| 6 | +expect( |
| 7 | +resolveEmbeddedAbortSettleTimeoutMs({ |
| 8 | +OPENCLAW_EMBEDDED_ABORT_SETTLE_TIMEOUT_MS: "1250", |
| 9 | +}), |
| 10 | +).toBe(1250); |
| 11 | +}); |
| 12 | + |
| 13 | +it.each(["0x10", "1e3", "12.5"])("ignores non-decimal-integer overrides: %s", (value) => { |
| 14 | +expect( |
| 15 | +resolveEmbeddedAbortSettleTimeoutMs({ |
| 16 | +OPENCLAW_EMBEDDED_ABORT_SETTLE_TIMEOUT_MS: value, |
| 17 | +}), |
| 18 | +).toBe(2_000); |
| 19 | +}); |
| 20 | + |
| 21 | +it("keeps the fast-test fallback when the override is invalid", () => { |
| 22 | +expect( |
| 23 | +resolveEmbeddedAbortSettleTimeoutMs({ |
| 24 | +OPENCLAW_EMBEDDED_ABORT_SETTLE_TIMEOUT_MS: "10ms", |
| 25 | +OPENCLAW_TEST_FAST: "1", |
| 26 | +}), |
| 27 | +).toBe(250); |
| 28 | +}); |
| 29 | +}); |
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +import { parseStrictPositiveInteger } from "../../../infra/parse-finite-number.js"; |
| 2 | + |
| 3 | +export function resolveEmbeddedAbortSettleTimeoutMs( |
| 4 | +env: Pick< |
| 5 | +NodeJS.ProcessEnv, |
| 6 | +"OPENCLAW_EMBEDDED_ABORT_SETTLE_TIMEOUT_MS" | "OPENCLAW_TEST_FAST" |
| 7 | +> = process.env, |
| 8 | +): number { |
| 9 | +const override = parseStrictPositiveInteger(env.OPENCLAW_EMBEDDED_ABORT_SETTLE_TIMEOUT_MS); |
| 10 | +if (override !== undefined) { |
| 11 | +return override; |
| 12 | +} |
| 13 | +return env.OPENCLAW_TEST_FAST === "1" ? 250 : 2_000; |
| 14 | +} |
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | import type { AgentMessage } from "../../runtime/index.js"; |
2 | 2 | import { log } from "../logger.js"; |
| 3 | +import { resolveEmbeddedAbortSettleTimeoutMs } from "./attempt.abort-settle-timeout.js"; |
3 | 4 | |
4 | 5 | const SESSIONS_YIELD_INTERRUPT_CUSTOM_TYPE = "openclaw.sessions_yield_interrupt"; |
5 | 6 | const SESSIONS_YIELD_CONTEXT_CUSTOM_TYPE = "openclaw.sessions_yield"; |
6 | | -function resolveSessionsYieldAbortSettleTimeoutMs(): number { |
7 | | -const override = Number(process.env.OPENCLAW_EMBEDDED_ABORT_SETTLE_TIMEOUT_MS); |
8 | | -if (Number.isFinite(override) && override > 0) { |
9 | | -return override; |
10 | | -} |
11 | | -return process.env.OPENCLAW_TEST_FAST === "1" ? 250 : 2_000; |
12 | | -} |
13 | 7 | |
14 | | -const SESSIONS_YIELD_ABORT_SETTLE_TIMEOUT_MS = resolveSessionsYieldAbortSettleTimeoutMs(); |
| 8 | +const SESSIONS_YIELD_ABORT_SETTLE_TIMEOUT_MS = resolveEmbeddedAbortSettleTimeoutMs(); |
15 | 9 | |
16 | 10 | // Persist a hidden context reminder so the next turn knows why the runner stopped. |
17 | 11 | function buildSessionsYieldContextMessage(message: string): string { |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | import type { SubscribeEmbeddedAgentSessionParams } from "../../embedded-agent-subscribe.types.js"; |
2 | 2 | import { log } from "../logger.js"; |
3 | | - |
4 | | -function resolveEmbeddedAbortSettleTimeoutMs(): number { |
5 | | -const override = Number(process.env.OPENCLAW_EMBEDDED_ABORT_SETTLE_TIMEOUT_MS); |
6 | | -if (Number.isFinite(override) && override > 0) { |
7 | | -return override; |
8 | | -} |
9 | | -return process.env.OPENCLAW_TEST_FAST === "1" ? 250 : 2_000; |
10 | | -} |
| 3 | +import { resolveEmbeddedAbortSettleTimeoutMs } from "./attempt.abort-settle-timeout.js"; |
11 | 4 | |
12 | 5 | export const EMBEDDED_ABORT_SETTLE_TIMEOUT_MS = resolveEmbeddedAbortSettleTimeoutMs(); |
13 | 6 | |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。