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

推荐订阅源

Apple Machine Learning Research
Apple Machine Learning Research
J
Java Code Geeks
博客园 - 聂微东
Microsoft Azure Blog
Microsoft Azure Blog
量子位
T
Tailwind CSS Blog
Vercel News
Vercel News
I
InfoQ
Stack Overflow Blog
Stack Overflow Blog
U
Unit 42
Engineering at Meta
Engineering at Meta
L
LangChain Blog
大猫的无限游戏
大猫的无限游戏
D
Docker
博客园_首页
P
Proofpoint News Feed
月光博客
月光博客
T
The Blog of Author Tim Ferriss
MyScale Blog
MyScale Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Martin Fowler
Martin Fowler
腾讯CDC
N
Netflix TechBlog - Medium
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

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: keep embedded run lanes from wedging · openclaw/open...
steipete · 2026-04-30 · via Recent Commits to openclaw:main

@@ -12,6 +12,7 @@ import { formatErrorMessage } from "../../infra/errors.js";

1212

import { getGlobalHookRunner } from "../../plugins/hook-runner-global.js";

1313

import { resolveProviderAuthProfileId } from "../../plugins/provider-runtime.js";

1414

import { enqueueCommandInLane } from "../../process/command-queue.js";

15+

import type { CommandQueueEnqueueOptions } from "../../process/command-queue.types.js";

1516

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

1617

import { sanitizeForLog } from "../../terminal/ansi.js";

1718

import { resolveUserPath } from "../../utils.js";

@@ -76,6 +77,7 @@ import {

7677

pickFallbackThinkingLevel,

7778

} from "../pi-embedded-helpers.js";

7879

import { resolveProviderIdForAuth } from "../provider-auth-aliases.js";

80+

import { runAgentCleanupStep } from "../run-cleanup-timeout.js";

7981

import { buildAgentRuntimeAuthPlan } from "../runtime-plan/auth.js";

8082

import { buildAgentRuntimePlan } from "../runtime-plan/build.js";

8183

import { ensureRuntimePluginsLoaded } from "../runtime-plugins.js";

@@ -159,8 +161,26 @@ import { createUsageAccumulator, mergeUsageIntoAccumulator } from "./usage-accum

159161

type ApiKeyInfo = ResolvedProviderAuth;

160162161163

const MAX_SAME_MODEL_IDLE_TIMEOUT_RETRIES = 1;

164+

const EMBEDDED_RUN_LANE_TIMEOUT_GRACE_MS = 30_000;

162165

type EmbeddedRunAttemptForRunner = Awaited<ReturnType<typeof runEmbeddedAttemptWithBackend>>;

163166167+

function resolveEmbeddedRunLaneTimeoutMs(timeoutMs: number): number | undefined {

168+

if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {

169+

return undefined;

170+

}

171+

return Math.floor(timeoutMs) + EMBEDDED_RUN_LANE_TIMEOUT_GRACE_MS;

172+

}

173+174+

function withEmbeddedRunLaneTimeout(

175+

opts: CommandQueueEnqueueOptions | undefined,

176+

laneTaskTimeoutMs: number | undefined,

177+

): CommandQueueEnqueueOptions | undefined {

178+

if (laneTaskTimeoutMs === undefined || opts?.taskTimeoutMs !== undefined) {

179+

return opts;

180+

}

181+

return { ...opts, taskTimeoutMs: laneTaskTimeoutMs };

182+

}

183+164184

function normalizeEmbeddedRunAttemptResult(

165185

attempt: EmbeddedRunAttemptForRunner,

166186

): EmbeddedRunAttemptForRunner {

@@ -292,10 +312,15 @@ export async function runEmbeddedPiAgent(

292312

}

293313

const sessionLane = resolveSessionLane(params.sessionKey?.trim() || params.sessionId);

294314

const globalLane = resolveGlobalLane(params.lane);

295-

const enqueueGlobal =

296-

params.enqueue ?? ((task, opts) => enqueueCommandInLane(globalLane, task, opts));

297-

const enqueueSession =

298-

params.enqueue ?? ((task, opts) => enqueueCommandInLane(sessionLane, task, opts));

315+

const laneTaskTimeoutMs = resolveEmbeddedRunLaneTimeoutMs(params.timeoutMs);

316+

const withLaneTimeout = (opts?: CommandQueueEnqueueOptions) =>

317+

withEmbeddedRunLaneTimeout(opts, laneTaskTimeoutMs);

318+

const enqueueGlobal = <T>(task: () => Promise<T>, opts?: CommandQueueEnqueueOptions) =>

319+

params.enqueue

320+

? params.enqueue(task, withLaneTimeout(opts))

321+

: enqueueCommandInLane(globalLane, task, withLaneTimeout(opts));

322+

const enqueueSession = <T>(task: () => Promise<T>, opts?: CommandQueueEnqueueOptions) =>

323+

params.enqueue ? params.enqueue(task, opts) : enqueueCommandInLane(sessionLane, task, opts);

299324

const channelHint = params.messageChannel ?? params.messageProvider;

300325

const resolvedToolResultFormat =

301326

params.toolResultFormat ??

@@ -2489,26 +2514,42 @@ export async function runEmbeddedPiAgent(

24892514

}

24902515

} finally {

24912516

forgetPromptBuildDrainCacheForRun(params.runId);

2492-

await contextEngine.dispose?.();

24932517

stopRuntimeAuthRefreshTimer();

2518+

await runAgentCleanupStep({

2519+

runId: params.runId,

2520+

sessionId: params.sessionId,

2521+

step: "context-engine-dispose",

2522+

log,

2523+

cleanup: async () => {

2524+

await contextEngine.dispose?.();

2525+

},

2526+

});

24942527

if (params.cleanupBundleMcpOnRunEnd === true) {

2495-

const onError = (error: unknown, sessionId: string) => {

2496-

log.warn(

2497-

`bundle-mcp cleanup failed after run for ${sessionId}: ${formatErrorMessage(error)}`,

2498-

);

2499-

};

2500-

const retiredBySessionKey = await retireSessionMcpRuntimeForSessionKey({

2501-

sessionKey: params.sessionKey,

2502-

reason: "embedded-run-end",

2503-

onError,

2528+

await runAgentCleanupStep({

2529+

runId: params.runId,

2530+

sessionId: params.sessionId,

2531+

step: "bundle-mcp-retire",

2532+

log,

2533+

cleanup: async () => {

2534+

const onError = (error: unknown, sessionId: string) => {

2535+

log.warn(

2536+

`bundle-mcp cleanup failed after run for ${sessionId}: ${formatErrorMessage(error)}`,

2537+

);

2538+

};

2539+

const retiredBySessionKey = await retireSessionMcpRuntimeForSessionKey({

2540+

sessionKey: params.sessionKey,

2541+

reason: "embedded-run-end",

2542+

onError,

2543+

});

2544+

if (!retiredBySessionKey) {

2545+

await retireSessionMcpRuntime({

2546+

sessionId: params.sessionId,

2547+

reason: "embedded-run-end",

2548+

onError,

2549+

});

2550+

}

2551+

},

25042552

});

2505-

if (!retiredBySessionKey) {

2506-

await retireSessionMcpRuntime({

2507-

sessionId: params.sessionId,

2508-

reason: "embedded-run-end",

2509-

onError,

2510-

});

2511-

}

25122553

}

25132554

}

25142555

});