fix(ui): hide system agent from agent roster (#111677)

This commit is contained in:
Peter Steinberger
2026-07-19 22:46:02 -07:00
committed by GitHub
parent a22ede72e4
commit 71513436f9
2 changed files with 19 additions and 1 deletions
+17
View File
@@ -1,11 +1,28 @@
/**
* Gateway agent-list RPC regression tests.
*/
import fs from "node:fs/promises";
import path from "node:path";
import { describe, expect, it } from "vitest";
import type { OpenClawConfig } from "../config/config.js";
import { withStateDirEnv } from "../test-helpers/state-dir-env.js";
import { listGatewayAgentsBasic } from "./agent-list.js";
describe("listGatewayAgentsBasic", () => {
it("omits reserved system-agent state directories from the discovered roster", async () => {
await withStateDirEnv("openclaw-agent-list-", async ({ stateDir }) => {
await Promise.all(
["openclaw", "crestodian", "research"].map((id) =>
fs.mkdir(path.join(stateDir, "agents", id), { recursive: true }),
),
);
const result = listGatewayAgentsBasic({});
expect(result.agents.map((agent) => agent.id)).toEqual(["main", "research"]);
});
});
it("falls back to identity.name when the configured agent name is missing", () => {
const cfg: OpenClawConfig = {
session: { mainKey: "main" },
+2 -1
View File
@@ -8,6 +8,7 @@ import { resolveStateDir } from "../config/paths.js";
import type { SessionScope } from "../config/sessions.js";
import type { OpenClawConfig } from "../config/types.openclaw.js";
import { normalizeAgentId, normalizeMainKey } from "../routing/session-key.js";
import { isReservedSystemAgentId } from "../system-agent/agent-id.js";
type GatewayAgentListRow = {
id: string;
@@ -22,7 +23,7 @@ function listExistingAgentIdsFromDisk(): string[] {
return entries
.filter((entry) => entry.isDirectory())
.map((entry) => normalizeAgentId(entry.name))
.filter(Boolean);
.filter((id) => id && !isReservedSystemAgentId(id));
} catch {
return [];
}