Table of Contents

Class AgentPoolService

Namespace
JD.AI.Gateway.Services
Assembly
JD.AI.Gateway.dll

Manages a pool of live agent instances. Each agent has its own Microsoft.SemanticKernel.Kernel, Microsoft.SemanticKernel.ChatCompletion.ChatHistory, and lifecycle.

public sealed class AgentPoolService : IHostedService
Inheritance
AgentPoolService
Implements
Inherited Members

Constructors

AgentPoolService(IProviderRegistry, IChannelRegistry, IEventBus, ILogger<AgentPoolService>, IMemoryService?, IAgentTaskRegistry?, McpManager?)

public AgentPoolService(IProviderRegistry providers, IChannelRegistry channelRegistry, IEventBus eventBus, ILogger<AgentPoolService> logger, IMemoryService? memoryService = null, IAgentTaskRegistry? taskRegistry = null, McpManager? mcpManager = null)

Parameters

providers IProviderRegistry
channelRegistry IChannelRegistry
eventBus IEventBus
logger ILogger<AgentPoolService>
memoryService IMemoryService
taskRegistry IAgentTaskRegistry
mcpManager McpManager

Properties

DaemonVersion

Daemon version info — set by Daemon host for agent identity enrichment.

public string? DaemonVersion { get; set; }

Property Value

string

LatestDaemonVersion

Latest available daemon version from NuGet — set by Daemon host.

public string? LatestDaemonVersion { get; set; }

Property Value

string

Methods

ClearHistory(string)

public void ClearHistory(string agentId)

Parameters

agentId string

GetDetector(string)

public IProviderDetector? GetDetector(string provider)

Parameters

provider string

Returns

IProviderDetector

ListAgents()

public IReadOnlyList<AgentInfo> ListAgents()

Returns

IReadOnlyList<AgentInfo>

SendMessageAsync(string, ChannelMessage, string, CancellationToken)

public Task<string?> SendMessageAsync(string agentId, ChannelMessage message, string channelType, CancellationToken ct)

Parameters

agentId string
message ChannelMessage
channelType string
ct CancellationToken

Returns

Task<string>

SendMessageAsync(string, ChannelMessage, CancellationToken)

public Task<string?> SendMessageAsync(string agentId, ChannelMessage message, CancellationToken ct)

Parameters

agentId string
message ChannelMessage
ct CancellationToken

Returns

Task<string>

SendMessageAsync(string, string, CancellationToken)

public Task<string?> SendMessageAsync(string agentId, string message, CancellationToken ct)

Parameters

agentId string
message string
ct CancellationToken

Returns

Task<string>

SpawnAgentAsync(string, string, string?, CancellationToken, ModelParameters?, IReadOnlyList<string>?)

public Task<string> SpawnAgentAsync(string provider, string model, string? systemPrompt, CancellationToken ct, ModelParameters? parameters = null, IReadOnlyList<string>? fallbackProviders = null)

Parameters

provider string
model string
systemPrompt string
ct CancellationToken
parameters ModelParameters
fallbackProviders IReadOnlyList<string>

Returns

Task<string>

StartAsync(CancellationToken)

Triggered when the application host is ready to start the service.

public Task StartAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

Indicates that the start process has been aborted.

Returns

Task

A Task that represents the asynchronous Start operation.

StopAgent(string)

public void StopAgent(string agentId)

Parameters

agentId string

StopAsync(CancellationToken)

Triggered when the application host is performing a graceful shutdown.

public Task StopAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

Indicates that the shutdown process should no longer be graceful.

Returns

Task

A Task that represents the asynchronous Stop operation.