mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-12 09:41:11 +00:00
fix: skip agent context eager warmup on import
This commit is contained in:
30
src/agents/context.eager-warmup.test.ts
Normal file
30
src/agents/context.eager-warmup.test.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
const loadConfigMock = vi.hoisted(() => vi.fn());
|
||||
|
||||
vi.mock("../config/config.js", () => ({
|
||||
loadConfig: loadConfigMock,
|
||||
}));
|
||||
|
||||
describe("agents/context eager warmup", () => {
|
||||
const originalArgv = process.argv.slice();
|
||||
|
||||
beforeEach(() => {
|
||||
vi.resetModules();
|
||||
loadConfigMock.mockReset();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
process.argv = originalArgv.slice();
|
||||
});
|
||||
|
||||
it.each([
|
||||
["models", ["node", "openclaw", "models", "set", "openai/gpt-5.4"]],
|
||||
["agent", ["node", "openclaw", "agent", "--message", "ok"]],
|
||||
])("does not eager-load config for %s commands on import", async (_label, argv) => {
|
||||
process.argv = argv;
|
||||
await import("./context.js");
|
||||
|
||||
expect(loadConfigMock).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
@@ -129,6 +129,7 @@ function getCommandPathFromArgv(argv: string[]): string[] {
|
||||
}
|
||||
|
||||
const SKIP_EAGER_WARMUP_PRIMARY_COMMANDS = new Set([
|
||||
"agent",
|
||||
"backup",
|
||||
"completion",
|
||||
"config",
|
||||
@@ -138,6 +139,7 @@ const SKIP_EAGER_WARMUP_PRIMARY_COMMANDS = new Set([
|
||||
"health",
|
||||
"hooks",
|
||||
"logs",
|
||||
"models",
|
||||
"plugins",
|
||||
"secrets",
|
||||
"status",
|
||||
|
||||
Reference in New Issue
Block a user