mirror of https://github.com/openclaw/openclaw.git
fix(context): skip eager warmup for non-model CLI commands
This commit is contained in:
parent
8e4a1d87e2
commit
d1e4ee03ff
|
|
@ -90,6 +90,20 @@ describe("lookupContextTokens", () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("skips eager warmup for logs commands that do not need model metadata at startup", async () => {
|
||||||
|
const loadConfigMock = vi.fn(() => ({ models: {} }));
|
||||||
|
mockContextModuleDeps(loadConfigMock);
|
||||||
|
|
||||||
|
const argvSnapshot = process.argv;
|
||||||
|
process.argv = ["node", "openclaw", "logs", "--limit", "5"];
|
||||||
|
try {
|
||||||
|
await import("./context.js");
|
||||||
|
expect(loadConfigMock).not.toHaveBeenCalled();
|
||||||
|
} finally {
|
||||||
|
process.argv = argvSnapshot;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
it("retries config loading after backoff when an initial load fails", async () => {
|
it("retries config loading after backoff when an initial load fails", async () => {
|
||||||
vi.useFakeTimers();
|
vi.useFakeTimers();
|
||||||
const loadConfigMock = vi
|
const loadConfigMock = vi
|
||||||
|
|
|
||||||
|
|
@ -108,9 +108,24 @@ function getCommandPathFromArgv(argv: string[]): string[] {
|
||||||
return tokens;
|
return tokens;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const SKIP_EAGER_WARMUP_PRIMARY_COMMANDS = new Set([
|
||||||
|
"backup",
|
||||||
|
"completion",
|
||||||
|
"config",
|
||||||
|
"directory",
|
||||||
|
"doctor",
|
||||||
|
"health",
|
||||||
|
"hooks",
|
||||||
|
"logs",
|
||||||
|
"plugins",
|
||||||
|
"secrets",
|
||||||
|
"update",
|
||||||
|
"webhooks",
|
||||||
|
]);
|
||||||
|
|
||||||
function shouldSkipEagerContextWindowWarmup(argv: string[] = process.argv): boolean {
|
function shouldSkipEagerContextWindowWarmup(argv: string[] = process.argv): boolean {
|
||||||
const [primary, secondary] = getCommandPathFromArgv(argv);
|
const [primary] = getCommandPathFromArgv(argv);
|
||||||
return primary === "config" && secondary === "validate";
|
return primary ? SKIP_EAGER_WARMUP_PRIMARY_COMMANDS.has(primary) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function primeConfiguredContextWindows(): OpenClawConfig | undefined {
|
function primeConfiguredContextWindows(): OpenClawConfig | undefined {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue