Skip to content

Commit 594ea56

Browse files
Rename AgentRunResponse and AgentRunResponseUpdate (#811)
* rename AgentRunResponse and AgentRunResponseUpdate * Rename AgentRunUpdateEvent and AgentRunResponseEvent classes
1 parent 232fbc9 commit 594ea56

29 files changed

Lines changed: 157 additions & 157 deletions

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

@@ -257,7 +257,7 @@ catch (Exception ex)
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`
259259
- **CreateAIAgent**: Extension method on `AGUIChatClient` to create an agent from the client
260-
- **RunStreamingAsync**: Streams responses as `AgentRunResponseUpdate` objects
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: 1 addition & 1 deletion
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 |

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

Lines changed: 6 additions & 6 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
};

agent-framework/migration-guide/from-autogen/index.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -688,8 +688,8 @@ Notes:
688688
from collections.abc import AsyncIterable
689689
from typing import Any
690690
from agent_framework import (
691-
AgentRunResponse,
692-
AgentRunResponseUpdate,
691+
AgentResponse,
692+
AgentResponseUpdate,
693693
AgentThread,
694694
BaseAgent,
695695
ChatMessage,
@@ -704,7 +704,7 @@ class StaticAgent(BaseAgent):
704704
*,
705705
thread: AgentThread | None = None,
706706
**kwargs: Any,
707-
) -> AgentRunResponse:
707+
) -> AgentResponse:
708708
# Build a static reply
709709
reply = ChatMessage(role=Role.ASSISTANT, contents=[TextContent(text="Hello from AF custom agent")])
710710

@@ -713,17 +713,17 @@ class StaticAgent(BaseAgent):
713713
normalized = self._normalize_messages(messages)
714714
await self._notify_thread_of_new_messages(thread, normalized, reply)
715715

716-
return AgentRunResponse(messages=[reply])
716+
return AgentResponse(messages=[reply])
717717

718718
async def run_stream(
719719
self,
720720
messages: str | ChatMessage | list[str] | list[ChatMessage] | None = None,
721721
*,
722722
thread: AgentThread | None = None,
723723
**kwargs: Any,
724-
) -> AsyncIterable[AgentRunResponseUpdate]:
724+
) -> AsyncIterable[AgentResponseUpdate]:
725725
# Stream the same static response in a single chunk for simplicity
726-
yield AgentRunResponseUpdate(contents=[TextContent(text="Hello from AF custom agent")], role=Role.ASSISTANT)
726+
yield AgentResponseUpdate(contents=[TextContent(text="Hello from AF custom agent")], role=Role.ASSISTANT)
727727

728728
# Notify thread of input and the complete response once streaming ends
729729
if thread is not None:
@@ -1199,7 +1199,7 @@ from typing import cast
11991199
from agent_framework import (
12001200
MAGENTIC_EVENT_TYPE_AGENT_DELTA,
12011201
MAGENTIC_EVENT_TYPE_ORCHESTRATOR,
1202-
AgentRunUpdateEvent,
1202+
AgentResponseUpdateEvent,
12031203
ChatAgent,
12041204
ChatMessage,
12051205
MagenticBuilder,
@@ -1231,7 +1231,7 @@ workflow = (
12311231
async def magentic_example():
12321232
output: str | None = None
12331233
async for event in workflow.run_stream("Complex research task"):
1234-
if isinstance(event, AgentRunUpdateEvent):
1234+
if isinstance(event, AgentResponseUpdateEvent):
12351235
props = event.data.additional_properties if event.data else None
12361236
event_type = props.get("magentic_event_type") if props else None
12371237

@@ -1255,7 +1255,7 @@ The Magentic workflow provides extensive customization options:
12551255

12561256
- **Manager configuration**: Use a ChatAgent with custom instructions and model settings
12571257
- **Round limits**: `max_round_count`, `max_stall_count`, `max_reset_count`
1258-
- **Event streaming**: Use `AgentRunUpdateEvent` with `magentic_event_type` metadata
1258+
- **Event streaming**: Use `AgentResponseUpdateEvent` with `magentic_event_type` metadata
12591259
- **Agent specialization**: Custom instructions and tools per agent
12601260
- **Human-in-the-loop**: Plan review, tool approval, and stall intervention
12611261

@@ -1265,7 +1265,7 @@ from typing import cast
12651265
from agent_framework import (
12661266
MAGENTIC_EVENT_TYPE_AGENT_DELTA,
12671267
MAGENTIC_EVENT_TYPE_ORCHESTRATOR,
1268-
AgentRunUpdateEvent,
1268+
AgentResponseUpdateEvent,
12691269
ChatAgent,
12701270
MagenticBuilder,
12711271
MagenticHumanInterventionDecision,

agent-framework/migration-guide/from-semantic-kernel/index.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,13 @@ await foreach (AgentResponseItem<ChatMessageContent> result in agent.InvokeAsync
180180

181181
### Agent Framework
182182

183-
The Non-Streaming returns a single `AgentRunResponse` with the agent response that can contain multiple messages.
184-
The text result of the run is available in `AgentRunResponse.Text` or `AgentRunResponse.ToString()`.
185-
All messages created as part of the response are returned in the `AgentRunResponse.Messages` list.
183+
The Non-Streaming returns a single `AgentResponse` with the agent response that can contain multiple messages.
184+
The text result of the run is available in `AgentResponse.Text` or `AgentResponse.ToString()`.
185+
All messages created as part of the response are returned in the `AgentResponse.Messages` list.
186186
This might include tool call messages, function results, reasoning updates, and final results.
187187

188188
```csharp
189-
AgentRunResponse agentResponse = await agent.RunAsync(userInput, thread);
189+
AgentResponse agentResponse = await agent.RunAsync(userInput, thread);
190190
```
191191

192192
## 7. Agent Streaming Invocation
@@ -204,12 +204,12 @@ await foreach (StreamingChatMessageContent update in agent.InvokeStreamingAsync(
204204

205205
### Agent Framework
206206

207-
Agent Framework has a similar streaming API pattern, with the key difference being that it returns `AgentRunResponseUpdate` objects that include more agent-related information per update.
207+
Agent Framework has a similar streaming API pattern, with the key difference being that it returns `AgentResponseUpdate` objects that include more agent-related information per update.
208208

209-
All updates produced by any service underlying the AIAgent are returned. The textual result of the agent is available by concatenating the `AgentRunResponse.Text` values.
209+
All updates produced by any service underlying the AIAgent are returned. The textual result of the agent is available by concatenating the `AgentResponse.Text` values.
210210

211211
```csharp
212-
await foreach (AgentRunResponseUpdate update in agent.RunStreamingAsync(userInput, thread))
212+
await foreach (AgentResponseUpdate update in agent.RunStreamingAsync(userInput, thread))
213213
{
214214
Console.Write(update); // Update is ToString() friendly
215215
}
@@ -677,7 +677,7 @@ This compatibility layer allows you to gradually migrate your code from Semantic
677677

678678
## 6. Agent Non-Streaming Invocation
679679

680-
Key differences can be seen in the method names from `invoke` to `run`, return types (for example, `AgentRunResponse`) and parameters.
680+
Key differences can be seen in the method names from `invoke` to `run`, return types (for example, `AgentResponse`) and parameters.
681681

682682
### Semantic Kernel
683683

@@ -701,7 +701,7 @@ print(f"# {response.role}: {response}")
701701

702702
### Agent Framework
703703

704-
The Non-Streaming run returns a single `AgentRunResponse` with the agent response that can contain multiple messages.
704+
The Non-Streaming run returns a single `AgentResponse` with the agent response that can contain multiple messages.
705705
The text result of the run is available in `response.text` or `str(response)`.
706706
All messages created as part of the response are returned in the `response.messages` list.
707707
This might include tool call messages, function results, reasoning updates and final results.
@@ -716,7 +716,7 @@ print("Agent response:", response.text)
716716

717717
## 7. Agent Streaming Invocation
718718

719-
Key differences in the method names from `invoke` to `run_stream`, return types (`AgentRunResponseUpdate`) and parameters.
719+
Key differences in the method names from `invoke` to `run_stream`, return types (`AgentResponseUpdate`) and parameters.
720720

721721
### Semantic Kernel
722722

@@ -731,28 +731,28 @@ async for update in agent.invoke_stream(
731731

732732
### Agent Framework
733733

734-
Similar streaming API pattern with the key difference being that it returns `AgentRunResponseUpdate` objects including more agent related information per update.
734+
Similar streaming API pattern with the key difference being that it returns `AgentResponseUpdate` objects including more agent related information per update.
735735

736736
All contents produced by any service underlying the Agent are returned. The final result of the agent is available by combining the `update` values into a single response.
737737

738738
```python
739-
from agent_framework import AgentRunResponse
739+
from agent_framework import AgentResponse
740740
agent = ...
741741
updates = []
742742
async for update in agent.run_stream(user_input, thread):
743743
updates.append(update)
744744
print(update.text)
745745

746-
full_response = AgentRunResponse.from_agent_run_response_updates(updates)
746+
full_response = AgentResponse.from_agent_response_updates(updates)
747747
print("Full agent response:", full_response.text)
748748
```
749749

750750
You can even do that directly:
751751

752752
```python
753-
from agent_framework import AgentRunResponse
753+
from agent_framework import AgentResponse
754754
agent = ...
755-
full_response = AgentRunResponse.from_agent_response_generator(agent.run_stream(user_input, thread))
755+
full_response = AgentResponse.from_agent_response_generator(agent.run_stream(user_input, thread))
756756
print("Full agent response:", full_response.text)
757757
```
758758

agent-framework/tutorials/agents/function-tools-approvals.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ You can check the response content for any `FunctionApprovalRequestContent` inst
6767

6868
```csharp
6969
AgentThread thread = agent.GetNewThread();
70-
AgentRunResponse response = await agent.RunAsync("What is the weather like in Amsterdam?", thread);
70+
AgentResponse response = await agent.RunAsync("What is the weather like in Amsterdam?", thread);
7171

7272
var functionApprovalRequests = response.Messages
7373
.SelectMany(x => x.Contents)

agent-framework/tutorials/agents/middleware.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ using System.Linq;
6262
using System.Threading;
6363
using System.Threading.Tasks;
6464

65-
async Task<AgentRunResponse> CustomAgentRunMiddleware(
65+
async Task<AgentResponse> CustomAgentRunMiddleware(
6666
IEnumerable<ChatMessage> messages,
6767
AgentThread? thread,
6868
AgentRunOptions? options,

0 commit comments

Comments
 (0)