From e07c51b045457999321b4dc853349897807a7efc Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Sun, 1 Mar 2026 17:13:58 -0800 Subject: [PATCH] CLI: avoid plugin preload for health --json route (#31108) * CLI routes: skip plugin preload for health --json * CLI routes tests: cover health --json plugin preload --- src/cli/program/routes.test.ts | 7 +++++-- src/cli/program/routes.ts | 6 +++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/cli/program/routes.test.ts b/src/cli/program/routes.test.ts index f9932bc93..eb4b7351c 100644 --- a/src/cli/program/routes.test.ts +++ b/src/cli/program/routes.test.ts @@ -18,9 +18,12 @@ describe("program routes", () => { expect(route?.loadPlugins).toBe(true); }); - it("matches health route and preloads plugins for channel diagnostics", () => { + it("matches health route and preloads plugins only for text output", () => { const route = expectRoute(["health"]); - expect(route?.loadPlugins).toBe(true); + expect(typeof route?.loadPlugins).toBe("function"); + const shouldLoad = route?.loadPlugins as (argv: string[]) => boolean; + expect(shouldLoad(["node", "openclaw", "health"])).toBe(true); + expect(shouldLoad(["node", "openclaw", "health", "--json"])).toBe(false); }); it("returns false when status timeout flag value is missing", async () => { diff --git a/src/cli/program/routes.ts b/src/cli/program/routes.ts index 9bc18162a..ccecd8548 100644 --- a/src/cli/program/routes.ts +++ b/src/cli/program/routes.ts @@ -9,9 +9,9 @@ export type RouteSpec = { const routeHealth: RouteSpec = { match: (path) => path[0] === "health", - // Health output uses channel plugin metadata for account fallback/log details. - // Keep routed behavior aligned with non-routed command execution. - loadPlugins: true, + // `health --json` only relays gateway RPC output and does not need local plugin metadata. + // Keep plugin preload for text output where channel diagnostics/logSelfId are rendered. + loadPlugins: (argv) => !hasFlag(argv, "--json"), run: async (argv) => { const json = hasFlag(argv, "--json"); const verbose = getVerboseFlag(argv, { includeDebug: true });