@@ -833,3 +833,86 @@ describe('optional default values', () => {
833833 expect ( result . enabled ) . toBe ( false ) ;
834834 } ) ;
835835} ) ;
836+
837+ describe ( 'tools map support' , ( ) => {
838+ it ( 'includes tools map in completion config from flag variation' , async ( ) => {
839+ const client = new LDAIClientImpl ( mockLdClient ) ;
840+ const key = 'test-flag' ;
841+ const defaultValue : LDAICompletionConfigDefault = { enabled : false } ;
842+ const mockVariation = {
843+ model : { name : 'example-model' } ,
844+ tools : {
845+ 'web-search-tool' : {
846+ name : 'web-search-tool' ,
847+ type : 'function' ,
848+ parameters : { type : 'object' , properties : { } , required : [ ] } ,
849+ customParameters : { 'some-custom-parameter' : 'some-custom-value' } ,
850+ } ,
851+ } ,
852+ _ldMeta : { variationKey : 'v1' , enabled : true , mode : 'completion' } ,
853+ } ;
854+ mockLdClient . variation . mockResolvedValue ( mockVariation ) ;
855+
856+ const result = await client . completionConfig ( key , testContext , defaultValue ) ;
857+
858+ expect ( result . tools ) . toEqual ( mockVariation . tools ) ;
859+ } ) ;
860+
861+ it ( 'includes tools map in agent config from flag variation' , async ( ) => {
862+ const client = new LDAIClientImpl ( mockLdClient ) ;
863+ const key = 'test-agent' ;
864+ const defaultValue : LDAIAgentConfigDefault = { enabled : false } ;
865+ const mockVariation = {
866+ model : { name : 'example-model' } ,
867+ instructions : 'You are a helpful agent.' ,
868+ tools : {
869+ 'search-tool' : {
870+ name : 'search-tool' ,
871+ type : 'function' ,
872+ customParameters : { maxResults : 10 } ,
873+ } ,
874+ } ,
875+ _ldMeta : { variationKey : 'v1' , enabled : true , mode : 'agent' } ,
876+ } ;
877+ mockLdClient . variation . mockResolvedValue ( mockVariation ) ;
878+
879+ const result = await client . agentConfig ( key , testContext , defaultValue ) ;
880+
881+ expect ( result . tools ) . toEqual ( mockVariation . tools ) ;
882+ } ) ;
883+
884+ it ( 'returns undefined tools when variation has no tools' , async ( ) => {
885+ const client = new LDAIClientImpl ( mockLdClient ) ;
886+ const key = 'test-flag' ;
887+ const defaultTools = {
888+ 'default-tool' : {
889+ name : 'default-tool' ,
890+ type : 'function' ,
891+ customParameters : { priority : 'high' } ,
892+ } ,
893+ } ;
894+ const defaultValue : LDAICompletionConfigDefault = { enabled : true , tools : defaultTools } ;
895+ mockLdClient . variation . mockResolvedValue ( {
896+ _ldMeta : { enabled : true , mode : 'completion' , variationKey : '' } ,
897+ } ) ;
898+
899+ const result = await client . completionConfig ( key , testContext , defaultValue ) ;
900+
901+ expect ( result . tools ) . toBeUndefined ( ) ;
902+ } ) ;
903+
904+ it ( 'returns undefined tools when no tools are configured' , async ( ) => {
905+ const client = new LDAIClientImpl ( mockLdClient ) ;
906+ const key = 'test-flag' ;
907+ const defaultValue : LDAICompletionConfigDefault = { enabled : false } ;
908+ const mockVariation = {
909+ model : { name : 'example-model' } ,
910+ _ldMeta : { variationKey : 'v1' , enabled : true , mode : 'completion' } ,
911+ } ;
912+ mockLdClient . variation . mockResolvedValue ( mockVariation ) ;
913+
914+ const result = await client . completionConfig ( key , testContext , defaultValue ) ;
915+
916+ expect ( result . tools ) . toBeUndefined ( ) ;
917+ } ) ;
918+ } ) ;
0 commit comments