perf(test): speed up vitest by skipping plugins + LLM slug

This commit is contained in:
Peter Steinberger
2026-02-07 07:57:50 +00:00
parent 626a1d0699
commit 9f507112b5
6 changed files with 61 additions and 9 deletions

View File

@@ -14,6 +14,7 @@ import { createSubsystemLogger } from "../logging/subsystem.js";
import { resolveUserPath } from "../utils.js";
import { clearPluginCommands } from "./commands.js";
import {
applyTestPluginDefaults,
normalizePluginsConfig,
resolveEnableState,
resolveMemorySlotDecision,
@@ -167,7 +168,9 @@ function pushDiagnostics(diagnostics: PluginDiagnostic[], append: PluginDiagnost
}
export function loadOpenClawPlugins(options: PluginLoadOptions = {}): PluginRegistry {
const cfg = options.config ?? {};
// Test env: default-disable plugins unless explicitly configured.
// This keeps unit/gateway suites fast and avoids loading heavyweight plugin deps by accident.
const cfg = applyTestPluginDefaults(options.config ?? {}, process.env);
const logger = options.logger ?? defaultLogger();
const validateOnly = options.mode === "validate";
const normalized = normalizePluginsConfig(cfg.plugins);

View File

@@ -2,6 +2,7 @@ import type { AnyAgentTool } from "../agents/tools/common.js";
import type { OpenClawPluginToolContext } from "./types.js";
import { normalizeToolName } from "../agents/tool-policy.js";
import { createSubsystemLogger } from "../logging/subsystem.js";
import { applyTestPluginDefaults, normalizePluginsConfig } from "./config-state.js";
import { loadOpenClawPlugins } from "./loader.js";
const log = createSubsystemLogger("plugins");
@@ -45,8 +46,16 @@ export function resolvePluginTools(params: {
existingToolNames?: Set<string>;
toolAllowlist?: string[];
}): AnyAgentTool[] {
// Fast path: when plugins are effectively disabled, avoid discovery/jiti entirely.
// This matters a lot for unit tests and for tool construction hot paths.
const effectiveConfig = applyTestPluginDefaults(params.context.config ?? {}, process.env);
const normalized = normalizePluginsConfig(effectiveConfig.plugins);
if (!normalized.enabled) {
return [];
}
const registry = loadOpenClawPlugins({
config: params.context.config,
config: effectiveConfig,
workspaceDir: params.context.workspaceDir,
logger: {
info: (msg) => log.info(msg),