@@ -53,7 +53,7 @@ func (a *workflowAgent) Description(_ context.Context) string {
5353 return a .description
5454}
5555
56- func (a * workflowAgent ) Run (ctx context.Context , input * AgentInput , _ ... AgentRunOption ) * AsyncIterator [* AgentEvent ] {
56+ func (a * workflowAgent ) Run (ctx context.Context , input * AgentInput , opts ... AgentRunOption ) * AsyncIterator [* AgentEvent ] {
5757 iterator , generator := NewAsyncIteratorPair [* AgentEvent ]()
5858
5959 go func () {
@@ -74,11 +74,11 @@ func (a *workflowAgent) Run(ctx context.Context, input *AgentInput, _ ...AgentRu
7474 // Different workflow execution based on mode
7575 switch a .mode {
7676 case workflowAgentModeSequential :
77- a .runSequential (ctx , input , generator )
77+ a .runSequential (ctx , input , generator , opts ... )
7878 case workflowAgentModeLoop :
79- a .runLoop (ctx , input , generator )
79+ a .runLoop (ctx , input , generator , opts ... )
8080 case workflowAgentModeParallel :
81- a .runParallel (ctx , input , generator )
81+ a .runParallel (ctx , input , generator , opts ... )
8282 default :
8383 err = errors .New (fmt .Sprintf ("unsupported workflow agent mode: %d" , a .mode ))
8484 }
@@ -88,10 +88,10 @@ func (a *workflowAgent) Run(ctx context.Context, input *AgentInput, _ ...AgentRu
8888}
8989
9090func (a * workflowAgent ) runSequential (ctx context.Context , input * AgentInput ,
91- generator * AsyncGenerator [* AgentEvent ]) (exit bool ) {
91+ generator * AsyncGenerator [* AgentEvent ], opts ... AgentRunOption ) (exit bool ) {
9292
9393 for _ , subAgent := range a .subAgents {
94- subIterator := subAgent .Run (ctx , input )
94+ subIterator := subAgent .Run (ctx , input , opts ... )
9595 for {
9696 event , ok := subIterator .Next ()
9797 if ! ok {
@@ -116,22 +116,26 @@ func (a *workflowAgent) runSequential(ctx context.Context, input *AgentInput,
116116 return false
117117}
118118
119- func (a * workflowAgent ) runLoop (ctx context.Context , input * AgentInput , generator * AsyncGenerator [* AgentEvent ]) {
119+ func (a * workflowAgent ) runLoop (ctx context.Context , input * AgentInput ,
120+ generator * AsyncGenerator [* AgentEvent ], opts ... AgentRunOption ) {
121+
120122 if len (a .subAgents ) == 0 {
121123 return
122124 }
123125
124126 var iterations int
125127 for iterations < a .maxIterations || a .maxIterations == 0 {
126128 iterations ++
127- exit := a .runSequential (ctx , input , generator )
129+ exit := a .runSequential (ctx , input , generator , opts ... )
128130 if exit {
129131 return
130132 }
131133 }
132134}
133135
134- func (a * workflowAgent ) runParallel (ctx context.Context , input * AgentInput , generator * AsyncGenerator [* AgentEvent ]) {
136+ func (a * workflowAgent ) runParallel (ctx context.Context , input * AgentInput ,
137+ generator * AsyncGenerator [* AgentEvent ], opts ... AgentRunOption ) {
138+
135139 if len (a .subAgents ) == 0 {
136140 return
137141 }
@@ -150,7 +154,7 @@ func (a *workflowAgent) runParallel(ctx context.Context, input *AgentInput, gene
150154 wg .Done ()
151155 }()
152156
153- iterator := agent .Run (ctx , input )
157+ iterator := agent .Run (ctx , input , opts ... )
154158 for {
155159 event , ok := iterator .Next ()
156160 if ! ok {
0 commit comments