Skip to content

Commit 35303ae

Browse files
authored
chore: exclude builtin agents in filters by default (#3162)
1 parent 81e4d03 commit 35303ae

File tree

7 files changed

+45
-28
lines changed

7 files changed

+45
-28
lines changed

platform/backend/src/models/agent.test.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1856,15 +1856,29 @@ describe("AgentModel", () => {
18561856
},
18571857
});
18581858

1859-
// Admin can see built-in agents
1859+
// Admin without scope filter excludes built-in agents by default
18601860
const adminResults = await AgentModel.findAllPaginated(
18611861
{ limit: 20, offset: 0 },
18621862
{ sortBy: "createdAt", sortDirection: "desc" },
18631863
{ agentType: "agent" },
18641864
admin.id,
18651865
true,
18661866
);
1867-
expect(adminResults.data).toHaveLength(2);
1867+
expect(adminResults.data).toHaveLength(1);
1868+
expect(adminResults.data[0].name).toBe("Regular Agent");
1869+
1870+
// Admin with scope=built_in sees only built-in agents
1871+
const builtInResults = await AgentModel.findAllPaginated(
1872+
{ limit: 20, offset: 0 },
1873+
{ sortBy: "createdAt", sortDirection: "desc" },
1874+
{ agentType: "agent", scope: "built_in" },
1875+
admin.id,
1876+
true,
1877+
);
1878+
expect(builtInResults.data).toHaveLength(1);
1879+
expect(builtInResults.data[0].name).toBe(
1880+
BUILT_IN_AGENT_NAMES.POLICY_CONFIG,
1881+
);
18681882

18691883
// Non-admin cannot see built-in agents
18701884
const nonAdminResults = await AgentModel.findAllPaginated(

platform/backend/src/models/agent.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,10 @@ class AgentModel {
471471
} else if (filters?.scope === "org") {
472472
whereConditions.push(eq(schema.agentsTable.scope, "org"));
473473
whereConditions.push(eq(schema.agentsTable.builtIn, false));
474+
} else {
475+
// No scope filter: exclude built-in agents by default.
476+
// Built-in agents are only shown when explicitly filtered via scope=built_in.
477+
whereConditions.push(eq(schema.agentsTable.builtIn, false));
474478
}
475479

476480
// Hide built-in agents from non-admin users

platform/e2e-tests/tests/api/built-in-agents.spec.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ async function getBuiltInAgent(
1515
const response = await makeApiRequest({
1616
request,
1717
method: "get",
18-
urlSuffix: "/api/agents?agentTypes=agent&limit=100",
18+
urlSuffix: "/api/agents?agentTypes=agent&scope=built_in&limit=100",
1919
});
2020
const result = await response.json();
2121
const agents = result.data ?? result;
@@ -159,10 +159,25 @@ test.describe("Built-In Agents API", () => {
159159
expect(builtIn).toBeTruthy();
160160
});
161161

162-
test("built-in agent included in /api/agents (agents management page)", async ({
162+
test("built-in agent excluded from /api/agents by default, included with scope=built_in", async ({
163163
request,
164164
makeApiRequest,
165165
}) => {
166+
// Without scope filter, built-in agents should be excluded
167+
const defaultResponse = await makeApiRequest({
168+
request,
169+
method: "get",
170+
urlSuffix: "/api/agents?agentTypes=agent&limit=100",
171+
});
172+
const defaultResult = await defaultResponse.json();
173+
const defaultAgents = defaultResult.data ?? defaultResult;
174+
const excluded = defaultAgents.find(
175+
(a: { builtInAgentConfig?: { name: string } }) =>
176+
a.builtInAgentConfig?.name === BUILT_IN_AGENT_IDS.POLICY_CONFIG,
177+
);
178+
expect(excluded).toBeUndefined();
179+
180+
// With scope=built_in, built-in agents should be included
166181
const builtIn = await getBuiltInAgent(request, makeApiRequest);
167182
expect(builtIn).toBeTruthy();
168183
expect(builtIn.builtInAgentConfig?.name).toBe(

platform/frontend/src/app/mcp/registry/_parts/mcp-exec-terminal.tsx

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
"use client";
22

3-
import {
4-
E2eTestId,
5-
type McpExecClosedMessage,
6-
type McpExecErrorMessage,
7-
type McpExecOutputMessage,
8-
type McpExecStartedMessage,
3+
import type {
4+
McpExecClosedMessage,
5+
McpExecErrorMessage,
6+
McpExecOutputMessage,
7+
McpExecStartedMessage,
98
} from "@shared";
109
import { Copy } from "lucide-react";
1110
import { useCallback, useEffect, useRef, useState } from "react";
@@ -224,10 +223,7 @@ export function McpExecTerminal({ serverId, isActive }: McpExecTerminalProps) {
224223
}, [command]);
225224

226225
return (
227-
<div
228-
className="flex flex-col gap-4 flex-1 min-h-0"
229-
data-testid={E2eTestId.McpDebugTerminal}
230-
>
226+
<div className="flex flex-col gap-4 flex-1 min-h-0">
231227
<div className="flex flex-col gap-2 flex-1 min-h-0">
232228
<h3 className="text-sm font-semibold flex-shrink-0">
233229
Interactive Shell

platform/frontend/src/app/mcp/registry/_parts/mcp-logs-dialog.tsx

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -396,12 +396,7 @@ export function McpLogsDialog({
396396
<Tooltip>
397397
<TooltipTrigger asChild>
398398
<span>
399-
<TabsTrigger
400-
value="debug"
401-
disabled
402-
data-testid={E2eTestId.McpDebugTab}
403-
className="px-6"
404-
>
399+
<TabsTrigger value="debug" disabled className="px-6">
405400
Shell
406401
</TabsTrigger>
407402
</span>
@@ -411,11 +406,7 @@ export function McpLogsDialog({
411406
</TooltipContent>
412407
</Tooltip>
413408
) : (
414-
<TabsTrigger
415-
value="debug"
416-
data-testid={E2eTestId.McpDebugTab}
417-
className="px-6"
418-
>
409+
<TabsTrigger value="debug" className="px-6">
419410
Shell
420411
</TabsTrigger>
421412
)}

platform/frontend/src/components/agent-scope-filter.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ export function AgentScopeFilter({
145145
</SelectTrigger>
146146
<SelectContent position="popper" side="bottom" align="start">
147147
<SelectItem value="all">All types</SelectItem>
148-
<SelectSeparator />
149148
<SelectItem value="personal">Personal</SelectItem>
150149
<SelectItem value="team">Team</SelectItem>
151150
<SelectItem value="org">Organization</SelectItem>

platform/shared/consts.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,7 @@ export const E2eTestId = {
8787
McpLogsError: "mcp-logs-error",
8888
McpLogsViewButton: "mcp-logs-view-button",
8989
McpLogsEditConfigButton: "mcp-logs-edit-config-button",
90-
McpDebugTab: "mcp-debug-tab",
9190
McpLogsTab: "mcp-logs-tab",
92-
McpDebugTerminal: "mcp-debug-terminal",
9391
} as const;
9492
export type E2eTestId = (typeof E2eTestId)[keyof typeof E2eTestId];
9593

0 commit comments

Comments
 (0)