Skip to content

Commit 3051954

Browse files
authored
fix(agent): show files in tool picker (#6666)
* fix(agent): show files in tool picker * chore(agent): remove redundant tool exclusions
1 parent 7f64d5e commit 3051954

5 files changed

Lines changed: 55 additions & 16 deletions

File tree

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/tool-input.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,32 @@
44
import { describe, expect, it } from 'vitest'
55
import type { StoredTool } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/types'
66
import {
7+
isAgentToolBlock,
78
isCustomToolAlreadySelected,
89
isMcpToolAlreadySelected,
910
isWorkflowAlreadySelected,
1011
} from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/utils'
1112

13+
describe('isAgentToolBlock', () => {
14+
it('includes the current File block', () => {
15+
expect(isAgentToolBlock({ type: 'file_v5', category: 'blocks', hideFromToolbar: false })).toBe(
16+
true
17+
)
18+
})
19+
20+
it('excludes hidden blocks such as the legacy File block', () => {
21+
expect(isAgentToolBlock({ type: 'file', category: 'blocks', hideFromToolbar: true })).toBe(
22+
false
23+
)
24+
})
25+
26+
it('does not make every visible core block agent-callable', () => {
27+
expect(isAgentToolBlock({ type: 'memory', category: 'blocks', hideFromToolbar: false })).toBe(
28+
false
29+
)
30+
})
31+
})
32+
1233
describe('isMcpToolAlreadySelected', () => {
1334
describe('basic functionality', () => {
1435
it.concurrent('returns false when selectedTools is empty', () => {

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/tool-input.tsx

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import { ToolSubBlockRenderer } from '@/app/workspace/[workspaceId]/w/[workflowI
4646
import { clearDependentToolParams } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/param-dependents'
4747
import type { StoredTool } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/types'
4848
import {
49+
isAgentToolBlock,
4950
isCustomToolAlreadySelected,
5051
isMcpToolAlreadySelected,
5152
isWorkflowAlreadySelected,
@@ -665,21 +666,7 @@ export const ToolInput = memo(function ToolInput({
665666

666667
const customBlockOverlayVersion = useCustomBlockOverlayVersion()
667668
const toolBlocks = useMemo(() => {
668-
const allToolBlocks = getAllBlocks().filter(
669-
(block) =>
670-
!block.hideFromToolbar &&
671-
(block.category === 'tools' ||
672-
block.type === 'api' ||
673-
block.type === 'webhook_request' ||
674-
block.type === 'workflow' ||
675-
block.type === 'workflow_input' ||
676-
block.type === 'knowledge' ||
677-
block.type === 'function' ||
678-
block.type === 'table') &&
679-
block.type !== 'evaluator' &&
680-
block.type !== 'mcp' &&
681-
block.type !== 'file'
682-
)
669+
const allToolBlocks = getAllBlocks().filter(isAgentToolBlock)
683670
return filterBlocks(allToolBlocks)
684671
}, [filterBlocks, customBlockOverlayVersion])
685672

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/utils.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,27 @@
11
import type { StoredTool } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/types'
2+
import type { BlockConfig } from '@/blocks/types'
3+
4+
const CORE_AGENT_TOOL_TYPES = new Set([
5+
'api',
6+
'webhook_request',
7+
'workflow',
8+
'workflow_input',
9+
'knowledge',
10+
'function',
11+
'table',
12+
'file_v5',
13+
])
14+
15+
/**
16+
* Checks whether a registered block should appear in the agent tool picker.
17+
*/
18+
export function isAgentToolBlock(
19+
block: Pick<BlockConfig, 'category' | 'hideFromToolbar' | 'type'>
20+
): boolean {
21+
return (
22+
!block.hideFromToolbar && (block.category === 'tools' || CORE_AGENT_TOOL_TYPES.has(block.type))
23+
)
24+
}
225

326
/**
427
* Checks if an MCP tool is already selected.

apps/sim/blocks/utils.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ vi.mock('@/lib/oauth/utils', () => ({
6969

7070
import type { SubBlockConfig } from '@/blocks/types'
7171
import {
72+
BUILT_IN_TOOL_TYPES,
7273
getApiKeyCondition,
7374
getDependsOnFields,
7475
getSubBlocksDependingOnChange,
@@ -77,6 +78,13 @@ import {
7778
parseOptionalNumberInput,
7879
} from '@/blocks/utils'
7980

81+
describe('BUILT_IN_TOOL_TYPES', () => {
82+
it('classifies the current File block instead of the legacy File block', () => {
83+
expect(BUILT_IN_TOOL_TYPES.has('file_v5')).toBe(true)
84+
expect(BUILT_IN_TOOL_TYPES.has('file')).toBe(false)
85+
})
86+
})
87+
8088
const BASE_CLOUD_MODELS: Record<string, string> = {
8189
'gpt-4o': 'openai',
8290
'claude-sonnet-4-5': 'anthropic',

apps/sim/blocks/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ export function normalizeFileInput(
658658
*/
659659
export const BUILT_IN_TOOL_TYPES = new Set([
660660
'api',
661-
'file',
661+
'file_v5',
662662
'function',
663663
'knowledge',
664664
'search',

0 commit comments

Comments
 (0)