Constructor ParallelNode
- Namespace
- LMKit.Agents.Orchestration.Nodes
- Assembly
- LM-Kit.NET.dll
ParallelNode(string, IEnumerable<IOrchestrationNode>, Func<IReadOnlyList<NodeResult>, string>, int?)
Initializes a new ParallelNode.
public ParallelNode(string name, IEnumerable<IOrchestrationNode> children, Func<IReadOnlyList<NodeResult>, string> aggregator = null, int? maxParallelism = null)
Parameters
namestringStable trace name for this node.
childrenIEnumerable<IOrchestrationNode>Children to run concurrently.
aggregatorFunc<IReadOnlyList<NodeResult>, string>Optional combiner that produces a single output string from the children's results. null uses DefaultAggregator(IReadOnlyList<NodeResult>) (newline-separated outputs).
maxParallelismint?Optional cap on concurrent children. null runs all children concurrently.
Examples
Fan out two perspectives in parallel and join their outputs:
using LMKit.Model;
using LMKit.Agents;
using LMKit.Agents.Orchestration.Nodes;
using var model = LM.LoadFromModelID("qwen3:8b");
var optimist = Agent.CreateBuilder(model).WithPersona("Optimist").Build();
var pessimist = Agent.CreateBuilder(model).WithPersona("Pessimist").Build();
var graph = new ParallelNode("perspectives",
new IOrchestrationNode[]
{
new AgentNode("optimist", optimist),
new AgentNode("pessimist", pessimist)
});
var orchestrator = new GraphOrchestrator(graph);
var result = await orchestrator.ExecuteAsync("Cloud computing trade-offs");
// result.Content is the newline-joined output from both branches.