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

推荐订阅源

GbyAI
GbyAI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 叶小钗
大猫的无限游戏
大猫的无限游戏
H
Help Net Security
G
Google Developers Blog
D
Docker
阮一峰的网络日志
阮一峰的网络日志
A
About on SuperTechFans
aimingoo的专栏
aimingoo的专栏
博客园 - 聂微东
Hugging Face - Blog
Hugging Face - Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Apple Machine Learning Research
Apple Machine Learning Research
云风的 BLOG
云风的 BLOG
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
腾讯CDC
T
The Blog of Author Tim Ferriss
Microsoft Security Blog
Microsoft Security Blog
WordPress大学
WordPress大学
I
InfoQ
Engineering at Meta
Engineering at Meta
Stack Overflow Blog
Stack Overflow Blog
Google DeepMind News
Google DeepMind 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
fix(agents): scope cli binding clears · openclaw/openclaw...
obviyus · 2026-05-30 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -1,2 +1,2 @@

11

export { runCliAgent } from "./cli-runner.js";

2-

export { getCliSessionId, setCliSessionId } from "./cli-session.js";

2+

export { clearCliSession, getCliSessionId, setCliSessionId } from "./cli-session.js";

Original file line numberDiff line numberDiff line change

@@ -95,10 +95,11 @@ export function keepCliSessionBindingOnlyWhenReused(params: {

9595

const existingSessionId = normalizeOptionalString(params.existingSessionId);

9696

const agentMeta = params.result.meta.agentMeta;

9797

const returnedSessionId = normalizeOptionalString(agentMeta?.cliSessionBinding?.sessionId);

98+

const shouldClearStoredSession = agentMeta?.clearCliSessionBinding === true;

9899

if (agentMeta === undefined || (existingSessionId && returnedSessionId === existingSessionId)) {

99100

return params.result;

100101

}

101-

if (returnedSessionId) {

102+

if (returnedSessionId || shouldClearStoredSession) {

102103

params.onDroppedReplacement?.();

103104

}

104105

return {

@@ -109,6 +110,7 @@ export function keepCliSessionBindingOnlyWhenReused(params: {

109110

...agentMeta,

110111

sessionId: "",

111112

cliSessionBinding: undefined,

113+

clearCliSessionBinding: undefined,

112114

},

113115

},

114116

};

Original file line numberDiff line numberDiff line change

@@ -1950,6 +1950,7 @@ describe("runAgentTurnWithFallback", () => {

19501950

sessionId: "transient-cli-session",

19511951

authProfileId: "profile",

19521952

},

1953+

clearCliSessionBinding: true,

19531954

},

19541955

},

19551956

});

@@ -1985,6 +1986,7 @@ describe("runAgentTurnWithFallback", () => {

19851986

}

19861987

expect(result.runResult.meta?.agentMeta?.sessionId).toBe("");

19871988

expect(result.runResult.meta?.agentMeta?.cliSessionBinding).toBeUndefined();

1989+

expect(result.runResult.meta?.agentMeta?.clearCliSessionBinding).toBeUndefined();

19881990

expect(activeSessionStore.main.cliSessionBindings?.["codex-cli"]).toBeUndefined();

19891991

});

19901992

@@ -2036,6 +2038,54 @@ describe("runAgentTurnWithFallback", () => {

20362038

});

20372039

});

20382040
2041+

it("clears room-event CLI bindings when an unflushed replacement is dropped", async () => {

2042+

state.isCliProviderMock.mockReturnValue(true);

2043+

state.runWithModelFallbackMock.mockImplementationOnce(async (params: FallbackRunnerParams) => ({

2044+

result: await params.run("codex-cli", "gpt-5.4"),

2045+

provider: "codex-cli",

2046+

model: "gpt-5.4",

2047+

attempts: [],

2048+

}));

2049+

state.runCliAgentMock.mockResolvedValueOnce({

2050+

payloads: [{ text: "handled" }],

2051+

meta: {

2052+

agentMeta: {

2053+

sessionId: "",

2054+

provider: "codex-cli",

2055+

model: "gpt-5.4",

2056+

clearCliSessionBinding: true,

2057+

},

2058+

},

2059+

});

2060+
2061+

const runAgentTurnWithFallback = await getRunAgentTurnWithFallback();

2062+

const followupRun = createFollowupRun();

2063+

followupRun.currentInboundEventKind = "room_event";

2064+

followupRun.run.provider = "codex-cli";

2065+

followupRun.run.model = "gpt-5.4";

2066+

const sessionEntry = {

2067+

cliSessionBindings: {

2068+

"codex-cli": { sessionId: "existing-cli-session" },

2069+

},

2070+

} as unknown as SessionEntry;

2071+

const activeSessionStore = { main: sessionEntry };

2072+
2073+

const result = await runAgentTurnWithFallback({

2074+

...createMinimalRunAgentTurnParams({ followupRun }),

2075+

activeSessionStore,

2076+

getActiveSessionEntry: () => sessionEntry,

2077+

});

2078+
2079+

expect(result.kind).toBe("success");

2080+

if (result.kind !== "success") {

2081+

throw new Error("expected success");

2082+

}

2083+

expect(result.runResult.meta?.agentMeta?.sessionId).toBe("");

2084+

expect(result.runResult.meta?.agentMeta?.cliSessionBinding).toBeUndefined();

2085+

expect(result.runResult.meta?.agentMeta?.clearCliSessionBinding).toBeUndefined();

2086+

expect(activeSessionStore.main.cliSessionBindings?.["codex-cli"]).toBeUndefined();

2087+

});

2088+
20392089

it("bridges CLI assistant agent events into onPartialReply for live preview (#76869)", async () => {

20402090

state.isCliProviderMock.mockReturnValue(true);

20412091

state.runWithModelFallbackMock.mockImplementationOnce(async (params: FallbackRunnerParams) => ({

Original file line numberDiff line numberDiff line change

@@ -1,5 +1,6 @@

11

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

22

import {

3+

clearCliSessionMock,

34

clearFastTestEnv,

45

getCliSessionIdMock,

56

isCliProviderMock,

@@ -284,6 +285,45 @@ describe("runCronIsolatedAgentTurn — cron model override forwarding (#58065)",

284285

).toBe(true);

285286

});

286287
288+

it("clears stale CLI bindings when cron CLI replacement is unflushed", async () => {

289+

isCliProviderMock.mockReturnValue(true);

290+

runWithModelFallbackMock.mockImplementation(async ({ provider, model, run }) => {

291+

const result = await run(provider, model);

292+

return { result, provider, model, attempts: [] };

293+

});

294+

const cronSession = makeCronSession({

295+

sessionEntry: makeCronSessionEntry({

296+

cliSessionBindings: {

297+

"claude-cli": { sessionId: "stale-cli-session" },

298+

"codex-cli": { sessionId: "codex-session" },

299+

},

300+

}),

301+

isNewSession: false,

302+

});

303+

resolveCronSessionMock.mockReturnValue(cronSession);

304+

runCliAgentMock.mockResolvedValueOnce({

305+

payloads: [{ text: "summary done" }],

306+

meta: {

307+

agentMeta: {

308+

provider: "claude-cli",

309+

model: "claude-opus-4-6",

310+

sessionId: "",

311+

clearCliSessionBinding: true,

312+

usage: { input: 10, output: 20 },

313+

},

314+

},

315+

});

316+
317+

const result = await runCronIsolatedAgentTurn(

318+

makeParams({

319+

job: makeJob({ sessionTarget: "session:existing-cron-session" }),

320+

}),

321+

);

322+
323+

expect(result.status).toBe("ok");

324+

expect(clearCliSessionMock).toHaveBeenCalledWith(cronSession.sessionEntry, "claude-cli");

325+

});

326+
287327

it("validates cron thinking with catalog reasoning metadata", async () => {

288328

resolveAllowedModelRefMock.mockImplementation(() => ({

289329

ref: { provider: "ollama", model: "qwen3:0.6b" },

Original file line numberDiff line numberDiff line change

@@ -56,6 +56,7 @@ export const runEmbeddedAgentMock = createMock();

5656

export const runCliAgentMock = createMock();

5757

export const lookupContextTokensMock = createMock();

5858

export const getCliSessionIdMock = createMock();

59+

export const clearCliSessionMock = createMock();

5960

export const updateSessionStoreMock = createMock();

6061

export const resolveCronSessionMock = createMock();

6162

export const logWarnMock = createMock();

@@ -283,6 +284,7 @@ vi.mock("./run-subagent-registry.runtime.js", () => ({

283284

}));

284285
285286

vi.mock("../../agents/cli-runner.runtime.js", () => ({

287+

clearCliSession: clearCliSessionMock,

286288

setCliSessionId: vi.fn(),

287289

}));

288290

@@ -487,6 +489,7 @@ function resetRunExecutionMocks(): void {

487489

runEmbeddedAgentMock.mockReset();

488490

runEmbeddedAgentMock.mockResolvedValue(makeDefaultEmbeddedResult());

489491

runCliAgentMock.mockReset();

492+

clearCliSessionMock.mockReset();

490493

getCliSessionIdMock.mockReturnValue(undefined);

491494

countActiveDescendantRunsMock.mockReset();

492495

countActiveDescendantRunsMock.mockReturnValue(0);

Original file line numberDiff line numberDiff line change

@@ -944,7 +944,10 @@ async function finalizeCronRun(params: {

944944

prepared.cronSession.sessionEntry.contextTokens = contextTokens;

945945

if (isCliProvider(providerUsed, prepared.cfgWithAgentDefaults)) {

946946

const cliSessionId = finalRunResult.meta?.agentMeta?.sessionId?.trim();

947-

if (cliSessionId) {

947+

if (finalRunResult.meta?.agentMeta?.clearCliSessionBinding === true) {

948+

const { clearCliSession } = await loadCliRunnerRuntime();

949+

clearCliSession(prepared.cronSession.sessionEntry, providerUsed);

950+

} else if (cliSessionId) {

948951

const { setCliSessionId } = await loadCliRunnerRuntime();

949952

setCliSessionId(prepared.cronSession.sessionEntry, providerUsed, cliSessionId);

950953

}