fix(agent): show files in tool picker (#6666)

* fix(agent): show files in tool picker

* chore(agent): remove redundant tool exclusions
This commit is contained in:
Justin Blumencranz
2026-08-14 14:20:31 -04:00
committed by GitHub
parent 7f64d5e600
commit 3051954396
5 changed files with 55 additions and 16 deletions
@@ -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', () => {
@@ -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,
@@ -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])
@@ -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.
+8
View File
@@ -69,6 +69,7 @@ vi.mock('@/lib/oauth/utils', () => ({
import type { SubBlockConfig } from '@/blocks/types'
import {
BUILT_IN_TOOL_TYPES,
getApiKeyCondition,
getDependsOnFields,
getSubBlocksDependingOnChange,
@@ -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',
+1 -1
View File
@@ -658,7 +658,7 @@ export function normalizeFileInput(
*/
export const BUILT_IN_TOOL_TYPES = new Set([
'api',
'file',
'file_v5',
'function',
'knowledge',
'search',