.NET API
RunRecordingAgent
Tracon.Core.dllRun completion: usage/cost merging, error mapping, and the terminal store
write. RunRecordingAgent.CompleteAsync fans out to the root-only notifications
in RunRecordingAgent.Notifications.cs, but owns the outcome itself.
public sealed class RunRecordingAgent : DelegatingAIAgent- Inheritance
- object ← AIAgent ← DelegatingAIAgent ← RunRecordingAgent
- Inherited Members
- DelegatingAIAgent.GetService(Type, object?), DelegatingAIAgent.Name, DelegatingAIAgent.Description, 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()
Remarks
Section titled “Remarks”This is not a Microsoft Agent Framework middleware but a
AI.DelegatingAIAgent wrapper. The reason: the MAF middleware chain is
specific to one agent, and HarnessAgent adds its own inner decorators.
The outer wrapper works the same way on every agent type, the harness included.
Tool calls are read from the AI.FunctionCallContent and
AI.FunctionResultContent contents that MAF produces; no separate hook is necessary.
The root span starts here. The wrapper is the outermost decorator
(Order = 0), therefore the tracon.run span that it opens collects the
spans of the inner wrappers and of the model calls as children. This is the only way
to link the run identifier and the trace identifier to each other.
Tracon builds this wrapper around every agent that IAgentCatalog resolves; resolve the agent through the catalog instead of constructing the wrapper.
Methods
Section titled “Methods”RunCoreAsync(IEnumerable<ChatMessage>, AgentSession?, AgentRunOptions?, CancellationToken)
Section titled “ RunCoreAsync(IEnumerable<ChatMessage>, AgentSession?, AgentRunOptions?, CancellationToken)”Core implementation of the agent invocation logic with a collection of chat messages.
protected override Task<AgentResponse> RunCoreAsync(IEnumerable<ChatMessage> messages, AgentSession? session = null, AgentRunOptions? options = null, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”messages IEnumerable<ChatMessage>
The collection of messages to send to the agent for processing.
session AgentSession?
The conversation session to use for this invocation. If null, a new session will be created. The session will be updated with the input messages and any response messages generated during invocation.
options AgentRunOptions?
Optional configuration parameters for controlling the agent’s invocation behavior.
cancellationToken CancellationToken
The CancellationToken to monitor for cancellation requests. The default is CancellationToken.None.
Returns
Section titled “Returns”Task<AgentResponse>
A task that represents the asynchronous operation. The task result contains an AI.AgentResponse with the agent’s output.
Remarks
Section titled “Remarks”This is the primary invocation method that implementations must override. It handles collections of messages, allowing for complex conversational scenarios including multi-turn interactions, function calls, and context-rich conversations.
The messages are processed in the order provided and become part of the conversation history.
The agent’s response will also be added to session if one is provided.
RunCoreStreamingAsync(IEnumerable<ChatMessage>, AgentSession?, AgentRunOptions?, CancellationToken)
Section titled “ RunCoreStreamingAsync(IEnumerable<ChatMessage>, AgentSession?, AgentRunOptions?, CancellationToken)”Core implementation of the agent streaming invocation logic with a collection of chat messages.
protected override IAsyncEnumerable<AgentResponseUpdate> RunCoreStreamingAsync(IEnumerable<ChatMessage> messages, AgentSession? session = null, AgentRunOptions? options = null, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”messages IEnumerable<ChatMessage>
The collection of messages to send to the agent for processing.
session AgentSession?
The conversation session to use for this invocation. If null, a new session will be created. The session will be updated with the input messages and any response updates generated during invocation.
options AgentRunOptions?
Optional configuration parameters for controlling the agent’s invocation behavior.
cancellationToken CancellationToken
The CancellationToken to monitor for cancellation requests. The default is CancellationToken.None.
Returns
Section titled “Returns”IAsyncEnumerable<AgentResponseUpdate>
An asynchronous enumerable of AI.AgentResponseUpdate instances representing the streaming response.
Remarks
Section titled “Remarks”This is the primary streaming invocation method that implementations must override. It provides real-time updates as the agent processes the input and generates its response, enabling more responsive user experiences.
Each AI.AgentResponseUpdate represents a portion of the complete response, allowing consumers
to display partial results, implement progressive loading, or provide immediate feedback to users.