Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,32 @@
import { describe, expect, it } from 'vitest'
import type { StoredTool } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/types'
import {
isAgentToolBlock,
isCustomToolAlreadySelected,
isMcpToolAlreadySelected,
isWorkflowAlreadySelected,
} from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/utils'

describe('isAgentToolBlock', () => {
it('includes the current File block', () => {
expect(isAgentToolBlock({ type: 'file_v5', category: 'blocks', hideFromToolbar: false })).toBe(
true
)
})

it('excludes hidden blocks such as the legacy File block', () => {
expect(isAgentToolBlock({ type: 'file', category: 'blocks', hideFromToolbar: true })).toBe(
false
)
})

it('does not make every visible core block agent-callable', () => {
expect(isAgentToolBlock({ type: 'memory', category: 'blocks', hideFromToolbar: false })).toBe(
false
)
})
})

describe('isMcpToolAlreadySelected', () => {
describe('basic functionality', () => {
it.concurrent('returns false when selectedTools is empty', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import { ToolSubBlockRenderer } from '@/app/workspace/[workspaceId]/w/[workflowI
import { clearDependentToolParams } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/param-dependents'
import type { StoredTool } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/types'
import {
isAgentToolBlock,
isCustomToolAlreadySelected,
isMcpToolAlreadySelected,
isWorkflowAlreadySelected,
Expand Down Expand Up @@ -665,21 +666,7 @@ export const ToolInput = memo(function ToolInput({

const customBlockOverlayVersion = useCustomBlockOverlayVersion()
const toolBlocks = useMemo(() => {
const allToolBlocks = getAllBlocks().filter(
(block) =>
!block.hideFromToolbar &&
(block.category === 'tools' ||
block.type === 'api' ||
block.type === 'webhook_request' ||
block.type === 'workflow' ||
block.type === 'workflow_input' ||
block.type === 'knowledge' ||
block.type === 'function' ||
block.type === 'table') &&
block.type !== 'evaluator' &&
block.type !== 'mcp' &&
block.type !== 'file'
)
const allToolBlocks = getAllBlocks().filter(isAgentToolBlock)
return filterBlocks(allToolBlocks)
}, [filterBlocks, customBlockOverlayVersion])

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
import type { StoredTool } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/types'
import type { BlockConfig } from '@/blocks/types'

const CORE_AGENT_TOOL_TYPES = new Set([
'api',
'webhook_request',
'workflow',
'workflow_input',
'knowledge',
'function',
'table',
'file_v5',
])

/**
* Checks whether a registered block should appear in the agent tool picker.
*/
export function isAgentToolBlock(
block: Pick<BlockConfig, 'category' | 'hideFromToolbar' | 'type'>
): boolean {
return (
!block.hideFromToolbar && (block.category === 'tools' || CORE_AGENT_TOOL_TYPES.has(block.type))
)
}

/**
* Checks if an MCP tool is already selected.
Expand Down
8 changes: 8 additions & 0 deletions apps/sim/blocks/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ vi.mock('@/lib/oauth/utils', () => ({

import type { SubBlockConfig } from '@/blocks/types'
import {
BUILT_IN_TOOL_TYPES,
getApiKeyCondition,
getDependsOnFields,
getSubBlocksDependingOnChange,
Expand All @@ -77,6 +78,13 @@ import {
parseOptionalNumberInput,
} from '@/blocks/utils'

describe('BUILT_IN_TOOL_TYPES', () => {
it('classifies the current File block instead of the legacy File block', () => {
expect(BUILT_IN_TOOL_TYPES.has('file_v5')).toBe(true)
expect(BUILT_IN_TOOL_TYPES.has('file')).toBe(false)
})
})

const BASE_CLOUD_MODELS: Record<string, string> = {
'gpt-4o': 'openai',
'claude-sonnet-4-5': 'anthropic',
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/blocks/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ export function normalizeFileInput(
*/
export const BUILT_IN_TOOL_TYPES = new Set([
'api',
'file',
'file_v5',
'function',
'knowledge',
'search',
Expand Down
Loading