Table of Contents

Method ExecuteAgentAsync

Namespace
LMKit.Agents.Orchestration.Nodes
Assembly
LM-Kit.NET.dll

ExecuteAgentAsync(Agent, string, string, CancellationToken)

Runs an agent inside this graph's host orchestrator so BeforeAgentExecution, AfterAgentExecution, distributed-trace spans, and streaming behave identically to a prebuilt orchestrator stage.

Use this from a custom IOrchestrationNode when you want to invoke an agent (for routing, classification, transformation, etc.) and have it participate in the orchestrator's full lifecycle. When no host is attached, this falls back to a plain RunAsync(string, AgentExecutionOptions, CancellationToken) call and records the result under resultName on the shared OrchestrationContext.

public Task<AgentExecutionResult> ExecuteAgentAsync(Agent agent, string input, string resultName = null, CancellationToken cancellationToken = default)

Parameters

agent Agent

The agent to invoke.

input string

The input to pass to the agent.

resultName string

Name to record under OrchestrationContext.Results. When omitted, the host uses the agent's persona (hosted path) or no rename happens (standalone path).

cancellationToken CancellationToken

Cancellation token.

Returns

Task<AgentExecutionResult>

The AgentExecutionResult, or null if a BeforeAgentExecution handler skipped the agent.

Share