Skip to content

Commit fa39bef

Browse files
clawsweeper[bot]zhangguiping-xydtTakhoffman
authored
fix #84857: skip CLI runtime harness preflight during compaction (#85862)
Summary: - The PR skips agent-harness compaction preflight for provider-owned or configured CLI runtime sessions, adds claude-cli regression coverage, includes a changelog entry, and applies small test/type cleanups. - Reproducibility: yes. at source level. Current main still routes provider-owned `claude-cli` runtime compaction preflight through harness selection, where `claude-cli` is not a registered embedded harness. Automerge notes: - PR branch already contained follow-up commit before automerge: fix #84857: skip CLI runtime harness preflight during compaction - PR branch already contained follow-up commit before automerge: fix(clawsweeper): address review for automerge-openclaw-openclaw-8487… Validation: - ClawSweeper review passed for head 1dd8a88. - Required merge gates passed before the squash merge. Prepared head SHA: 1dd8a88 Review: #85862 (comment) Co-authored-by: 张贵萍0668001030 <[email protected]> Co-authored-by: clawsweeper <274271284+clawsweeper[bot]@users.noreply.github.com> Co-authored-by: clawsweeper[bot] <274271284+clawsweeper[bot]@users.noreply.github.com> Approved-by: takhoffman Co-authored-by: takhoffman <[email protected]>
1 parent 4ffbd07 commit fa39bef

6 files changed

Lines changed: 51 additions & 5 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ Docs: https://docs.openclaw.ai
6262

6363
### Fixes
6464

65+
- Agents/compaction: skip agent-harness preflight for provider-owned CLI runtime sessions so over-threshold Claude CLI sessions continue through normal compaction instead of failing on a missing harness. Fixes #84857. (#84878) Thanks @zhangguiping-xydt.
6566
- WebChat: summarize internal message-tool source replies so tool cards no longer duplicate the visible reply body. (#84773) Thanks @jason-allen-oneal.
6667
- WebChat: scope the visible attachment button to its own composer file input so clicking Upload reliably opens the file picker. (#83952, fixes #47983) Thanks @jason-allen-oneal.
6768
- Gateway: preserve deferred lifecycle-error cleanup across later non-terminal events so provider timeouts can persist failed session state instead of leaving sessions stuck running. (#85256, fixes #63819) Thanks @samzong.

‎extensions/meeting-notes/index.test.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,15 +429,19 @@ describe("meeting-notes plugin", () => {
429429
],
430430
});
431431
const logger = { debug: vi.fn(), error: vi.fn(), info: vi.fn(), warn: vi.fn() };
432+
const service = services[0];
433+
if (!service?.stop) {
434+
throw new Error("Expected meeting notes service with stop hook");
435+
}
432436

433-
await services[0]?.start({ config: {}, logger, stateDir });
437+
await service.start({ config: {}, logger, stateDir });
434438
await vi.waitFor(() => {
435439
expect(start).toHaveBeenCalledOnce();
436440
});
437441
const request = start.mock.calls[0]?.[0];
438442
expect(request.abortSignal?.aborted).toBe(false);
439443

440-
await services[0]?.stop({ config: {}, logger, stateDir });
444+
await service.stop({ config: {}, logger, stateDir });
441445

442446
expect(request.abortSignal?.aborted).toBe(true);
443447
expect(stop).not.toHaveBeenCalled();

‎extensions/meeting-notes/src/tool.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ async function waitForPendingAutoStartsToSettle(
106106
let timeout: ReturnType<typeof setTimeout> | undefined;
107107
try {
108108
return await Promise.race([
109-
Promise.allSettled([...pendingStarts]).then(() => true),
109+
Promise.allSettled(pendingStarts).then(() => true),
110110
new Promise<boolean>((resolve) => {
111111
timeout = setTimeout(() => resolve(false), AUTO_START_STOP_TIMEOUT_MS);
112112
timeout.unref?.();

‎src/agents/harness/selection.test.ts‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,34 @@ describe("selectAgentHarness", () => {
639639
).toBe("codex");
640640
});
641641

642+
it("skips harness compaction preflight for claude-cli runtime sessions", async () => {
643+
await expect(
644+
maybeCompactAgentHarnessSession({
645+
sessionId: "session-1",
646+
sessionKey: "agent:main:main",
647+
sessionFile: "/tmp/session.jsonl",
648+
workspaceDir: "/tmp/workspace",
649+
provider: "anthropic",
650+
model: "claude-opus-4-7",
651+
config: agentModelRuntimeConfig("anthropic/claude-opus-4-7", "claude-cli"),
652+
}),
653+
).resolves.toBeUndefined();
654+
});
655+
656+
it("skips harness compaction preflight for claude-cli provider sessions", async () => {
657+
await expect(
658+
maybeCompactAgentHarnessSession({
659+
sessionId: "session-1",
660+
sessionKey: "agent:main:main",
661+
sessionFile: "/tmp/session.jsonl",
662+
workspaceDir: "/tmp/workspace",
663+
provider: "claude-cli",
664+
model: "claude-opus-4-7",
665+
config: providerRuntimeConfig("claude-cli", "claude-cli"),
666+
}),
667+
).resolves.toBeUndefined();
668+
});
669+
642670
it("ignores stale plugin pins during compaction when the provider no longer matches", async () => {
643671
registerFailingCodexHarness();
644672

‎src/agents/harness/selection.ts‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { OpenClawConfig } from "../../config/types.openclaw.js";
22
import { formatErrorMessage } from "../../infra/errors.js";
33
import { createSubsystemLogger } from "../../logging/subsystem.js";
4-
import { isCliRuntimeAliasForProvider } from "../model-runtime-aliases.js";
4+
import { isCliRuntimeAliasForProvider, isCliRuntimeProvider } from "../model-runtime-aliases.js";
55
import type { CompactEmbeddedPiSessionParams } from "../pi-embedded-runner/compact.types.js";
66
import type {
77
EmbeddedRunAttemptParams,
@@ -459,6 +459,18 @@ function logAgentHarnessSelection(
459459
export async function maybeCompactAgentHarnessSession(
460460
params: CompactEmbeddedPiSessionParams,
461461
): Promise<EmbeddedPiCompactResult | undefined> {
462+
if (params.provider && isCliRuntimeProvider(params.provider)) {
463+
return undefined;
464+
}
465+
const runtime = resolveConfiguredAgentHarnessPolicy({
466+
provider: params.provider,
467+
modelId: params.model,
468+
config: params.config,
469+
sessionKey: params.sessionKey,
470+
}).runtime;
471+
if (isCliRuntimeAliasForProvider({ runtime, provider: params.provider })) {
472+
return undefined;
473+
}
462474
const harness = selectAgentHarness({
463475
provider: params.provider ?? "",
464476
modelId: params.model,

‎src/gateway/server-startup-post-attach.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ import type {
66
PluginHookGatewayContext,
77
PluginHookGatewayStartEvent,
88
} from "../plugins/hook-types.js";
9+
import type { PluginServicesHandle } from "../plugins/services.js";
910
import { withEnvAsync } from "../test-utils/env.js";
1011

1112
const hoisted = vi.hoisted(() => {
12-
const startPluginServices = vi.fn(async () => null);
13+
const startPluginServices = vi.fn<() => Promise<PluginServicesHandle | null>>(async () => null);
1314
const startGmailWatcherWithLogs = vi.fn(async () => {});
1415
const loadInternalHooks = vi.fn(async () => 0);
1516
const setInternalHooksEnabled = vi.fn();

0 commit comments

Comments
 (0)