@@ -11,10 +11,8 @@ import {
1111 normalizeSubblockValue ,
1212 normalizeTools ,
1313 resolveBlockRetryUpdate ,
14- updateCanonicalModesForInputs ,
1514} from '@/lib/workflows/editing/builders'
1615import type { SkippedItem } from '@/lib/workflows/editing/types'
17- import { getBlock } from '@/blocks/registry'
1816
1917const { mockIsIntegrationDeploymentAvailable } = vi . hoisted ( ( ) => ( {
2018 mockIsIntegrationDeploymentAvailable : vi . fn ( ( ) => true ) ,
@@ -202,48 +200,6 @@ describe('createBlockFromParams', () => {
202200 } )
203201} )
204202
205- describe ( 'agent permission selections from API inputs' , ( ) => {
206- it ( 'preserves distinct active modes when an unchanged round trip contains both values' , ( ) => {
207- const repeated = Array . from ( { length : 2 } , ( ) => ( {
208- type : 'custom-tool' ,
209- customToolId : 'repeated' ,
210- usageControl : 'force' ,
211- usageControlExpression : 'none' ,
212- } ) )
213- const block = createBlockFromParams ( 'agent' , {
214- type : 'agent' ,
215- name : 'Agent' ,
216- inputs : { tools : repeated } ,
217- } )
218- const modes = { '1:agentToolUsageControl' : 'advanced' as const , model : 'advanced' as const }
219- block . data . canonicalModes = modes
220- block . subBlocks . tools . value = normalizeTools ( structuredClone ( repeated ) )
221-
222- updateCanonicalModesForInputs ( block , [ 'tools' ] , getBlock ( 'agent' ) ! )
223-
224- expect ( block . data . canonicalModes ) . toEqual ( modes )
225- } )
226-
227- it ( 'returns to the Auto default when an API tool omits both permission fields' , ( ) => {
228- const block = createBlockFromParams ( 'agent' , {
229- type : 'agent' ,
230- name : 'Agent' ,
231- inputs : {
232- tools : [ { type : 'custom-tool' , customToolId : 'custom-1' , usageControlExpression : 'none' } ] ,
233- } ,
234- } )
235- block . data . canonicalModes . model = 'advanced'
236- block . subBlocks . tools . value = normalizeTools ( [
237- { type : 'custom-tool' , customToolId : 'custom-1' } ,
238- ] )
239-
240- updateCanonicalModesForInputs ( block , [ 'tools' ] , getBlock ( 'agent' ) ! )
241-
242- expect ( block . data . canonicalModes ) . toEqual ( { model : 'advanced' } )
243- expect ( block . subBlocks . tools . value [ 0 ] . usageControl ) . toBe ( 'auto' )
244- } )
245- } )
246-
247203describe ( 'filterDisallowedTools' , ( ) => {
248204 it ( 'assigns canonical tool modes after removing disallowed tools' , ( ) => {
249205 const block = createBlockFromParams (
@@ -314,6 +270,13 @@ describe('normalizeTools', () => {
314270 } ,
315271 ] )
316272 } )
273+
274+ it ( 'defaults a custom tool reference without either permission field to Auto' , ( ) => {
275+ expect ( normalizeTools ( [ { type : 'custom-tool' , customToolId : 'custom-1' } ] ) [ 0 ] ) . toMatchObject ( {
276+ usageControl : 'auto' ,
277+ usageControlExpression : undefined ,
278+ } )
279+ } )
317280} )
318281
319282describe ( 'normalizeSubblockValue' , ( ) => {
0 commit comments