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 });