Class SubagentRunner
Manages subagent lifecycle: creates isolated Kernel instances with scoped tools, runs a single turn, and returns the result string.
public sealed class SubagentRunner
- Inheritance
-
SubagentRunner
- Inherited Members
Constructors
SubagentRunner(AgentSession, IToolLoadoutRegistry?, IAgentTaskRegistry?)
Initialises a SubagentRunner using the parent session's kernel and tools.
public SubagentRunner(AgentSession parentSession, IToolLoadoutRegistry? loadoutRegistry = null, IAgentTaskRegistry? taskRegistry = null)
Parameters
parentSessionAgentSessionThe owning agent session.
loadoutRegistryIToolLoadoutRegistryOptional loadout registry. When provided, subagent tool sets are resolved via the registry using the loadout mapped to each SubagentType.
taskRegistryIAgentTaskRegistryOptional task registry for tracking concurrent subagent tasks.
Methods
RunAsync(SubagentType, string, CancellationToken)
Spawns a subagent of the given type, sends it a prompt, and returns its response. The subagent runs in the same process but with its own Kernel, ChatHistory, and scoped tools.
public Task<string> RunAsync(SubagentType type, string prompt, CancellationToken ct = default)
Parameters
typeSubagentTypepromptstringctCancellationToken
Returns
RunParallelAsync(IEnumerable<(SubagentType Type, string Label, string Prompt)>, CancellationToken)
Spawns multiple subagents in parallel and returns all results.
public Task<IDictionary<string, string>> RunParallelAsync(IEnumerable<(SubagentType Type, string Label, string Prompt)> tasks, CancellationToken ct = default)
Parameters
tasksIEnumerable<(SubagentType Type, string Label, string Prompt)>ctCancellationToken
Returns
SpawnAsync(SubagentType, string, CancellationToken)
Spawns a subagent as a tracked concurrent task and returns immediately. The task executes asynchronously and is registered in the task registry if available.
public Task<IAgentTask> SpawnAsync(SubagentType type, string prompt, CancellationToken ct = default)
Parameters
typeSubagentTypeThe subagent type.
promptstringThe prompt to send to the subagent.
ctCancellationTokenCancellation token.
Returns
- Task<IAgentTask>
An IAgentTask representing the spawned subagent task.