@@ -244,7 +244,7 @@ export class Agent {
244244  readonly  purpose ?: string ; 
245245  readonly  instructions : InstructionsDynamicValue ; 
246246  readonly  model : LanguageModel  |  DynamicValue < LanguageModel > ; 
247-   readonly  tools :  ( Tool < any ,   any >   |   Toolkit ) [ ]   |  DynamicValue < ( Tool < any ,  any >  |  Toolkit ) [ ] > ; 
247+   readonly  dynamicTools ?:  DynamicValue < ( Tool < any ,  any >  |  Toolkit ) [ ] > ; 
248248  readonly  hooks : AgentHooks ; 
249249  readonly  temperature ?: number ; 
250250  readonly  maxOutputTokens ?: number ; 
@@ -271,7 +271,7 @@ export class Agent {
271271    this . purpose  =  options . purpose ; 
272272    this . instructions  =  options . instructions ; 
273273    this . model  =  options . model ; 
274-     this . tools  =   options . tools  ||   [ ] ; 
274+     this . dynamicTools   =   typeof   options . tools  ===    "function"  ?  options . tools  :  undefined ; 
275275    this . hooks  =  options . hooks  ||  { } ; 
276276    this . temperature  =  options . temperature ; 
277277    this . maxOutputTokens  =  options . maxOutputTokens ; 
@@ -312,7 +312,7 @@ export class Agent {
312312    this . memoryManager  =  new  MemoryManager ( this . id ,  this . memory ,  { } ,  this . logger ) ; 
313313
314314    // Initialize tool manager with static tools 
315-     const  staticTools  =  typeof  this . tools  ===  "function"  ? [ ]  : this . tools   ||   [ ] ; 
315+     const  staticTools  =  typeof  options . tools  ===  "function"  ? [ ]  : options . tools ; 
316316    this . toolManager  =  new  ToolManager ( staticTools ,  this . logger ) ; 
317317    if  ( options . toolkits )  { 
318318      this . toolManager . addItems ( options . toolkits ) ; 
@@ -1278,10 +1278,6 @@ export class Agent {
12781278    tools : Record < string ,  any > ; 
12791279    maxSteps : number ; 
12801280  } >  { 
1281-     // Resolve dynamic values 
1282-     const  model  =  await  this . resolveValue ( this . model ,  oc ) ; 
1283-     const  agentToolList  =  await  this . resolveValue ( this . tools ,  oc ) ; 
1284- 
12851281    // Prepare messages (system + memory + input) as UIMessages 
12861282    const  buffer  =  this . getConversationBuffer ( oc ) ; 
12871283    const  uiMessages  =  await  this . prepareMessages ( input ,  oc ,  options ,  buffer ) ; 
@@ -1304,10 +1300,13 @@ export class Agent {
13041300    // Calculate maxSteps (use provided option or calculate based on subagents) 
13051301    const  maxSteps  =  options ?. maxSteps  ??  this . calculateMaxSteps ( ) ; 
13061302
1303+     // Resolve dynamic values 
1304+     const  model  =  await  this . resolveValue ( this . model ,  oc ) ; 
1305+     const  dynamicToolList  =  ( await  this . resolveValue ( this . dynamicTools ,  oc ) )  ||  [ ] ; 
1306+ 
13071307    // Merge agent tools with option tools 
1308-     const  agentToolsArray  =  Array . isArray ( agentToolList )  ? agentToolList  : [ ] ; 
13091308    const  optionToolsArray  =  options ?. tools  ||  [ ] ; 
1310-     const  mergedTools  =  [ ...agentToolsArray ,  ...optionToolsArray ] ; 
1309+     const  mergedTools  =  [ ...dynamicToolList ,  ...optionToolsArray ] ; 
13111310
13121311    // Prepare tools with execution context 
13131312    const  tools  =  await  this . prepareTools ( mergedTools ,  oc ,  maxSteps ,  options ) ; 
0 commit comments