Skip to content

Commit 56dbe96

Browse files
authored
Merge pull request #344 from MicrosoftDocs/main639045504619495658sync_temp
Repo sync for protected branch
2 parents 7ff289a + c820aa7 commit 56dbe96

File tree

81 files changed

+3666
-1061
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+3666
-1061
lines changed

.openpublishing.publish.config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"build_output_subfolder": "agent-framework",
77
"locale": "en-us",
88
"monikers": [],
9-
"open_to_public_contributors": false,
9+
"open_to_public_contributors": true,
1010
"type_mapping": {
1111
"Conceptual": "Content"
1212
},

agent-framework/integrations/ag-ui/backend-tool-rendering.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ ChatClient chatClient = new AzureOpenAIClient(
147147
new DefaultAzureCredential())
148148
.GetChatClient(deploymentName);
149149

150-
ChatClientAgent agent = chatClient.AsIChatClient().CreateAIAgent(
150+
ChatClientAgent agent = chatClient.AsIChatClient().AsAIAgent(
151151
name: "AGUIAssistant",
152152
instructions: "You are a helpful assistant with access to restaurant information.",
153153
tools: tools);
@@ -186,7 +186,7 @@ To see tool calls and results in real-time, extend the client's streaming loop t
186186

187187
```csharp
188188
// Inside the streaming loop from getting-started.md
189-
await foreach (AgentRunResponseUpdate update in agent.RunStreamingAsync(messages, thread))
189+
await foreach (AgentResponseUpdate update in agent.RunStreamingAsync(messages, thread))
190190
{
191191
ChatResponseUpdate chatUpdate = update.AsChatResponseUpdate();
192192

agent-framework/integrations/ag-ui/frontend-tools.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static string GetUserLocation()
5757
AITool[] frontendTools = [AIFunctionFactory.Create(GetUserLocation)];
5858

5959
// Pass tools when creating the agent
60-
AIAgent agent = chatClient.CreateAIAgent(
60+
AIAgent agent = chatClient.AsAIAgent(
6161
name: "agui-client",
6262
description: "AG-UI Client Agent",
6363
tools: frontendTools);
@@ -67,7 +67,7 @@ The rest of your client code remains the same as shown in the Getting Started tu
6767

6868
### How Tools Are Sent to the Server
6969

70-
When you register tools with `CreateAIAgent()`, the `AGUIChatClient` automatically:
70+
When you register tools with `AsAIAgent()`, the `AGUIChatClient` automatically:
7171

7272
1. Captures the tool definitions (names, descriptions, parameter schemas)
7373
3. Sends the tools with each request to the server agent which maps them to `ChatAgentRunOptions.ChatOptions.Tools`
@@ -85,7 +85,7 @@ AIAgent inspectableAgent = baseAgent
8585
.Use(runFunc: null, runStreamingFunc: InspectToolsMiddleware)
8686
.Build();
8787

88-
static async IAsyncEnumerable<AgentRunResponseUpdate> InspectToolsMiddleware(
88+
static async IAsyncEnumerable<AgentResponseUpdate> InspectToolsMiddleware(
8989
IEnumerable<ChatMessage> messages,
9090
AgentThread? thread,
9191
AgentRunOptions? options,
@@ -109,7 +109,7 @@ static async IAsyncEnumerable<AgentRunResponseUpdate> InspectToolsMiddleware(
109109
}
110110
}
111111

112-
await foreach (AgentRunResponseUpdate update in innerAgent.RunStreamingAsync(messages, thread, options, cancellationToken))
112+
await foreach (AgentResponseUpdate update in innerAgent.RunStreamingAsync(messages, thread, options, cancellationToken))
113113
{
114114
yield return update;
115115
}
@@ -123,7 +123,7 @@ This middleware pattern allows you to:
123123

124124
The following are new concepts for frontend tools:
125125

126-
- **Client-side registration**: Tools are registered on the client using `AIFunctionFactory.Create()` and passed to `CreateAIAgent()`
126+
- **Client-side registration**: Tools are registered on the client using `AIFunctionFactory.Create()` and passed to `AsAIAgent()`
127127
- **Automatic capture**: Tools are automatically captured and sent via `ChatAgentRunOptions.ChatOptions.Tools`
128128

129129
## How Frontend Tools Work

agent-framework/integrations/ag-ui/getting-started.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ ChatClient chatClient = new AzureOpenAIClient(
9292
new DefaultAzureCredential())
9393
.GetChatClient(deploymentName);
9494

95-
AIAgent agent = chatClient.AsIChatClient().CreateAIAgent(
95+
AIAgent agent = chatClient.AsIChatClient().AsAIAgent(
9696
name: "AGUIAssistant",
9797
instructions: "You are a helpful assistant.");
9898

@@ -107,7 +107,7 @@ await app.RunAsync();
107107
- **`AddAGUI`**: Registers AG-UI services with the dependency injection container
108108
- **`MapAGUI`**: Extension method that registers the AG-UI endpoint with automatic request/response handling and SSE streaming
109109
- **`ChatClient` and `AsIChatClient()`**: `AzureOpenAIClient.GetChatClient()` returns OpenAI's `ChatClient` type. The `AsIChatClient()` extension method (from `Microsoft.Extensions.AI.OpenAI`) converts it to the `IChatClient` interface required by Agent Framework
110-
- **`CreateAIAgent`**: Creates an Agent Framework agent from an `IChatClient`
110+
- **`AsAIAgent`**: Creates an Agent Framework agent from an `IChatClient`
111111
- **ASP.NET Core Integration**: Uses ASP.NET Core's native async support for streaming responses
112112
- **Instructions**: The agent is created with default instructions, which can be overridden by client messages
113113
- **Configuration**: `AzureOpenAIClient` with `DefaultAzureCredential` provides secure authentication
@@ -149,7 +149,7 @@ dotnet add package Microsoft.Agents.AI --prerelease
149149
```
150150

151151
> [!NOTE]
152-
> The `Microsoft.Agents.AI` package provides the `CreateAIAgent()` extension method.
152+
> The `Microsoft.Agents.AI` package provides the `AsAIAgent()` extension method.
153153
154154
### Client Code
155155

@@ -174,11 +174,11 @@ using HttpClient httpClient = new()
174174

175175
AGUIChatClient chatClient = new(httpClient, serverUrl);
176176

177-
AIAgent agent = chatClient.CreateAIAgent(
177+
AIAgent agent = chatClient.AsAIAgent(
178178
name: "agui-client",
179179
description: "AG-UI Client Agent");
180180

181-
AgentThread thread = agent.GetNewThread();
181+
AgentThread thread = await agent.GetNewThreadAsync();
182182
List<ChatMessage> messages =
183183
[
184184
new(ChatRole.System, "You are a helpful assistant.")
@@ -209,7 +209,7 @@ try
209209
bool isFirstUpdate = true;
210210
string? threadId = null;
211211

212-
await foreach (AgentRunResponseUpdate update in agent.RunStreamingAsync(messages, thread))
212+
await foreach (AgentResponseUpdate update in agent.RunStreamingAsync(messages, thread))
213213
{
214214
ChatResponseUpdate chatUpdate = update.AsChatResponseUpdate();
215215

@@ -256,8 +256,8 @@ catch (Exception ex)
256256

257257
- **Server-Sent Events (SSE)**: The protocol uses SSE for streaming responses
258258
- **AGUIChatClient**: Client class that connects to AG-UI servers and implements `IChatClient`
259-
- **CreateAIAgent**: Extension method on `AGUIChatClient` to create an agent from the client
260-
- **RunStreamingAsync**: Streams responses as `AgentRunResponseUpdate` objects
259+
- **AsAIAgent**: Extension method on `AGUIChatClient` to create an agent from the client
260+
- **RunStreamingAsync**: Streams responses as `AgentResponseUpdate` objects
261261
- **AsChatResponseUpdate**: Extension method to access chat-specific properties like `ConversationId` and `ResponseId`
262262
- **Thread Management**: The `AgentThread` maintains conversation context across requests
263263
- **Content Types**: Responses include `TextContent` for messages and `ErrorContent` for errors
@@ -327,7 +327,7 @@ The client displays different content types with distinct colors:
327327

328328
1. `AGUIChatClient` sends HTTP POST request to server endpoint
329329
2. Server responds with SSE stream
330-
3. Client parses incoming events into `AgentRunResponseUpdate` objects
330+
3. Client parses incoming events into `AgentResponseUpdate` objects
331331
4. Each update is displayed based on its content type
332332
5. `ConversationId` is captured for conversation continuity
333333
6. Stream completes when run finishes

agent-framework/integrations/ag-ui/human-in-the-loop.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ var agent = baseAgent
126126
cancellationToken))
127127
.Build();
128128

129-
static async IAsyncEnumerable<AgentRunResponseUpdate> HandleApprovalRequestsMiddleware(
129+
static async IAsyncEnumerable<AgentResponseUpdate> HandleApprovalRequestsMiddleware(
130130
IEnumerable<ChatMessage> messages,
131131
AgentThread? thread,
132132
AgentRunOptions? options,
@@ -250,8 +250,8 @@ static async IAsyncEnumerable<AgentRunResponseUpdate> HandleApprovalRequestsMidd
250250
}
251251

252252
// Local function: Convert FunctionApprovalRequestContent to client tool calls
253-
static async IAsyncEnumerable<AgentRunResponseUpdate> ConvertFunctionApprovalsToToolCalls(
254-
AgentRunResponseUpdate update,
253+
static async IAsyncEnumerable<AgentResponseUpdate> ConvertFunctionApprovalsToToolCalls(
254+
AgentResponseUpdate update,
255255
JsonSerializerOptions jsonSerializerOptions)
256256
{
257257
// Check if this update contains a FunctionApprovalRequestContent
@@ -292,7 +292,7 @@ static async IAsyncEnumerable<AgentRunResponseUpdate> HandleApprovalRequestsMidd
292292
var approvalJson = JsonSerializer.Serialize(approvalData, jsonSerializerOptions.GetTypeInfo(typeof(ApprovalRequest)));
293293

294294
// Yield a tool call update that represents the approval request
295-
yield return new AgentRunResponseUpdate(ChatRole.Assistant, [
295+
yield return new AgentResponseUpdate(ChatRole.Assistant, [
296296
new FunctionCallContent(
297297
callId: approvalId,
298298
name: "request_approval",
@@ -337,7 +337,7 @@ var wrappedAgent = agent
337337
cancellationToken))
338338
.Build();
339339

340-
static async IAsyncEnumerable<AgentRunResponseUpdate> HandleApprovalRequestsClientMiddleware(
340+
static async IAsyncEnumerable<AgentResponseUpdate> HandleApprovalRequestsClientMiddleware(
341341
IEnumerable<ChatMessage> messages,
342342
AgentThread? thread,
343343
AgentRunOptions? options,
@@ -414,8 +414,8 @@ static async IAsyncEnumerable<AgentRunResponseUpdate> HandleApprovalRequestsClie
414414
}
415415

416416
// Local function: Convert request_approval tool calls to FunctionApprovalRequestContent
417-
static async IAsyncEnumerable<AgentRunResponseUpdate> ConvertToolCallsToApprovalRequests(
418-
AgentRunResponseUpdate update,
417+
static async IAsyncEnumerable<AgentResponseUpdate> ConvertToolCallsToApprovalRequests(
418+
AgentResponseUpdate update,
419419
JsonSerializerOptions jsonSerializerOptions)
420420
{
421421
FunctionCallContent? approvalToolCall = null;
@@ -452,7 +452,7 @@ static async IAsyncEnumerable<AgentRunResponseUpdate> HandleApprovalRequestsClie
452452
arguments: functionArguments);
453453

454454
// Yield the original tool call first (for message history)
455-
yield return new AgentRunResponseUpdate(ChatRole.Assistant, [approvalToolCall]);
455+
yield return new AgentResponseUpdate(ChatRole.Assistant, [approvalToolCall]);
456456

457457
// Create approval request with CallId stored in AdditionalProperties
458458
var approvalRequestContent = new FunctionApprovalRequestContent(
@@ -463,7 +463,7 @@ static async IAsyncEnumerable<AgentRunResponseUpdate> HandleApprovalRequestsClie
463463
approvalRequestContent.AdditionalProperties ??= new Dictionary<string, object?>();
464464
approvalRequestContent.AdditionalProperties["request_approval_call_id"] = approvalToolCall.CallId;
465465

466-
yield return new AgentRunResponseUpdate(ChatRole.Assistant, [approvalRequestContent]);
466+
yield return new AgentResponseUpdate(ChatRole.Assistant, [approvalRequestContent]);
467467
}
468468
}
469469
#pragma warning restore MEAI001
@@ -490,7 +490,7 @@ do
490490
approvalResponses.Clear();
491491
approvalToolCalls.Clear();
492492

493-
await foreach (AgentRunResponseUpdate update in wrappedAgent.RunStreamingAsync(
493+
await foreach (AgentResponseUpdate update in wrappedAgent.RunStreamingAsync(
494494
messages, thread, cancellationToken: cancellationToken))
495495
{
496496
foreach (AIContent content in update.Contents)

agent-framework/integrations/ag-ui/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ Understanding how Agent Framework concepts map to AG-UI helps you build effectiv
114114
| `AIAgent` | Agent Endpoint | Each agent becomes an HTTP endpoint |
115115
| `agent.Run()` | HTTP POST Request | Client sends messages via HTTP |
116116
| `agent.RunStreamingAsync()` | Server-Sent Events | Streaming responses via SSE |
117-
| `AgentRunResponseUpdate` | AG-UI Events | Converted to protocol events automatically |
117+
| `AgentResponseUpdate` | AG-UI Events | Converted to protocol events automatically |
118118
| `AIFunctionFactory.Create()` | Backend Tools | Executed on server, results streamed |
119119
| `ApprovalRequiredAIFunction` | Human-in-the-Loop | Middleware converts to approval protocol |
120120
| `AgentThread` | Thread Management | `ConversationId` maintains context |
@@ -251,7 +251,7 @@ To get started with AG-UI integration:
251251

252252
- [Agent Framework Documentation](../../overview/agent-framework-overview.md)
253253
- [AG-UI Protocol Documentation](https://docs.ag-ui.com/introduction)
254-
- [AG-UI Dojo App](https://github.com/ag-oss/ag-ui/tree/main/apps/dojo) - Example application demonstrating Agent Framework integration
254+
- [AG-UI Dojo App](https://dojo.ag-ui.com/) - Example application demonstrating Agent Framework integration
255255
- [Agent Framework GitHub Repository](https://github.com/microsoft/agent-framework)
256256

257257
::: zone-end

agent-framework/integrations/ag-ui/state-management.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,17 +113,17 @@ internal sealed class SharedStateAgent : DelegatingAIAgent
113113
this._jsonSerializerOptions = jsonSerializerOptions;
114114
}
115115

116-
public override Task<AgentRunResponse> RunAsync(
116+
public override Task<AgentResponse> RunAsync(
117117
IEnumerable<ChatMessage> messages,
118118
AgentThread? thread = null,
119119
AgentRunOptions? options = null,
120120
CancellationToken cancellationToken = default)
121121
{
122122
return this.RunStreamingAsync(messages, thread, options, cancellationToken)
123-
.ToAgentRunResponseAsync(cancellationToken);
123+
.ToAgentResponseAsync(cancellationToken);
124124
}
125125

126-
public override async IAsyncEnumerable<AgentRunResponseUpdate> RunStreamingAsync(
126+
public override async IAsyncEnumerable<AgentResponseUpdate> RunStreamingAsync(
127127
IEnumerable<ChatMessage> messages,
128128
AgentThread? thread = null,
129129
AgentRunOptions? options = null,
@@ -187,7 +187,7 @@ internal sealed class SharedStateAgent : DelegatingAIAgent
187187
var firstRunMessages = messages.Append(stateUpdateMessage);
188188

189189
// Collect all updates from first run
190-
var allUpdates = new List<AgentRunResponseUpdate>();
190+
var allUpdates = new List<AgentResponseUpdate>();
191191
await foreach (var update in this.InnerAgent.RunStreamingAsync(firstRunMessages, thread, firstRunOptions, cancellationToken).ConfigureAwait(false))
192192
{
193193
allUpdates.Add(update);
@@ -200,7 +200,7 @@ internal sealed class SharedStateAgent : DelegatingAIAgent
200200
}
201201
}
202202

203-
var response = allUpdates.ToAgentRunResponse();
203+
var response = allUpdates.ToAgentResponse();
204204

205205
// Try to deserialize the structured state response
206206
if (response.TryDeserialize(this._jsonSerializerOptions, out JsonElement stateSnapshot))
@@ -209,7 +209,7 @@ internal sealed class SharedStateAgent : DelegatingAIAgent
209209
byte[] stateBytes = JsonSerializer.SerializeToUtf8Bytes(
210210
stateSnapshot,
211211
this._jsonSerializerOptions.GetTypeInfo(typeof(JsonElement)));
212-
yield return new AgentRunResponseUpdate
212+
yield return new AgentResponseUpdate
213213
{
214214
Contents = [new DataContent(stateBytes, "application/json")]
215215
};
@@ -255,7 +255,7 @@ AIAgent CreateRecipeAgent(JsonSerializerOptions jsonSerializerOptions)
255255
var chatClient = azureClient.GetChatClient(deploymentName);
256256

257257
// Create base agent
258-
AIAgent baseAgent = chatClient.AsIChatClient().CreateAIAgent(
258+
AIAgent baseAgent = chatClient.AsIChatClient().AsAIAgent(
259259
name: "RecipeAgent",
260260
instructions: """
261261
You are a helpful recipe assistant. When users ask you to create or suggest a recipe,

agent-framework/integrations/ag-ui/testing-with-dojo.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ms.service: agent-framework
1111

1212
# Testing with AG-UI Dojo
1313

14-
The [AG-UI Dojo application](https://github.com/ag-oss/ag-ui/tree/main/apps/dojo) provides an interactive environment to test and explore Microsoft Agent Framework agents that implement the AG-UI protocol. Dojo offers a visual interface to connect to your agents and interact with all 7 AG-UI features.
14+
The [AG-UI Dojo application](https://dojo.ag-ui.com/) provides an interactive environment to test and explore Microsoft Agent Framework agents that implement the AG-UI protocol. Dojo offers a visual interface to connect to your agents and interact with all 7 AG-UI features.
1515

1616
:::zone pivot="programming-language-python"
1717

@@ -226,18 +226,18 @@ If you see authentication errors:
226226

227227
## Next Steps
228228

229-
- Explore the [example agents](https://github.com/ag-oss/ag-ui/tree/main/integrations/microsoft-agent-framework/python/examples/agents) to see implementation patterns
229+
- Explore the [example agents](https://github.com/ag-ui-protocol/ag-ui/tree/main/integrations/microsoft-agent-framework/python/examples/agents) to see implementation patterns
230230
- Learn about [Backend Tool Rendering](backend-tool-rendering.md) to customize tool UIs
231231
<!-- - Implement [Human-in-the-Loop](human-in-the-loop.md) workflows for approval flows -->
232232
<!-- - Add [State Management](state-management.md) for complex interactive experiences -->
233233

234234
## Additional Resources
235235

236236
- [AG-UI Documentation](https://docs.ag-ui.com/introduction)
237-
- [AG-UI GitHub Repository](https://github.com/ag-oss/ag-ui)
238-
- [Dojo Application](https://github.com/ag-oss/ag-ui/tree/main/apps/dojo)
237+
- [AG-UI GitHub Repository](https://github.com/ag-ui-protocol/ag-ui)
238+
- [Dojo Application](https://dojo.ag-ui.com/)
239239

240-
- [Microsoft Agent Framework Integration Examples](https://github.com/ag-oss/ag-ui/tree/main/integrations/microsoft-agent-framework)
240+
- [Microsoft Agent Framework Integration Examples](https://github.com/ag-ui-protocol/ag-ui/tree/main/integrations/microsoft-agent-framework)
241241

242242
:::zone-end
243243

0 commit comments

Comments
 (0)