@@ -48,10 +48,22 @@ const mockConstants = {
4848jest . mock ( '../src/constants' , ( ) => mockConstants )
4949
5050// Import after mocks are set up
51- import { type ContactInfo , VerbosityLevel } from '@botonic/core'
51+ import { type ContactInfo } from '@botonic/core'
5252
53+ import type { LLMConfig } from '../src/llm-config'
5354import { AIAgentBuilder } from '../src/agent-builder'
5455
56+ // Mock LLMConfig for tests (builder uses modelName and modelSettings for logging)
57+ const mockLlmConfig = {
58+ modelName : 'gpt-4.1-mini' ,
59+ modelSettings : {
60+ reasoning : { effort : 'none' as const } ,
61+ text : { verbosity : 'medium' as const } ,
62+ toolChoice : undefined as string | undefined ,
63+ } ,
64+ modelProvider : { } ,
65+ } as unknown as LLMConfig
66+
5567describe ( 'AIAgentBuilder' , ( ) => {
5668 const agentName = 'Test Agent'
5769 const agentInstructions = 'Test instructions for the agent'
@@ -117,7 +129,7 @@ describe('AIAgentBuilder', () => {
117129 const aiAgent = new AIAgentBuilder ( {
118130 name : agentName ,
119131 instructions : agentInstructions ,
120- verbosity : VerbosityLevel . Medium ,
132+ llmConfig : mockLlmConfig ,
121133 tools : agentCustomTools ,
122134 contactInfo,
123135 inputGuardrailRules,
@@ -246,7 +258,7 @@ describe('AIAgentBuilder', () => {
246258 const aiAgent = new AIAgentBuilder ( {
247259 name : agentName ,
248260 instructions : agentInstructions ,
249- verbosity : VerbosityLevel . Medium ,
261+ llmConfig : mockLlmConfig ,
250262 tools : agentCustomTools ,
251263 contactInfo,
252264 inputGuardrailRules : [ ] ,
@@ -270,7 +282,7 @@ describe('AIAgentBuilder', () => {
270282 const aiAgent = new AIAgentBuilder ( {
271283 name : agentName ,
272284 instructions : agentInstructions ,
273- verbosity : VerbosityLevel . Medium ,
285+ llmConfig : mockLlmConfig ,
274286 tools : agentCustomTools ,
275287 contactInfo,
276288 inputGuardrailRules : [ ] ,
@@ -294,7 +306,7 @@ describe('AIAgentBuilder', () => {
294306 const aiAgent = new AIAgentBuilder ( {
295307 name : agentName ,
296308 instructions : agentInstructions ,
297- verbosity : VerbosityLevel . Medium ,
309+ llmConfig : mockLlmConfig ,
298310 tools : agentCustomTools ,
299311 contactInfo,
300312 inputGuardrailRules : [ ] ,
@@ -319,7 +331,7 @@ describe('AIAgentBuilder', () => {
319331 const aiAgent = new AIAgentBuilder ( {
320332 name : agentName ,
321333 instructions : agentInstructions ,
322- verbosity : VerbosityLevel . Medium ,
334+ llmConfig : mockLlmConfig ,
323335 tools : agentCustomTools ,
324336 contactInfo,
325337 inputGuardrailRules : [ ] ,
@@ -341,7 +353,7 @@ describe('AIAgentBuilder', () => {
341353 const aiAgent = new AIAgentBuilder ( {
342354 name : agentName ,
343355 instructions : agentInstructions ,
344- verbosity : VerbosityLevel . Medium ,
356+ llmConfig : mockLlmConfig ,
345357 tools : agentCustomTools ,
346358 contactInfo,
347359 inputGuardrailRules : [ ] ,
@@ -350,19 +362,20 @@ describe('AIAgentBuilder', () => {
350362 logger : mockLogger ,
351363 } ) . build ( )
352364
353- // When using azure provider with retrieveKnowledge, toolChoice should be set
354- expect ( capturedAgentConfig ) . toBeDefined ( )
355- expect ( capturedAgentConfig . modelSettings ) . toBeDefined ( )
356- expect ( capturedAgentConfig . modelSettings . toolChoice ) . toBe (
357- 'retrieve_knowledge'
365+ // When using azure provider with retrieveKnowledge, logModelSettings is called
366+ expect ( mockLogger . logModelSettings ) . toHaveBeenCalledWith (
367+ expect . objectContaining ( {
368+ provider : 'azure' ,
369+ hasRetrieveKnowledge : true ,
370+ } )
358371 )
359372 } )
360373
361374 it ( 'should NOT set toolChoice when sourceIds is empty (no retrieveKnowledge)' , ( ) => {
362375 const aiAgent = new AIAgentBuilder ( {
363376 name : agentName ,
364377 instructions : agentInstructions ,
365- verbosity : VerbosityLevel . Medium ,
378+ llmConfig : mockLlmConfig ,
366379 tools : agentCustomTools ,
367380 contactInfo,
368381 inputGuardrailRules : [ ] ,
@@ -371,17 +384,19 @@ describe('AIAgentBuilder', () => {
371384 logger : mockLogger ,
372385 } ) . build ( )
373386
374- expect ( capturedAgentConfig ) . toBeDefined ( )
375- // When no retrieveKnowledge tool, toolChoice should not be set
376- expect ( capturedAgentConfig . modelSettings . toolChoice ) . toBeUndefined ( )
387+ expect ( mockLogger . logModelSettings ) . toHaveBeenCalledWith (
388+ expect . objectContaining ( {
389+ hasRetrieveKnowledge : false ,
390+ } )
391+ )
377392 } )
378393
379- it ( 'should NOT set model for azure provider (uses deployment name)' , ( ) => {
394+ it ( 'should set model ( deployment name) for azure provider ' , ( ) => {
380395 // Default OPENAI_PROVIDER is 'azure'
381396 const aiAgent = new AIAgentBuilder ( {
382397 name : agentName ,
383398 instructions : agentInstructions ,
384- verbosity : VerbosityLevel . Medium ,
399+ llmConfig : mockLlmConfig ,
385400 tools : agentCustomTools ,
386401 contactInfo,
387402 inputGuardrailRules : [ ] ,
@@ -391,16 +406,16 @@ describe('AIAgentBuilder', () => {
391406 } ) . build ( )
392407
393408 expect ( capturedAgentConfig ) . toBeDefined ( )
394- // Azure uses deployment name, not model
395- expect ( capturedAgentConfig . model ) . toBeUndefined ( )
409+ // Azure uses deployment name as model
410+ expect ( capturedAgentConfig . model ) . toBe ( 'gpt-4.1-mini' )
396411 } )
397412
398413 it ( 'should set reasoning and text settings for azure provider (same as openai)' , ( ) => {
399414 // Default OPENAI_PROVIDER is 'azure'
400415 const aiAgent = new AIAgentBuilder ( {
401416 name : agentName ,
402417 instructions : agentInstructions ,
403- verbosity : VerbosityLevel . Medium ,
418+ llmConfig : mockLlmConfig ,
404419 tools : agentCustomTools ,
405420 contactInfo,
406421 inputGuardrailRules : [ ] ,
@@ -409,14 +424,14 @@ describe('AIAgentBuilder', () => {
409424 logger : mockLogger ,
410425 } ) . build ( )
411426
412- expect ( capturedAgentConfig ) . toBeDefined ( )
413- // Azure now receives same reasoning and text settings as OpenAI
414- expect ( capturedAgentConfig . modelSettings . reasoning ) . toEqual ( {
415- effort : 'none ' ,
416- } )
417- expect ( capturedAgentConfig . modelSettings . text ) . toEqual ( {
418- verbosity : 'medium' ,
419- } )
427+ expect ( mockLogger . logModelSettings ) . toHaveBeenCalledWith (
428+ expect . objectContaining ( {
429+ provider : 'azure' ,
430+ model : 'gpt-4.1-mini ' ,
431+ reasoning : { effort : 'none' } ,
432+ text : { verbosity : 'medium' } ,
433+ } )
434+ )
420435 } )
421436 } )
422437} )
@@ -462,7 +477,7 @@ describe('AIAgentBuilder - OpenAI Provider', () => {
462477 new AIAgentBuilder ( {
463478 name : agentName ,
464479 instructions : agentInstructions ,
465- verbosity : VerbosityLevel . Medium ,
480+ llmConfig : mockLlmConfig ,
466481 tools : agentCustomTools ,
467482 contactInfo,
468483 inputGuardrailRules : [ ] ,
@@ -471,17 +486,19 @@ describe('AIAgentBuilder - OpenAI Provider', () => {
471486 logger : mockLogger ,
472487 } ) . build ( )
473488
474- expect ( capturedAgentConfig ) . toBeDefined ( )
475- expect ( capturedAgentConfig . modelSettings . reasoning ) . toEqual ( {
476- effort : 'none' ,
477- } )
489+ expect ( mockLogger . logModelSettings ) . toHaveBeenCalledWith (
490+ expect . objectContaining ( {
491+ provider : 'openai' ,
492+ reasoning : { effort : 'none' } ,
493+ } )
494+ )
478495 } )
479496
480497 it ( 'should set text setting with verbosity: medium for openai provider' , ( ) => {
481498 new AIAgentBuilder ( {
482499 name : agentName ,
483500 instructions : agentInstructions ,
484- verbosity : VerbosityLevel . Medium ,
501+ llmConfig : mockLlmConfig ,
485502 tools : agentCustomTools ,
486503 contactInfo,
487504 inputGuardrailRules : [ ] ,
@@ -490,17 +507,18 @@ describe('AIAgentBuilder - OpenAI Provider', () => {
490507 logger : mockLogger ,
491508 } ) . build ( )
492509
493- expect ( capturedAgentConfig ) . toBeDefined ( )
494- expect ( capturedAgentConfig . modelSettings . text ) . toEqual ( {
495- verbosity : 'medium' ,
496- } )
510+ expect ( mockLogger . logModelSettings ) . toHaveBeenCalledWith (
511+ expect . objectContaining ( {
512+ text : { verbosity : 'medium' } ,
513+ } )
514+ )
497515 } )
498516
499517 it ( 'should set model to OPENAI_MODEL for openai provider' , ( ) => {
500518 new AIAgentBuilder ( {
501519 name : agentName ,
502520 instructions : agentInstructions ,
503- verbosity : VerbosityLevel . Medium ,
521+ llmConfig : mockLlmConfig ,
504522 tools : agentCustomTools ,
505523 contactInfo,
506524 inputGuardrailRules : [ ] ,
@@ -517,7 +535,7 @@ describe('AIAgentBuilder - OpenAI Provider', () => {
517535 new AIAgentBuilder ( {
518536 name : agentName ,
519537 instructions : agentInstructions ,
520- verbosity : VerbosityLevel . Medium ,
538+ llmConfig : mockLlmConfig ,
521539 tools : agentCustomTools ,
522540 contactInfo,
523541 inputGuardrailRules : [ ] ,
@@ -526,8 +544,11 @@ describe('AIAgentBuilder - OpenAI Provider', () => {
526544 logger : mockLogger ,
527545 } ) . build ( )
528546
529- expect ( capturedAgentConfig ) . toBeDefined ( )
530- // OpenAI provider should NOT set toolChoice (only azure does)
531- expect ( capturedAgentConfig . modelSettings . toolChoice ) . toBeUndefined ( )
547+ expect ( mockLogger . logModelSettings ) . toHaveBeenCalledWith (
548+ expect . objectContaining ( {
549+ provider : 'openai' ,
550+ hasRetrieveKnowledge : true ,
551+ } )
552+ )
532553 } )
533554} )
0 commit comments