Skip to content

ChildAgentInvoker

Namespace AgentPrism · Assembly AgentPrism.Core.dll

Wraps a sub-agent an agent may call; enforces depth, budget, and tenant limits and links the sub-run into the tree.

public sealed class ChildAgentInvoker : AIAgent

object ← AIAgent ← ChildAgentInvoker

AIAgent.GetService(Type, object?), AIAgent.GetService<TService>(object?), AIAgent.CreateSessionAsync(CancellationToken), AIAgent.SerializeSessionAsync(AgentSession, JsonSerializerOptions?, CancellationToken), AIAgent.DeserializeSessionAsync(JsonElement, JsonSerializerOptions?, CancellationToken), AIAgent.RunAsync(AgentSession?, AgentRunOptions?, CancellationToken), AIAgent.RunAsync(string, AgentSession?, AgentRunOptions?, CancellationToken), AIAgent.RunAsync(ChatMessage, AgentSession?, AgentRunOptions?, CancellationToken), AIAgent.RunAsync(IEnumerable<ChatMessage>, AgentSession?, AgentRunOptions?, CancellationToken), AIAgent.RunStreamingAsync(AgentSession?, AgentRunOptions?, CancellationToken), AIAgent.RunStreamingAsync(string, AgentSession?, AgentRunOptions?, CancellationToken), AIAgent.RunStreamingAsync(ChatMessage, AgentSession?, AgentRunOptions?, CancellationToken), AIAgent.RunStreamingAsync(IEnumerable<ChatMessage>, AgentSession?, AgentRunOptions?, CancellationToken), AIAgent.RunAsync<T>(AgentSession?, JsonSerializerOptions?, AgentRunOptions?, CancellationToken), AIAgent.RunAsync<T>(string, AgentSession?, JsonSerializerOptions?, AgentRunOptions?, CancellationToken), AIAgent.RunAsync<T>(ChatMessage, AgentSession?, JsonSerializerOptions?, AgentRunOptions?, CancellationToken), AIAgent.RunAsync<T>(IEnumerable<ChatMessage>, AgentSession?, JsonSerializerOptions?, AgentRunOptions?, CancellationToken), AIAgent.Id, AIAgent.Name, AIAgent.Description, AIAgent.CurrentRunContext, object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

This is not an IAgentDecorator. Decorators apply to every agent resolved from the catalog; this wrapper only intervenes when one agent appears in another agent’s view. It does not touch the decorator order (recording 0 → telemetry 10 → approval 20).

The sub-agent is resolved late. This way, the calling agent’s compiled copy does not go stale when the sub-agent’s definition changes.

Microsoft Agent Framework calls the sub-agent with options = null . Tree information therefore cannot be read from the incoming options; the wrapper reads it from the AgentPrismRunContext scope and builds the AgentPrismRunOptions object itself.

ChildAgentInvoker(CallableAgentResolver, ITenantContext, ILogger, string, CallableAgentInfo)

Section titled “ ChildAgentInvoker(CallableAgentResolver, ITenantContext, ILogger, string, CallableAgentInfo)”

Creates a new sub-agent wrapper.

public ChildAgentInvoker(CallableAgentResolver resolver, ITenantContext tenantContext, ILogger logger, string callerName, CallableAgentInfo child)

resolver CallableAgentResolver

Resolver that resolves the sub-agent from the catalog.

tenantContext ITenantContext

Tenant context.

logger ILogger

Logger.

callerName string

Name of the calling agent.

child CallableAgentInfo

Summary of the sub-agent being called.

ArgumentNullException

One of the required dependencies is null.

public override string? Description { get; }

string?

public override string Name { get; }

string

CreateSessionCoreAsync(CancellationToken)

Section titled “ CreateSessionCoreAsync(CancellationToken)”
protected override ValueTask<AgentSession> CreateSessionCoreAsync(CancellationToken cancellationToken = default)

cancellationToken CancellationToken

ValueTask<AgentSession>

DeserializeSessionCoreAsync(JsonElement, JsonSerializerOptions?, CancellationToken)

Section titled “ DeserializeSessionCoreAsync(JsonElement, JsonSerializerOptions?, CancellationToken)”
protected override ValueTask<AgentSession> DeserializeSessionCoreAsync(JsonElement serializedState, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default)

serializedState JsonElement

jsonSerializerOptions JsonSerializerOptions?

cancellationToken CancellationToken

ValueTask<AgentSession>

RunCoreAsync(IEnumerable<ChatMessage>, AgentSession?, AgentRunOptions?, CancellationToken)

Section titled “ RunCoreAsync(IEnumerable<ChatMessage>, AgentSession?, AgentRunOptions?, CancellationToken)”
protected override Task<AgentResponse> RunCoreAsync(IEnumerable<ChatMessage> messages, AgentSession? session = null, AgentRunOptions? options = null, CancellationToken cancellationToken = default)

messages IEnumerable<ChatMessage>

session AgentSession?

options AgentRunOptions?

cancellationToken CancellationToken

Task<AgentResponse>

RunCoreStreamingAsync(IEnumerable<ChatMessage>, AgentSession?, AgentRunOptions?, CancellationToken)

Section titled “ RunCoreStreamingAsync(IEnumerable<ChatMessage>, AgentSession?, AgentRunOptions?, CancellationToken)”
protected override IAsyncEnumerable<AgentResponseUpdate> RunCoreStreamingAsync(IEnumerable<ChatMessage> messages, AgentSession? session = null, AgentRunOptions? options = null, CancellationToken cancellationToken = default)

messages IEnumerable<ChatMessage>

session AgentSession?

options AgentRunOptions?

cancellationToken CancellationToken

IAsyncEnumerable<AgentResponseUpdate>

SerializeSessionCoreAsync(AgentSession, JsonSerializerOptions?, CancellationToken)

Section titled “ SerializeSessionCoreAsync(AgentSession, JsonSerializerOptions?, CancellationToken)”
protected override ValueTask<JsonElement> SerializeSessionCoreAsync(AgentSession session, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default)

session AgentSession

jsonSerializerOptions JsonSerializerOptions?

cancellationToken CancellationToken

ValueTask<JsonElement>