diff --git a/src/agents/pi-embedded-runner/run/attempt.ts b/src/agents/pi-embedded-runner/run/attempt.ts index bfe363da303..ac4e0d77d74 100644 --- a/src/agents/pi-embedded-runner/run/attempt.ts +++ b/src/agents/pi-embedded-runner/run/attempt.ts @@ -2835,11 +2835,6 @@ export async function runEmbeddedAttempt( ); } - if (process.env.OPENCLAW_PLUGIN_CHECKPOINTS === "1") { - log.warn( - `[hooks][checkpoints] attempt llm_input runId=${params.runId} sessionKey=${params.sessionKey ?? "unknown"} pid=${process.pid} hookRunner=${hookRunner ? "present" : "missing"} hasHooks=${hookRunner?.hasHooks("llm_input") === true}`, - ); - } if (hookRunner?.hasHooks("llm_input")) { hookRunner .runLlmInput( @@ -3112,11 +3107,6 @@ export async function runEmbeddedAttempt( // Run agent_end hooks to allow plugins to analyze the conversation // This is fire-and-forget, so we don't await // Run even on compaction timeout so plugins can log/cleanup - if (process.env.OPENCLAW_PLUGIN_CHECKPOINTS === "1") { - log.warn( - `[hooks][checkpoints] attempt agent_end runId=${params.runId} sessionKey=${params.sessionKey ?? "unknown"} pid=${process.pid} hookRunner=${hookRunner ? "present" : "missing"} hasHooks=${hookRunner?.hasHooks("agent_end") === true}`, - ); - } if (hookRunner?.hasHooks("agent_end")) { hookRunner .runAgentEnd( @@ -3176,11 +3166,6 @@ export async function runEmbeddedAttempt( ) .map((entry) => ({ toolName: entry.toolName, meta: entry.meta })); - if (process.env.OPENCLAW_PLUGIN_CHECKPOINTS === "1") { - log.warn( - `[hooks][checkpoints] attempt llm_output runId=${params.runId} sessionKey=${params.sessionKey ?? "unknown"} pid=${process.pid} hookRunner=${hookRunner ? "present" : "missing"} hasHooks=${hookRunner?.hasHooks("llm_output") === true}`, - ); - } if (hookRunner?.hasHooks("llm_output")) { hookRunner .runLlmOutput( diff --git a/src/agents/runtime-plugins.test.ts b/src/agents/runtime-plugins.test.ts index 137bc23a699..4025507ec46 100644 --- a/src/agents/runtime-plugins.test.ts +++ b/src/agents/runtime-plugins.test.ts @@ -13,16 +13,16 @@ vi.mock("../plugins/runtime.js", () => ({ getActivePluginRegistryKey: hoisted.getActivePluginRegistryKey, })); -const { ensureRuntimePluginsLoaded } = await import("./runtime-plugins.js"); - describe("ensureRuntimePluginsLoaded", () => { beforeEach(() => { hoisted.loadOpenClawPlugins.mockReset(); hoisted.getActivePluginRegistryKey.mockReset(); hoisted.getActivePluginRegistryKey.mockReturnValue(null); + vi.resetModules(); }); - it("does not reactivate plugins when a process already has an active registry", () => { + it("does not reactivate plugins when a process already has an active registry", async () => { + const { ensureRuntimePluginsLoaded } = await import("./runtime-plugins.js"); hoisted.getActivePluginRegistryKey.mockReturnValue("gateway-registry"); ensureRuntimePluginsLoaded({ @@ -34,7 +34,9 @@ describe("ensureRuntimePluginsLoaded", () => { expect(hoisted.loadOpenClawPlugins).not.toHaveBeenCalled(); }); - it("loads runtime plugins when no active registry exists", () => { + it("loads runtime plugins when no active registry exists", async () => { + const { ensureRuntimePluginsLoaded } = await import("./runtime-plugins.js"); + ensureRuntimePluginsLoaded({ config: {} as never, workspaceDir: "/tmp/workspace", diff --git a/src/infra/diagnostic-events.ts b/src/infra/diagnostic-events.ts index efad1d790f1..5acf0483a8f 100644 --- a/src/infra/diagnostic-events.ts +++ b/src/infra/diagnostic-events.ts @@ -1,7 +1,5 @@ import type { OpenClawConfig } from "../config/config.js"; -const diagnosticCheckpointLogsEnabled = process.env.OPENCLAW_DIAGNOSTIC_CHECKPOINTS === "1"; - export type DiagnosticSessionState = "idle" | "processing" | "waiting"; type DiagnosticBaseEvent = { @@ -208,11 +206,6 @@ export function emitDiagnosticEvent(event: DiagnosticEventInput) { seq: (state.seq += 1), ts: Date.now(), } satisfies DiagnosticEventPayload; - if (diagnosticCheckpointLogsEnabled) { - console.warn( - `[diagnostic-events][checkpoints] emit type=${enriched.type} seq=${enriched.seq} listeners=${state.listeners.size}${"sessionKey" in enriched && typeof enriched.sessionKey === "string" ? ` sessionKey=${enriched.sessionKey}` : ""}`, - ); - } state.dispatchDepth += 1; for (const listener of state.listeners) { try { @@ -236,16 +229,8 @@ export function emitDiagnosticEvent(event: DiagnosticEventInput) { export function onDiagnosticEvent(listener: (evt: DiagnosticEventPayload) => void): () => void { const state = getDiagnosticEventsState(); state.listeners.add(listener); - if (diagnosticCheckpointLogsEnabled) { - console.warn(`[diagnostic-events][checkpoints] subscribe listeners=${state.listeners.size}`); - } return () => { state.listeners.delete(listener); - if (diagnosticCheckpointLogsEnabled) { - console.warn( - `[diagnostic-events][checkpoints] unsubscribe listeners=${state.listeners.size}`, - ); - } }; } diff --git a/src/plugins/hooks.ts b/src/plugins/hooks.ts index 0272481bee8..e8e1e2aa163 100644 --- a/src/plugins/hooks.ts +++ b/src/plugins/hooks.ts @@ -159,7 +159,6 @@ function getHooksForNameAndPlugin( export function createHookRunner(registry: PluginRegistry, options: HookRunnerOptions = {}) { const logger = options.logger; const catchErrors = options.catchErrors ?? true; - const hookCheckpointLogsEnabled = process.env.OPENCLAW_PLUGIN_CHECKPOINTS === "1"; const mergeBeforeModelResolve = ( acc: PluginHookBeforeModelResolveResult | undefined, @@ -251,17 +250,9 @@ export function createHookRunner(registry: PluginRegistry, options: HookRunnerOp } logger?.debug?.(`[hooks] running ${hookName} (${hooks.length} handlers)`); - if (hookCheckpointLogsEnabled) { - logger?.warn( - `[hooks][checkpoints] dispatch ${hookName} handlers=${hooks.map((hook) => hook.pluginId).join(",")}`, - ); - } const promises = hooks.map(async (hook) => { try { - if (hookCheckpointLogsEnabled) { - logger?.warn(`[hooks][checkpoints] invoke ${hookName} plugin=${hook.pluginId}`); - } await (hook.handler as (event: unknown, ctx: unknown) => Promise)(event, ctx); } catch (err) { handleHookError({ hookName, pluginId: hook.pluginId, error: err }); diff --git a/src/plugins/runtime.ts b/src/plugins/runtime.ts index e1a287233e3..c1c8974adc2 100644 --- a/src/plugins/runtime.ts +++ b/src/plugins/runtime.ts @@ -28,16 +28,6 @@ const state: RegistryState = (() => { })(); export function setActivePluginRegistry(registry: PluginRegistry, cacheKey?: string) { - if (process.env.OPENCLAW_PLUGIN_CHECKPOINTS === "1") { - const stack = new Error().stack - ?.split("\n") - .slice(2, 5) - .map((line) => line.trim()) - .join(" | "); - console.warn( - `[plugins][checkpoints] activate registry key=${cacheKey ?? "none"} plugins=${registry.plugins.length} typedHooks=${registry.typedHooks.length}${stack ? ` caller=${stack}` : ""}`, - ); - } state.registry = registry; if (!state.httpRouteRegistryPinned) { state.httpRouteRegistry = registry; diff --git a/src/plugins/services.ts b/src/plugins/services.ts index 73e6c901965..bc1846f1792 100644 --- a/src/plugins/services.ts +++ b/src/plugins/services.ts @@ -5,8 +5,6 @@ import type { PluginRegistry } from "./registry.js"; import type { OpenClawPluginServiceContext, PluginLogger } from "./types.js"; const log = createSubsystemLogger("plugins"); -const pluginCheckpointLogsEnabled = process.env.OPENCLAW_PLUGIN_CHECKPOINTS === "1"; - function createPluginLogger(): PluginLogger { return { info: (msg) => log.info(msg), @@ -48,18 +46,8 @@ export async function startPluginServices(params: { for (const entry of params.registry.services) { const service = entry.service; - const typedHookCountBefore = params.registry.typedHooks.length; try { await service.start(serviceContext); - if (pluginCheckpointLogsEnabled) { - const newTypedHooks = params.registry.typedHooks - .slice(typedHookCountBefore) - .filter((hook) => hook.pluginId === entry.pluginId) - .map((hook) => hook.hookName); - log.warn( - `[plugins][checkpoints] service started (${service.id}, plugin=${entry.pluginId}) typedHooksAdded=${newTypedHooks.length}${newTypedHooks.length > 0 ? ` hooks=${newTypedHooks.join(",")}` : ""}`, - ); - } running.push({ id: service.id, stop: service.stop ? () => service.stop?.(serviceContext) : undefined,