@@ -30,7 +30,12 @@ describe('AkamaiAgentCR', () => {
3030 spec : {
3131 foundationModel : 'gpt-4' ,
3232 agentInstructions : 'You are a helpful assistant' ,
33- knowledgeBase : 'test-kb' ,
33+ tools : [
34+ {
35+ type : 'knowledgeBase' ,
36+ name : 'test-kb' ,
37+ } ,
38+ ] ,
3439 } ,
3540 }
3641
@@ -48,8 +53,16 @@ describe('AkamaiAgentCR', () => {
4853 expect ( agentCR . metadata . namespace ) . toBe ( 'team-team-123' )
4954 expect ( agentCR . metadata . labels ?. [ 'apl.io/teamId' ] ) . toBe ( 'team-123' )
5055 expect ( agentCR . spec . foundationModel ) . toBe ( 'gpt-4' )
51- expect ( agentCR . spec . systemPrompt ) . toBe ( 'You are a helpful assistant' )
52- expect ( agentCR . spec . knowledgeBase ) . toBe ( 'test-kb' )
56+ expect ( agentCR . spec . agentInstructions ) . toBe ( 'You are a helpful assistant' )
57+ expect ( agentCR . spec . tools ) . toEqual ( [
58+ {
59+ type : 'knowledgeBase' ,
60+ name : 'test-kb' ,
61+ description :
62+ 'Search the test-kb knowledge base for relevant information. Use this when you need factual information, documentation, or specific details stored in the knowledge base.' ,
63+ endpoint : undefined ,
64+ } ,
65+ ] )
5366 } )
5467
5568 test ( 'should set teamId label and not merge custom labels' , ( ) => {
@@ -62,18 +75,45 @@ describe('AkamaiAgentCR', () => {
6275 expect ( agentCR . metadata . labels ?. [ 'custom-label' ] ) . toBeUndefined ( )
6376 } )
6477
65- test ( 'should handle request without knowledgeBase' , ( ) => {
66- const requestWithoutKB = {
78+ test ( 'should handle request without tools' , ( ) => {
79+ const requestWithoutTools = {
80+ ...mockAgentRequest ,
81+ spec : {
82+ ...mockAgentRequest . spec ,
83+ tools : undefined ,
84+ } ,
85+ }
86+
87+ const agentCR = new AkamaiAgentCR ( 'team-123' , 'test-agent' , requestWithoutTools )
88+
89+ expect ( agentCR . spec . tools ) . toBeUndefined ( )
90+ } )
91+
92+ test ( 'should handle tools with custom description' , ( ) => {
93+ const requestWithDescription = {
6794 ...mockAgentRequest ,
6895 spec : {
6996 ...mockAgentRequest . spec ,
70- knowledgeBase : undefined ,
97+ tools : [
98+ {
99+ type : 'knowledgeBase' ,
100+ name : 'test-kb' ,
101+ description : 'Custom description for the knowledge base' ,
102+ } ,
103+ ] ,
71104 } ,
72105 }
73106
74- const agentCR = new AkamaiAgentCR ( 'team-123' , 'test-agent' , requestWithoutKB )
107+ const agentCR = new AkamaiAgentCR ( 'team-123' , 'test-agent' , requestWithDescription )
75108
76- expect ( agentCR . spec . knowledgeBase ) . toBeUndefined ( )
109+ expect ( agentCR . spec . tools ) . toEqual ( [
110+ {
111+ type : 'knowledgeBase' ,
112+ name : 'test-kb' ,
113+ description : 'Custom description for the knowledge base' ,
114+ endpoint : undefined ,
115+ } ,
116+ ] )
77117 } )
78118 } )
79119
@@ -108,7 +148,15 @@ describe('AkamaiAgentCR', () => {
108148 spec : {
109149 foundationModel : 'gpt-4' ,
110150 agentInstructions : 'You are a helpful assistant' ,
111- knowledgeBase : 'test-kb' ,
151+ tools : [
152+ {
153+ type : 'knowledgeBase' ,
154+ name : 'test-kb' ,
155+ description :
156+ 'Search the test-kb knowledge base for relevant information. Use this when you need factual information, documentation, or specific details stored in the knowledge base.' ,
157+ endpoint : undefined ,
158+ } ,
159+ ] ,
112160 } ,
113161 status : {
114162 conditions : [
@@ -123,19 +171,48 @@ describe('AkamaiAgentCR', () => {
123171 } )
124172 } )
125173
126- test ( 'should handle empty knowledgeBase in response' , ( ) => {
127- const requestWithoutKB = {
174+ test ( 'should handle empty tools array in response' , ( ) => {
175+ const requestWithoutTools = {
176+ ...mockAgentRequest ,
177+ spec : {
178+ ...mockAgentRequest . spec ,
179+ tools : undefined ,
180+ } ,
181+ }
182+
183+ const agentCR = new AkamaiAgentCR ( 'team-123' , 'test-agent' , requestWithoutTools )
184+ const response = agentCR . toApiResponse ( 'team-123' )
185+
186+ expect ( response . spec . tools ) . toBeUndefined ( )
187+ } )
188+
189+ test ( 'should preserve custom description and endpoint in response' , ( ) => {
190+ const requestWithDetails = {
128191 ...mockAgentRequest ,
129192 spec : {
130193 ...mockAgentRequest . spec ,
131- knowledgeBase : undefined ,
194+ tools : [
195+ {
196+ type : 'knowledgeBase' ,
197+ name : 'test-kb' ,
198+ description : 'Custom KB description' ,
199+ endpoint : 'https://api.example.com/kb' ,
200+ } ,
201+ ] ,
132202 } ,
133203 }
134204
135- const agentCR = new AkamaiAgentCR ( 'team-123' , 'test-agent' , requestWithoutKB )
205+ const agentCR = new AkamaiAgentCR ( 'team-123' , 'test-agent' , requestWithDetails )
136206 const response = agentCR . toApiResponse ( 'team-123' )
137207
138- expect ( response . spec . knowledgeBase ) . toBe ( '' )
208+ expect ( response . spec . tools ) . toEqual ( [
209+ {
210+ type : 'knowledgeBase' ,
211+ name : 'test-kb' ,
212+ description : 'Custom KB description' ,
213+ endpoint : 'https://api.example.com/kb' ,
214+ } ,
215+ ] )
139216 } )
140217 } )
141218
@@ -202,7 +279,7 @@ describe('AkamaiAgentCR', () => {
202279 apiVersion : 'akamai.com/v1' ,
203280 kind : 'Agent' ,
204281 metadata : { name : 'existing-agent' , namespace : 'team-456' } ,
205- spec : { foundationModel : 'gpt-3.5' , systemPrompt : 'Test prompt' } ,
282+ spec : { foundationModel : 'gpt-3.5' , agentInstructions : 'Test prompt' } ,
206283 }
207284
208285 const result = AkamaiAgentCR . fromCR ( crObject )
0 commit comments