Table of Contents

Class SubagentRunner

Namespace
JD.AI.Core.Agents
Assembly
JD.AI.Core.dll

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

parentSession AgentSession

The owning agent session.

loadoutRegistry IToolLoadoutRegistry

Optional loadout registry. When provided, subagent tool sets are resolved via the registry using the loadout mapped to each SubagentType.

taskRegistry IAgentTaskRegistry

Optional 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

type SubagentType
prompt string
ct CancellationToken

Returns

Task<string>

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

tasks IEnumerable<(SubagentType Type, string Label, string Prompt)>
ct CancellationToken

Returns

Task<IDictionary<string, string>>

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

type SubagentType

The subagent type.

prompt string

The prompt to send to the subagent.

ct CancellationToken

Cancellation token.

Returns

Task<IAgentTask>

An IAgentTask representing the spawned subagent task.