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

推荐订阅源

D
Docker
I
InfoQ
L
LangChain Blog
阮一峰的网络日志
阮一峰的网络日志
Y
Y Combinator Blog
博客园_首页
Martin Fowler
Martin Fowler
宝玉的分享
宝玉的分享
A
About on SuperTechFans
Apple Machine Learning Research
Apple Machine Learning Research
Vercel News
Vercel News
T
The Blog of Author Tim Ferriss
C
Check Point Blog
B
Blog RSS Feed
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Engineering at Meta
Engineering at Meta
B
Blog
爱范儿
爱范儿
Stack Overflow Blog
Stack Overflow Blog
aimingoo的专栏
aimingoo的专栏
WordPress大学
WordPress大学
F
Fortinet All Blogs
月光博客
月光博客
GbyAI
GbyAI

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
refactor(agents): simplify stale cli retry cleanup · open...
obviyus · 2026-05-31 · via Recent Commits to openclaw:main

@@ -61,16 +61,19 @@ function shouldRetryFreshCliSessionAfterFailover(params: {

6161

error: FailoverError;

6262

hasHistoryPrompt: boolean;

6363

}): boolean {

64-

// These reasons can mean only the resumed CLI session is bad. Auth, billing,

65-

// rate-limit, and provider/config errors should clear stale state but surface.

6664

if (!params.hasHistoryPrompt) {

6765

return false;

6866

}

69-

return (

70-

params.error.reason === "session_expired" ||

71-

(params.error.reason === "unknown" && params.error.code === "cli_unknown_empty_failure") ||

72-

(params.error.reason === "timeout" && params.error.code === "cli_no_output_timeout")

73-

);

67+

switch (params.error.reason) {

68+

case "session_expired":

69+

return true;

70+

case "unknown":

71+

return params.error.code === "cli_unknown_empty_failure";

72+

case "timeout":

73+

return params.error.code === "cli_no_output_timeout";

74+

default:

75+

return false;

76+

}

7477

}

75787679

export async function isCliBindingFlushed(

@@ -666,7 +669,6 @@ export async function runPreparedCliAgent(

666669

};

667670

};

668671669-

// Try with the provided CLI session ID first

670672

try {

671673

await bootstrapHarnessContextEngine({

672674

hadSessionFile: context.hadSessionFile,

@@ -686,6 +688,35 @@ export async function runPreparedCliAgent(

686688

config: params.config,

687689

})

688690

: [];

691+

const finishCliAttempt = async (

692+

result: Awaited<ReturnType<typeof executeCliAttempt>>,

693+

fallbackCliSessionId?: string,

694+

) => {

695+

const { output, lastAssistant } = result;

696+

const assistantText = output.text.trim();

697+

const effectiveCliSessionId = output.sessionId ?? fallbackCliSessionId;

698+

await finalizeCliContextEngineTurn({

699+

context,

700+

historyMessages: context.contextEngine ? contextEngineHistoryMessages : historyMessages,

701+

assistantText,

702+

output,

703+

});

704+

const bindingFlushOk = await isCliBindingFlushed(

705+

effectiveCliSessionId,

706+

params.provider,

707+

context.cwd ?? context.workspaceDir,

708+

);

709+

await runCliAgentEndHook(params, {

710+

event: {

711+

messages: buildAgentEndMessages(lastAssistant),

712+

success: true,

713+

durationMs: Date.now() - context.started,

714+

},

715+

ctx: hookContext,

716+

hookRunner,

717+

});

718+

return buildCliRunResult({ output, effectiveCliSessionId, bindingFlushOk });

719+

};

689720690721

if (hasBeforeAgentRunHooks && hookRunner) {

691722

let beforeRunResult:

@@ -747,32 +778,10 @@ export async function runPreparedCliAgent(

747778

hookRunner,

748779

});

749780

try {

750-

const { output, lastAssistant } = await executeCliAttempt(

781+

return await finishCliAttempt(

782+

await executeCliAttempt(context.reusableCliSession.sessionId),

751783

context.reusableCliSession.sessionId,

752784

);

753-

const assistantText = output.text.trim();

754-

const effectiveCliSessionId = output.sessionId ?? context.reusableCliSession.sessionId;

755-

await finalizeCliContextEngineTurn({

756-

context,

757-

historyMessages: context.contextEngine ? contextEngineHistoryMessages : historyMessages,

758-

assistantText,

759-

output,

760-

});

761-

const bindingFlushOk = await isCliBindingFlushed(

762-

effectiveCliSessionId,

763-

params.provider,

764-

context.cwd ?? context.workspaceDir,

765-

);

766-

await runCliAgentEndHook(params, {

767-

event: {

768-

messages: buildAgentEndMessages(lastAssistant),

769-

success: true,

770-

durationMs: Date.now() - context.started,

771-

},

772-

ctx: hookContext,

773-

hookRunner,

774-

});

775-

return buildCliRunResult({ output, effectiveCliSessionId, bindingFlushOk });

776785

} catch (err) {

777786

if (isFailoverError(err)) {

778787

const retryableSessionId = context.reusableCliSession.sessionId;

@@ -802,32 +811,7 @@ export async function runPreparedCliAgent(

802811

cliBackendLog.warn(

803812

`cli session recovery retry: provider=${params.provider} reason=${err.reason} sessionKey=${params.sessionKey}`,

804813

);

805-

const { output, lastAssistant } = await executeCliAttempt(undefined, retryTimeoutMs);

806-

const assistantText = output.text.trim();

807-

const effectiveCliSessionId = output.sessionId;

808-

await finalizeCliContextEngineTurn({

809-

context,

810-

historyMessages: context.contextEngine

811-

? contextEngineHistoryMessages

812-

: historyMessages,

813-

assistantText,

814-

output,

815-

});

816-

const bindingFlushOk = await isCliBindingFlushed(

817-

effectiveCliSessionId,

818-

params.provider,

819-

context.cwd ?? context.workspaceDir,

820-

);

821-

await runCliAgentEndHook(params, {

822-

event: {

823-

messages: buildAgentEndMessages(lastAssistant),

824-

success: true,

825-

durationMs: Date.now() - context.started,

826-

},

827-

ctx: hookContext,

828-

hookRunner,

829-

});

830-

return buildCliRunResult({ output, effectiveCliSessionId, bindingFlushOk });

814+

return await finishCliAttempt(await executeCliAttempt(undefined, retryTimeoutMs));

831815

} catch (retryErr) {

832816

const retryMessage = formatErrorMessage(retryErr);

833817

await runCliAgentEndHook(params, {