Skip to content

Commit 62ecc3d

Browse files
authored
Revert " feat: Add internal builtin tools (read_file, list_files) with compa…"
This reverts commit 849faf5.
1 parent 27e4824 commit 62ecc3d

File tree

16 files changed

+5
-338
lines changed

16 files changed

+5
-338
lines changed

apps/api/src/modules/skill/skill-engine.service.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -248,13 +248,6 @@ export class SkillEngineService implements OnModuleInit {
248248
const result = await this.driveService.getDriveFileDetail(user, fileId);
249249
return result;
250250
},
251-
listFiles: async (user, canvasId) => {
252-
const result = await this.driveService.listDriveFiles(user, {
253-
canvasId,
254-
scope: 'present',
255-
});
256-
return result;
257-
},
258251
writeFile: async (user, param) => {
259252
return await this.driveService.createDriveFile(user, param);
260253
},

apps/api/src/modules/skill/skill.service.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,11 @@ import { AutoModelRouter } from '../provider/auto-model-router.service';
7070
/**
7171
* Fixed builtin toolsets that are always available for node_agent mode.
7272
* These toolsets will be automatically appended to user-selected toolsets.
73-
* Internal tools (read_file, list_files) are system-level tools hidden from mentionList.
7473
* Note: IDs must match BuiltinToolsetDefinition.tools[].name for instantiateBuiltinToolsets to work.
7574
*/
7675
const FIXED_BUILTIN_TOOLSETS: GenericToolset[] = [
7776
{ type: 'regular', id: 'execute_code', name: 'execute_code', builtin: true },
7877
{ type: 'regular', id: 'read_file', name: 'read_file', builtin: true },
79-
{ type: 'regular', id: 'list_files', name: 'list_files', builtin: true },
8078
{ type: 'regular', id: 'get_time', name: 'get_time', builtin: true },
8179
];
8280

apps/api/src/modules/tool/tool.service.ts

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,9 @@ export class ToolService {
7878
return key === 'web_search';
7979
}
8080

81-
/**
82-
* Check if a toolset should be exposed to users in mentionList.
83-
* Filters out deprecated and internal (system-level) toolsets.
84-
* Internal toolsets are auto-included by the system and not user-selectable.
85-
*/
86-
private shouldExposeToolset(key?: string, options?: { internal?: boolean }): boolean {
81+
private shouldExposeToolset(key?: string): boolean {
8782
if (!key) return true;
88-
if (this.isDeprecatedToolset(key)) return false;
89-
// Filter out internal/system-level toolsets (e.g., read_file, list_files)
90-
if (options?.internal) return false;
91-
return true;
83+
return !this.isDeprecatedToolset(key);
9284
}
9385

9486
async getToolsetInventory(): Promise<
@@ -115,8 +107,6 @@ export class ToolService {
115107

116108
/**
117109
* Load toolset inventory from sources (builtin + external)
118-
* Note: This is for /tool/inventory/list API, which includes all tools for rendering.
119-
* Internal tools are NOT filtered here as they need to be available for ToolCall rendering.
120110
*/
121111
private async loadToolsetInventory(): Promise<ToolsetDefinition[]> {
122112
const builtinInventory = Object.values(builtinToolsetInventory).map((toolset) => ({
@@ -176,18 +166,11 @@ export class ToolService {
176166
return [...authorizedItems, ...unauthorizedItems];
177167
}
178168

179-
/**
180-
* List builtin tools for mentionList.
181-
* Filters out internal (system-level) tools that are auto-included.
182-
*/
183169
listBuiltinTools(): GenericToolset[] {
184170
return Object.values(builtinToolsetInventory)
185171
.filter(
186172
(toolset) =>
187-
Boolean(toolset.definition) &&
188-
this.shouldExposeToolset(toolset.definition.key, {
189-
internal: toolset.definition.internal,
190-
}),
173+
Boolean(toolset.definition) && this.shouldExposeToolset(toolset.definition.key),
191174
)
192175
.map((toolset) => ({
193176
type: ToolsetType.REGULAR,

packages/agent-tools/src/builtin/index.ts

Lines changed: 2 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,6 @@ export const BuiltinToolsetDefinition: ToolsetDefinition = {
3434
},
3535
modelOnly: true,
3636
},
37-
{
38-
name: 'list_files',
39-
descriptionDict: {
40-
en: 'List all files in the current canvas.',
41-
'zh-CN': '列出当前画布中的所有文件。',
42-
},
43-
modelOnly: true,
44-
},
4537
{
4638
name: 'generate_doc',
4739
descriptionDict: {
@@ -147,7 +139,7 @@ export const BuiltinSendEmailDefinition: ToolsetDefinition = {
147139

148140
export const BuiltinGetTimeDefinition: ToolsetDefinition = {
149141
key: 'get_time',
150-
// internal: true - This tool should be visible in mentionList for user selection
142+
internal: true,
151143
labelDict: {
152144
en: 'Get Time',
153145
'zh-CN': '获取时间',
@@ -160,7 +152,6 @@ export const BuiltinGetTimeDefinition: ToolsetDefinition = {
160152

161153
export const BuiltinReadFileDefinition: ToolsetDefinition = {
162154
key: 'read_file',
163-
// System-level tool, auto-included, hidden from mentionList, uses compact rendering
164155
internal: true,
165156
labelDict: {
166157
en: 'Read File',
@@ -174,7 +165,7 @@ export const BuiltinReadFileDefinition: ToolsetDefinition = {
174165

175166
export const BuiltinExecuteCodeDefinition: ToolsetDefinition = {
176167
key: 'execute_code',
177-
// internal: true - This tool should be visible in mentionList for user selection
168+
internal: true,
178169
labelDict: {
179170
en: 'Execute Code',
180171
'zh-CN': '执行代码',
@@ -185,20 +176,6 @@ export const BuiltinExecuteCodeDefinition: ToolsetDefinition = {
185176
},
186177
};
187178

188-
export const BuiltinListFilesDefinition: ToolsetDefinition = {
189-
key: 'list_files',
190-
// System-level tool, auto-included, hidden from mentionList, uses compact rendering
191-
internal: true,
192-
labelDict: {
193-
en: 'List Files',
194-
'zh-CN': '列出文件',
195-
},
196-
descriptionDict: {
197-
en: 'List all files in the current canvas.',
198-
'zh-CN': '列出当前画布中的所有文件。',
199-
},
200-
};
201-
202179
export class BuiltinLibrarySearch extends AgentBaseTool<BuiltinToolParams> {
203180
name = 'library_search';
204181
toolsetKey = 'library_search';
@@ -764,10 +741,6 @@ export class BuiltinReadFile extends AgentBaseTool<BuiltinToolParams> {
764741

765742
schema = z.object({
766743
fileId: z.string().describe('The ID of the file to read (format: df-xxx, from context)'),
767-
fileName: z
768-
.string()
769-
.optional()
770-
.describe('Optional file name for frontend display purpose only'),
771744
});
772745

773746
description = `Read content from a file.
@@ -808,74 +781,6 @@ Latency: <2s`;
808781
}
809782
}
810783

811-
export class BuiltinListFiles extends AgentBaseTool<BuiltinToolParams> {
812-
name = 'list_files';
813-
toolsetKey = 'list_files';
814-
815-
// No parameters needed - canvasId is obtained from context automatically
816-
schema = z.object({});
817-
818-
description = `List all files in the current canvas.
819-
820-
Returns a list of files with their IDs and names. Use the fileId with read_file tool to read file content.`;
821-
822-
protected params: BuiltinToolParams;
823-
824-
constructor(params: BuiltinToolParams) {
825-
super(params);
826-
this.params = params;
827-
}
828-
829-
async _call(
830-
_input: z.infer<typeof this.schema>,
831-
_: unknown,
832-
config: RunnableConfig,
833-
): Promise<ToolCallResult> {
834-
try {
835-
const { reflyService, user } = this.params;
836-
const canvasId = config.configurable?.canvasId;
837-
838-
if (!canvasId) {
839-
return {
840-
status: 'error',
841-
error: 'Canvas ID not found in context',
842-
summary: 'Cannot list files: canvas context is not available',
843-
};
844-
}
845-
846-
const files = await reflyService.listFiles(user, canvasId);
847-
848-
if (!files || files.length === 0) {
849-
return {
850-
status: 'success',
851-
data: [],
852-
summary: 'No files found in the current canvas',
853-
};
854-
}
855-
856-
// Return simplified file info for LLM consumption
857-
const fileList = files.map((f) => ({
858-
fileId: f.fileId,
859-
fileName: f.name,
860-
type: f.type,
861-
}));
862-
863-
return {
864-
status: 'success',
865-
data: fileList,
866-
summary: `Found ${files.length} file(s) in the canvas: ${files.map((f) => f.name).join(', ')}`,
867-
};
868-
} catch (error) {
869-
return {
870-
status: 'error',
871-
error: 'Error listing files',
872-
summary:
873-
error instanceof Error ? error.message : 'Unknown error occurred while listing files',
874-
};
875-
}
876-
}
877-
}
878-
879784
export class BuiltinLibrarySearchToolset extends AgentBaseToolset<BuiltinToolParams> {
880785
toolsetKey = BuiltinLibrarySearchDefinition.key;
881786
tools = [BuiltinLibrarySearch] satisfies readonly AgentToolConstructor<BuiltinToolParams>[];
@@ -913,11 +818,6 @@ export class BuiltinReadFileToolset extends AgentBaseToolset<BuiltinToolParams>
913818
tools = [BuiltinReadFile] satisfies readonly AgentToolConstructor<BuiltinToolParams>[];
914819
}
915820

916-
export class BuiltinListFilesToolset extends AgentBaseToolset<BuiltinToolParams> {
917-
toolsetKey = BuiltinListFilesDefinition.key;
918-
tools = [BuiltinListFiles] satisfies readonly AgentToolConstructor<BuiltinToolParams>[];
919-
}
920-
921821
export class BuiltinExecuteCodeToolset extends AgentBaseToolset<BuiltinToolParams> {
922822
toolsetKey = BuiltinExecuteCodeDefinition.key;
923823
tools = [BuiltinExecuteCode] satisfies readonly AgentToolConstructor<BuiltinToolParams>[];
@@ -932,7 +832,6 @@ export class BuiltinToolset extends AgentBaseToolset<BuiltinToolParams> {
932832
BuiltinSendEmail,
933833
BuiltinGetTime,
934834
BuiltinReadFile,
935-
BuiltinListFiles,
936835
BuiltinExecuteCode,
937836
] satisfies readonly AgentToolConstructor<BuiltinToolParams>[];
938837
}

packages/agent-tools/src/builtin/interface.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ export interface ReflyService {
8282
options?: { topN?: number; relevanceThreshold?: number },
8383
) => Promise<RerankResponse>;
8484
readFile: (user: User, fileId: string) => Promise<DriveFile>;
85-
listFiles: (user: User, canvasId: string) => Promise<DriveFile[]>;
8685
writeFile: (user: User, param: UpsertDriveFileRequest) => Promise<DriveFile>;
8786
inMemorySearchWithIndexing: (
8887
user: User,

packages/agent-tools/src/inventory.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ import {
1212
BuiltinGetTimeDefinition,
1313
BuiltinReadFileToolset,
1414
BuiltinReadFileDefinition,
15-
BuiltinListFilesToolset,
16-
BuiltinListFilesDefinition,
1715
BuiltinExecuteCodeToolset,
1816
BuiltinExecuteCodeDefinition,
1917
} from './builtin';
@@ -67,10 +65,6 @@ export const builtinToolsetInventory: Record<
6765
class: BuiltinReadFileToolset,
6866
definition: BuiltinReadFileDefinition,
6967
},
70-
[BuiltinListFilesDefinition.key]: {
71-
class: BuiltinListFilesToolset,
72-
definition: BuiltinListFilesDefinition,
73-
},
7468
[BuiltinExecuteCodeDefinition.key]: {
7569
class: BuiltinExecuteCodeToolset,
7670
definition: BuiltinExecuteCodeDefinition,

packages/ai-workspace-common/src/components/markdown/plugins/tool-call/internal-tool-renderers/default-renderer.tsx

Lines changed: 0 additions & 24 deletions
This file was deleted.

packages/ai-workspace-common/src/components/markdown/plugins/tool-call/internal-tool-renderers/index.scss

Lines changed: 0 additions & 23 deletions
This file was deleted.

packages/ai-workspace-common/src/components/markdown/plugins/tool-call/internal-tool-renderers/index.tsx

Lines changed: 0 additions & 33 deletions
This file was deleted.

packages/ai-workspace-common/src/components/markdown/plugins/tool-call/internal-tool-renderers/list-files-renderer.tsx

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)