Agent Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Base abstraction for all Semantic Kernel agents. An agent instance may participate in one or more conversations, or AgentChat. A conversation may include one or more agents.
public abstract class Agent
type Agent = class
Public MustInherit Class Agent
- Inheritance
-
Agent
- Derived
Remarks
In addition to identity and descriptive meta-data, an Agent must define its communication protocol, or AgentChannel.
Constructors
Agent() |
Properties
ActiveLoggerFactory |
Get the active logger factory, if defined; otherwise, provide the default. |
Arguments |
Gets the arguments for the agent instruction parameters (optional). |
Description |
Gets the description of the agent (optional). |
Id |
Gets the identifier of the agent (optional). |
Instructions |
Gets the instructions for the agent (optional). |
Kernel |
Gets the Kernel containing services, plugins, and filters for use throughout the agent lifetime. |
Logger | |
LoggerFactory |
A ILoggerFactory for this Agent. |
Name |
Gets the name of the agent (optional). |
Template |
Gets or sets a prompt template based on the agent instructions. |
Methods
CreateChannelAsync(CancellationToken) |
Produce an AgentChannel appropriate for the agent type. |
EnsureThreadExistsWithMessagesAsync<TThreadType>(ICollection<ChatMessageContent>, AgentThread, Func<TThreadType>, CancellationToken) |
Ensures that the thread exists, is of the expected type, and is active, plus adds the provided message to the thread. |
GetChannelKeys() |
Set of keys to establish channel affinity. Minimum expected key-set: <example> yield return typeof(YourAgentChannel).FullName; </example> |
InvokeAsync(AgentThread, AgentInvokeOptions, CancellationToken) |
Invoke the agent with no message assuming that all required instructions are already provided to the agent or on the thread. |
InvokeAsync(ChatMessageContent, AgentThread, AgentInvokeOptions, CancellationToken) |
Invoke the agent with the provided message and arguments. |
InvokeAsync(ICollection<ChatMessageContent>, AgentThread, AgentInvokeOptions, CancellationToken) |
Invoke the agent with the provided message and arguments. |
InvokeAsync(String, AgentThread, AgentInvokeOptions, CancellationToken) |
Invoke the agent with the provided message and arguments. |
InvokeStreamingAsync(AgentThread, AgentInvokeOptions, CancellationToken) |
Invoke the agent with no message assuming that all required instructions are already provided to the agent or on the thread. |
InvokeStreamingAsync(ChatMessageContent, AgentThread, AgentInvokeOptions, CancellationToken) |
Invoke the agent with the provided message and arguments. |
InvokeStreamingAsync(ICollection<ChatMessageContent>, AgentThread, AgentInvokeOptions, CancellationToken) |
Invoke the agent with the provided message and arguments. |
InvokeStreamingAsync(String, AgentThread, AgentInvokeOptions, CancellationToken) |
Invoke the agent with the provided message and arguments. |
NotifyThreadOfNewMessage(AgentThread, ChatMessageContent, CancellationToken) |
Notfiy the given thread that a new message is available. |
RenderInstructionsAsync(Kernel, KernelArguments, CancellationToken) |
Formats the system instructions for the agent. |
RestoreChannelAsync(String, CancellationToken) |
Produce an AgentChannel appropriate for the agent type based on the provided state. |