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

推荐订阅源

J
Java Code Geeks
小众软件
小众软件
博客园 - 叶小钗
宝玉的分享
宝玉的分享
博客园_首页
Hugging Face - Blog
Hugging Face - Blog
人人都是产品经理
人人都是产品经理
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
S
SegmentFault 最新的问题
B
Blog RSS Feed
Engineering at Meta
Engineering at Meta
N
Netflix TechBlog - Medium
Google DeepMind News
Google DeepMind News
U
Unit 42
F
Fortinet All Blogs
IT之家
IT之家
Y
Y Combinator Blog
Martin Fowler
Martin Fowler
T
The Blog of Author Tim Ferriss
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The GitHub Blog
The GitHub Blog
Stack Overflow Blog
Stack Overflow Blog
Blog — PlanetScale
Blog — PlanetScale
酷 壳 – CoolShell
酷 壳 – CoolShell

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(agents): trace slow embedded run startup stages · ope...
steipete · 2026-04-29 · via Recent Commits to openclaw:main

@@ -242,6 +242,11 @@ import {

242242

shouldRotateCompactionTranscript,

243243

} from "../compaction-successor-transcript.js";

244244

import { configureEmbeddedAttemptHttpRuntime } from "./attempt-http-runtime.js";

245+

import {

246+

createEmbeddedRunStageTracker,

247+

formatEmbeddedRunStageSummary,

248+

shouldEmitEmbeddedRunStageSummary,

249+

} from "./attempt-stage-timing.js";

245250

import {

246251

assembleAttemptContextEngine,

247252

buildLoopPromptCacheInfo,

@@ -589,6 +594,19 @@ export async function runEmbeddedAttempt(

589594

log.debug(

590595

`embedded run start: runId=${params.runId} sessionId=${params.sessionId} provider=${params.provider} model=${params.modelId} thinking=${params.thinkLevel} messageChannel=${params.messageChannel ?? params.messageProvider ?? "unknown"}`,

591596

);

597+

const prepStages = createEmbeddedRunStageTracker();

598+

const emitPrepStageSummary = (phase: string) => {

599+

const summary = prepStages.snapshot();

600+

const message = formatEmbeddedRunStageSummary(

601+

`embedded run prep stages: runId=${params.runId} sessionId=${params.sessionId} phase=${phase}`,

602+

summary,

603+

);

604+

if (shouldEmitEmbeddedRunStageSummary(summary)) {

605+

log.warn(message);

606+

} else if (log.isEnabled("debug")) {

607+

log.debug(message);

608+

}

609+

};

592610593611

await fs.mkdir(resolvedWorkspace, { recursive: true });

594612

@@ -610,6 +628,7 @@ export async function runEmbeddedAttempt(

610628

config: params.config,

611629

agentId: params.agentId,

612630

});

631+

prepStages.mark("workspace-sandbox");

613632614633

let restoreSkillEnv: (() => void) | undefined;

615634

let aborted = Boolean(params.abortSignal?.aborted);

@@ -645,6 +664,7 @@ export async function runEmbeddedAttempt(

645664

workspaceDir: effectiveWorkspace,

646665

agentId: sessionAgentId,

647666

});

667+

prepStages.mark("skills");

648668649669

const sessionLabel = params.sessionKey ?? params.sessionId;

650670

const contextInjectionMode = resolveContextInjectionMode(params.config);

@@ -760,6 +780,7 @@ export async function runEmbeddedAttempt(

760780

});

761781

return applyEmbeddedAttemptToolsAllow(allTools, params.toolsAllow);

762782

})();

783+

prepStages.mark("core-plugin-tools");

763784

const toolsEnabled = supportsModelTools(params.model);

764785

const bootstrapHasFileAccess = toolsEnabled && toolsRaw.some((tool) => tool.name === "read");

765786

const bootstrapRouting = await resolveAttemptWorkspaceBootstrapRouting({

@@ -803,6 +824,7 @@ export async function runEmbeddedAttempt(

803824

runKind: params.bootstrapContextRunKind,

804825

}),

805826

});

827+

prepStages.mark("bootstrap-context");

806828

const remappedContextFiles = remapInjectedContextFilesToWorkspace({

807829

files: resolvedContextFiles,

808830

sourceWorkspaceDir: resolvedWorkspace,

@@ -935,6 +957,7 @@ export async function runEmbeddedAttempt(

935957

warn: (message) => log.warn(message),

936958

});

937959

const effectiveTools = [...tools, ...filteredBundledTools];

960+

prepStages.mark("bundle-tools");

938961

const allowedToolNames = collectAllowedToolNames({

939962

tools: effectiveTools,

940963

clientTools,

@@ -1221,6 +1244,7 @@ export async function runEmbeddedAttempt(

12211244

bootstrapMode,

12221245

contextFiles: remappedContextFiles,

12231246

});

1247+

prepStages.mark("system-prompt");

1224124812251249

// Keep the session lock scoped to transcript/session mutations. Cold plugin

12261250

// and tool setup can be slow, and holding the lock there blocks CLI fallback

@@ -1345,6 +1369,7 @@ export async function runEmbeddedAttempt(

13451369

cfg: params.config,

13461370

contextTokenBudget: params.contextTokenBudget,

13471371

});

1372+

prepStages.mark("session-resource-loader");

1348137313491374

// Get hook runner early so it's available when creating tools

13501375

const hookRunner = getGlobalHookRunner();

@@ -1441,6 +1466,7 @@ export async function runEmbeddedAttempt(

14411466

}

14421467

session.setActiveToolsByName(sessionToolAllowlist);

14431468

const activeSession = session;

1469+

prepStages.mark("agent-session");

14441470

if (isRawModelRun) {

14451471

// Raw model probes should measure exactly the requested prompt against

14461472

// the selected provider/model. Reset clears restored transcript state

@@ -1692,6 +1718,8 @@ export async function runEmbeddedAttempt(

16921718

`(${params.provider}/${params.modelId})`,

16931719

);

16941720

}

1721+

prepStages.mark("stream-setup");

1722+

emitPrepStageSummary("stream-ready");

1695172316961724

const cacheObservabilityEnabled = Boolean(cacheTrace) || log.isEnabled("debug");

16971725

const promptCacheToolNames = collectPromptCacheToolNames(