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
agentAgentThe agent to invoke.
inputstringThe input to pass to the agent.
resultNamestringName to record under
OrchestrationContext.Results. When omitted, the host uses the agent's persona (hosted path) or no rename happens (standalone path).cancellationTokenCancellationTokenCancellation token.
Returns
- Task<AgentExecutionResult>
The AgentExecutionResult, or null if a BeforeAgentExecution handler skipped the agent.