@@ -27,7 +27,7 @@ public abstract class AIAgentSubgraphBuilderBase<Input, Output> {
27
27
*
28
28
* @param Input The type of input data that this starting node processes.
29
29
*/
30
- public abstract val nodeStart: StartAIAgentNodeBase <Input >
30
+ public abstract val nodeStart: AIAgentStartNodeBase <Input >
31
31
32
32
/* *
33
33
* Represents the "finish" node in the AI agent's subgraph structure. This node indicates
@@ -43,7 +43,7 @@ public abstract class AIAgentSubgraphBuilderBase<Input, Output> {
43
43
*
44
44
* @param Output The type of data processed and produced by this node.
45
45
*/
46
- public abstract val nodeFinish: FinishAIAgentNodeBase <Output >
46
+ public abstract val nodeFinish: AIAgentFinishNodeBase <Output >
47
47
48
48
/* *
49
49
* Defines a new node in the agent's stage, representing a unit of execution that takes an input and produces an output.
@@ -108,20 +108,20 @@ public abstract class AIAgentSubgraphBuilderBase<Input, Output> {
108
108
vararg nodes : AIAgentNodeBase <Input , Output >,
109
109
dispatcher : CoroutineDispatcher = Dispatchers .Default ,
110
110
name : String? = null,
111
- ): AIAgentNodeDelegateBase <Input , List <ForkedNodeResult <Input , Output >>> {
112
- return AIAgentNodeDelegate (name, ForkNodeBuilder (nodes.asList(), dispatcher))
111
+ ): AIAgentNodeDelegateBase <Input , List <ForkResult <Input , Output >>> {
112
+ return AIAgentNodeDelegate (name, AIAgentForkNodeBuilder (nodes.asList(), dispatcher))
113
113
}
114
114
115
115
/* *
116
116
* Creates a node that merges the results of the forked nodes.
117
- * @param execute Function to merge the contexts after parallel execution
117
+ * @param execute Function to merge the contexts and outputs after parallel execution
118
118
* @param name Optional node name
119
119
*/
120
120
public fun <Input , Output > merge (
121
121
name : String? = null,
122
- execute : suspend AIAgentContextBase .(List <ForkedNodeResult <Input , Output >>) -> Pair <AIAgentContextBase , Output >,
123
- ): AIAgentNodeDelegateBase <List <ForkedNodeResult <Input , Output >>, Output> {
124
- return AIAgentNodeDelegate (name, MergeNodeBuilder (execute))
122
+ execute : suspend AIAgentContextBase .(List <ForkResult <Input , Output >>) -> Pair <AIAgentContextBase , Output >,
123
+ ): AIAgentNodeDelegateBase <List <ForkResult <Input , Output >>, Output> {
124
+ return AIAgentNodeDelegate (name, AIAgentMergeNodeBuilder (execute))
125
125
}
126
126
127
127
/* *
@@ -136,11 +136,11 @@ public abstract class AIAgentSubgraphBuilderBase<Input, Output> {
136
136
}
137
137
138
138
/* *
139
- * Checks if finish node is reachable from start node.
139
+ * Checks if the finish node is reachable from start node.
140
140
* @param start Starting node
141
- * @return True if finish node is reachable
141
+ * @return True if the finish node is reachable
142
142
*/
143
- protected fun isFinishReachable (start : StartAIAgentNodeBase <Input >): Boolean {
143
+ protected fun isFinishReachable (start : AIAgentStartNodeBase <Input >): Boolean {
144
144
val visited = mutableSetOf<AIAgentNodeBase <* , * >>()
145
145
146
146
fun visit (node : AIAgentNodeBase <* , * >): Boolean {
@@ -173,8 +173,8 @@ public class AIAgentSubgraphBuilder<Input, Output>(
173
173
private val toolSelectionStrategy : ToolSelectionStrategy
174
174
) : AIAgentSubgraphBuilderBase<Input, Output>(),
175
175
BaseBuilder <AIAgentSubgraphDelegate <Input , Output >> {
176
- override val nodeStart: StartAIAgentNodeBase <Input > = StartAIAgentNodeBase ()
177
- override val nodeFinish: FinishAIAgentNodeBase <Output > = FinishAIAgentNodeBase ()
176
+ override val nodeStart: AIAgentStartNodeBase <Input > = AIAgentStartNodeBase ()
177
+ override val nodeFinish: AIAgentFinishNodeBase <Output > = AIAgentFinishNodeBase ()
178
178
179
179
override fun build (): AIAgentSubgraphDelegate <Input , Output > {
180
180
require(isFinishReachable(nodeStart)) {
@@ -227,8 +227,8 @@ public interface AIAgentSubgraphDelegateBase<Input, Output> {
227
227
*/
228
228
public open class AIAgentSubgraphDelegate <Input , Output > internal constructor(
229
229
private val name : String? ,
230
- public val nodeStart : StartAIAgentNodeBase <Input >,
231
- public val nodeFinish : FinishAIAgentNodeBase <Output >,
230
+ public val nodeStart : AIAgentStartNodeBase <Input >,
231
+ public val nodeFinish : AIAgentFinishNodeBase <Output >,
232
232
private val toolSelectionStrategy : ToolSelectionStrategy
233
233
) : AIAgentSubgraphDelegateBase<Input, Output> {
234
234
private var subgraph: AIAgentSubgraph <Input , Output >? = null
@@ -258,7 +258,7 @@ public open class AIAgentSubgraphDelegate<Input, Output> internal constructor(
258
258
* @property context Context of the node on the node termination state
259
259
* @property output Output of the node
260
260
*/
261
- public data class ForkedNodeResult <Input , Output >(
261
+ public data class ForkResult <Input , Output >(
262
262
val nodeName : String ,
263
263
val input : Input ,
264
264
val context : AIAgentContextBase ,
@@ -272,10 +272,10 @@ public data class ForkedNodeResult<Input, Output>(
272
272
* @param dispatcher Coroutine dispatcher to use for parallel execution
273
273
*/
274
274
@OptIn(ExperimentalUuidApi ::class )
275
- public class ForkNodeBuilder <Input , Output > internal constructor(
275
+ public class AIAgentForkNodeBuilder <Input , Output > internal constructor(
276
276
private val nodes : List <AIAgentNodeBase <Input , Output >>,
277
277
private val dispatcher : CoroutineDispatcher
278
- ) : AIAgentNodeBuilder<Input, List<ForkedNodeResult <Input, Output>>>(
278
+ ) : AIAgentNodeBuilder<Input, List<ForkResult <Input, Output>>>(
279
279
execute = { input ->
280
280
val initialContext : AIAgentContextBase = this
281
281
val mapResults = supervisorScope {
@@ -284,7 +284,7 @@ public class ForkNodeBuilder<Input, Output> internal constructor(
284
284
val nodeContext = (initialContext as? ai.koog.agents.core.agent.context.AIAgentContext )?.fork()
285
285
? : initialContext.fork()
286
286
val result = node.execute(nodeContext, input)
287
- ForkedNodeResult (node.name, input, nodeContext, result)
287
+ ForkResult (node.name, input, nodeContext, result)
288
288
}
289
289
}
290
290
}
@@ -299,9 +299,9 @@ public class ForkNodeBuilder<Input, Output> internal constructor(
299
299
* @param execute Function to merge the contexts after parallel execution
300
300
*/
301
301
@OptIn(ExperimentalUuidApi ::class )
302
- public class MergeNodeBuilder <Input , Output > internal constructor(
303
- private val execute : suspend AIAgentContextBase .(List <ForkedNodeResult <Input , Output >>) -> Pair <AIAgentContextBase , Output >,
304
- ) : AIAgentNodeBuilder<List<ForkedNodeResult <Input, Output>>, Output>(
302
+ public class AIAgentMergeNodeBuilder <Input , Output > internal constructor(
303
+ private val execute : suspend AIAgentContextBase .(List <ForkResult <Input , Output >>) -> Pair <AIAgentContextBase , Output >,
304
+ ) : AIAgentNodeBuilder<List<ForkResult <Input, Output>>, Output>(
305
305
execute = { input ->
306
306
val (context, output) = execute(input)
307
307
this.replace(context)
0 commit comments