Message Types in the Microsoft Agent Framework
Input and output from agents in the Microsoft Agent Framework are represented as messages. Each message is subdivided into content items. The framework uses the ChatMessage class and the AIContent hierarchy from the Microsoft.Extensions.AI abstractions.
Understanding these types is essential because agents don’t just return plain text — responses may contain tool calls, binary data, URIs, and more. Knowing how to construct input messages and inspect output content items is the foundation of working with the framework.
ChatMessage — The Message Container
Every interaction with an agent revolves around ChatMessage objects. A ChatMessage has two key properties:
Role— who created the message (ChatRole.User,ChatRole.Assistant,ChatRole.System,ChatRole.Tool)Contents— a collection ofAIContentitems that make up the message’s payload
AIContent — The Base Content Class
All content items in a ChatMessage inherit from AIContent. The framework provides several built-in subclasses, and providers can add their own.
| Type | Description | Direction |
|---|---|---|
TextContent | Textual content — the most common type. Contains the text result from an agent or text input from a user. | Input & Output |
DataContent | Binary content for images, audio, or video data. | Input & Output |
UriContent | A URL pointing at hosted content such as an image, audio, or video. | Input & Output |
FunctionCallContent | A request by the model to invoke a function tool. | Output |
FunctionResultContent | The result of a function tool invocation. | Output |
TextContent — The Most Common Type
TextContent is what you’ll encounter most often. When you send a text prompt, the framework wraps it in a TextContent. When the agent responds with text, that’s also a TextContent.
The .Text shortcut works by iterating through every ChatMessage in response.Messages and concatenating all TextContent items. You can do this manually to understand what happens under the hood:
DataContent — Binary Data
DataContent carries binary data with a MIME type. Use it to send images, audio, or video to vision/audio-capable models:
DataContent is useful when you have the actual file bytes in memory. For hosted content, prefer UriContent instead.
UriContent — URLs to Hosted Content
UriContent points at hosted resources like images or documents. The model will fetch the content from the URL during processing:
Use UriContent when working with hosted assets to avoid embedding large binary data directly in the message.
FunctionCallContent & FunctionResultContent — Tool Interactions
When an agent has access to function tools, responses may include FunctionCallContent (a request to call a function) and FunctionResultContent (the result of that call). These appear in the Contents collection alongside TextContent.
These content types are not included in the .Text property. If you only use .Text, you’ll get the text result; tool call details must be inspected separately through .Contents.
Inspecting All Content Types with Pattern Matching
The recommended way to handle the full range of content types is C# pattern matching with a switch expression:
Content Types in Streaming Responses
Streaming chunks (AgentResponseUpdate) also carry content items via update.Contents. Each chunk may contain a TextContent fragment, a tool call, or other content:
Building Multi-Content Input Messages
A ChatMessage can contain multiple content items. This is how you send multimodal input (text + image) or provide conversation history:
Multimodal Input
Conversation History
Content Type Reference
| Type | Key Properties | In .Text? | Typical Use |
TextContent | .Text | Yes | User prompts, agent answers |
DataContent | .Data, .MediaType | No | Sending images/audio/video as bytes |
UriContent | .Uri, .MediaType | No | Pointing at hosted resources |
FunctionCallContent | .Name, .CallId, .Arguments | No | Agent requests a tool invocation |
FunctionResultContent | .CallId, .Result | No | Result of a tool invocation |
UsageContent | .Details.InputTokenCount, .Details.OutputTokenCount | No | Token usage statistics |
Key Takeaways
- Messages are containers, content items are the payload — a
ChatMessageholds aRoleand a collection ofAIContentitems. TextContentis the most common type — it carries both user input and agent output text. The.Textshortcut aggregates allTextContentitems.DataContentandUriContentenable multimodal input — send images, audio, or video to capable models via bytes or URLs.FunctionCallContentandFunctionResultContentrepresent tool interactions — these appear when the agent invokes function tools and are not included in.Text.- Use pattern matching on
.Contents— C# pattern matching is the idiomatic way to handle the differentAIContentsubclasses in both non-streaming and streaming responses.