@@ -14,6 +14,7 @@ import { runProgrammaticStep } from './run-programmatic-step'
1414import { additionalSystemPrompts } from './system-prompt/prompts'
1515import { getAgentTemplate } from './templates/agent-registry'
1616import { getAgentPrompt } from './templates/strings'
17+ import { getToolSet } from './tools/prompts'
1718import { processStreamWithTools } from './tools/stream-parser'
1819import { getAgentOutput } from './util/agent-output'
1920import {
@@ -527,6 +528,7 @@ export async function loopAgentSteps(
527528 | 'spawnParams'
528529 | 'system'
529530 | 'textOverride'
531+ | 'tools'
530532 > &
531533 ParamsExcluding <
532534 AddAgentStepFn ,
@@ -631,6 +633,19 @@ export async function loopAgentSteps(
631633 } ,
632634 } ) ) ?? ''
633635
636+ const tools = await getToolSet ( {
637+ toolNames : agentTemplate . toolNames ,
638+ additionalToolDefinitions : async ( ) => {
639+ if ( ! cachedAdditionalToolDefinitions ) {
640+ cachedAdditionalToolDefinitions = await additionalToolDefinitions ( {
641+ ...params ,
642+ agentTemplate,
643+ } )
644+ }
645+ return cachedAdditionalToolDefinitions
646+ } ,
647+ } )
648+
634649 const hasUserMessage = Boolean (
635650 prompt || ( spawnParams && Object . keys ( spawnParams ) . length > 0 ) ,
636651 )
@@ -786,6 +801,16 @@ export async function loopAgentSteps(
786801 nResponses : generatedResponses ,
787802 } = await runAgentStep ( {
788803 ...params ,
804+
805+ agentState : currentAgentState ,
806+ n,
807+ prompt : currentPrompt ,
808+ runId,
809+ spawnParams : currentParams ,
810+ system,
811+ textOverride : textOverride ,
812+ tools,
813+
789814 additionalToolDefinitions : async ( ) => {
790815 if ( ! cachedAdditionalToolDefinitions ) {
791816 cachedAdditionalToolDefinitions = await additionalToolDefinitions ( {
@@ -795,13 +820,6 @@ export async function loopAgentSteps(
795820 }
796821 return cachedAdditionalToolDefinitions
797822 } ,
798- textOverride : textOverride ,
799- runId,
800- agentState : currentAgentState ,
801- prompt : currentPrompt ,
802- spawnParams : currentParams ,
803- system,
804- n,
805823 } )
806824
807825 if ( newAgentState . runId ) {
0 commit comments