@@ -3497,6 +3497,42 @@ describe('AgentBlockHandler', () => {
34973497 expect ( tools [ 0 ] . parameters . required ) . toContain ( 'format' )
34983498 } )
34993499
3500+ it ( 'resolves a secret-backed customToolId without exposing it to the provider' , async ( ) => {
3501+ const toolId = 'custom-tool-123'
3502+ mockDBForCustomTool ( toolId )
3503+ const registry = new ResolvedSecretTraceRegistry ( [
3504+ {
3505+ name : 'CANARY_CUSTOM_TOOL_ID' ,
3506+ plaintext : toolId ,
3507+ encryptedValue : 'encrypted-custom-tool-id' ,
3508+ } ,
3509+ ] )
3510+ const inputPath = [ 'tools' , '0' , 'customToolId' ] as const
3511+ registry . recordResolvedAtInputPath ( 'CANARY_CUSTOM_TOOL_ID' , toolId , inputPath )
3512+ registry . recordResolvedInputProjection ( inputPath , toolId , '{{CANARY_CUSTOM_TOOL_ID}}' )
3513+ mockContext . resolvedSecretTraceRegistry = registry
3514+
3515+ await handler . execute ( mockContext , mockBlock , {
3516+ model : 'gpt-4o' ,
3517+ userPrompt : 'Format a report' ,
3518+ apiKey : 'test-api-key' ,
3519+ tools : [
3520+ {
3521+ type : 'custom-tool' ,
3522+ customToolId : toolId ,
3523+ usageControl : 'auto' ,
3524+ } ,
3525+ ] ,
3526+ } )
3527+
3528+ expect ( mockGetCustomToolById ) . toHaveBeenCalledWith ( expect . objectContaining ( { toolId } ) )
3529+ const providerRequest = mockExecuteProviderRequest . mock . calls [ 0 ] [ 1 ]
3530+ expect ( providerRequest . tools ) . toHaveLength ( 1 )
3531+ expect ( providerRequest . tools [ 0 ] . name ) . toBe ( 'formatReport' )
3532+ expect ( JSON . stringify ( providerRequest . tools ) ) . not . toContain ( toolId )
3533+ expect ( JSON . stringify ( providerRequest . tools ) ) . not . toContain ( 'CANARY_CUSTOM_TOOL_ID' )
3534+ } )
3535+
35003536 it ( 'should fall back to inline schema when DB fetch fails and inline exists' , async ( ) => {
35013537 mockDBFailure ( )
35023538
0 commit comments