Skip to main content
Pre-built agent implementations and specialized components for common use cases.

AI Agents

Base class for agents using Microsoft.Extensions.AI for chat completion.
T
type parameter
required
Message type (must implement IMessage)
id
AgentId
required
Agent identifier
runtime
IAgentRuntime
required
Runtime environment
name
string
required
Agent name
logger
ILogger?
Optional logger
client
IChatClient
required
Chat client from Microsoft.Extensions.AI

Properties

ChatClient
IChatClient
Gets the chat client for inference

Methods

CompleteAsync
Task<ChatResponse>
Generate a chat completion
chatMessages
IList<ChatMessage>
required
Conversation messages
options
ChatOptions?
Generation options
cancellationToken
CancellationToken
Cancellation token
CompleteStreamingAsync
IAsyncEnumerable<ChatResponseUpdate>
Stream chat completion chunks

I/O Agents

Interface for process I/O operations.
WriteAsync
Task
Write content to output
content
string
required
Content to write
ReadAsync
Task<string>
Read input from user or process
Interface for console interaction agents.
Interface for file I/O operations.
ReadFileAsync
ValueTask<string>
Read file contents
filePath
string
required
Path to file
WriteFileAsync
ValueTask
Write content to file
filePath
string
required
Path to file
content
string
required
Content to write

Agent Chat (Teams)

State management for agent teams.
History
List<Message>
Conversation history
SharedContext
Dictionary<string, object>
Shared context between agents
CurrentSpeaker
string
Current active agent

Termination Conditions

Terminate after maximum messages.
maxMessages
int
required
Maximum number of messages
Terminate on specific text pattern.
pattern
string
required
Text pattern to match
Terminate when text mentions specific content.
Terminate after time limit.
timeout
TimeSpan
required
Maximum execution time
Terminate after token budget.
maxTokens
int
required
Maximum tokens to consume
Terminate on stop message.
Terminate when message source matches.
Terminate on agent handoff.
Terminate on specific function call.
Terminate based on external signal.

Agent Host

Application host for running agent systems.

Example: Complete AI Agent

See Also