mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Round 2 of cleanup for agent runtime and orchestrations (#164)
- Moved InProcessRuntime type into abstractions package and deleted InProcess package. - Moved several members of IAgentRuntime to be extension methods instead, e.g. multiple GetActorAsync overloads. - Added synchronous RegisterMessageHandler overloads and used them to avoid unnecessary async usage at call sites. - Removed unnecessary surface area from InProcessRuntime, e.g. StopAsync, RunUntilIdleAsync, etc. - Fixed spin loop in InProcessRuntime that would consume an entire core for the duration of the orchestration's operation. - Removed a bunch of allocation from InProcessRuntime. - Made a runtime optional for orchestrations, defaulting to using a temporary InProcessRuntime if none is provided. - Removed custom delegate types from orchestrations. - Consolidated namespaces. - Used records to simplify message classes. - Tweaked naming on AgentActor to make purpose of protected methods more clear. - Removed invocation in AgentActor.InvokeAsync of empty update / isFinal parameter. - Changed OrchestrationHandoffs to avoid needing to pass in agents duplicatively. - Made various extension methods, such as those on OrchestrationHandoffsExtensions, into instance methods.
This commit is contained in:
committed by
GitHub
Unverified
parent
eca0eb9cd0
commit
456e7d1b65
@@ -16,11 +16,6 @@ namespace Microsoft.Shared.SampleUtilities;
|
||||
/// </summary>
|
||||
public abstract class OrchestrationSample : BaseSample
|
||||
{
|
||||
/// <summary>
|
||||
/// This constant defines the timeout duration for result retrieval, measured in seconds.
|
||||
/// </summary>
|
||||
protected const int ResultTimeoutInSeconds = 30;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ChatClientAgent"/> instance using the specified instructions, description, name, and functions.
|
||||
/// </summary>
|
||||
@@ -136,28 +131,23 @@ public abstract class OrchestrationSample : BaseSample
|
||||
/// <returns>A <see cref="ValueTask"/> representing the asynchronous operation.</returns>
|
||||
public ValueTask ResponseCallback(IEnumerable<ChatMessage> response)
|
||||
{
|
||||
WriteStreamedResponse(this.StreamedResponses);
|
||||
this.StreamedResponses.Clear();
|
||||
|
||||
this.History.AddRange(response);
|
||||
WriteResponse(response);
|
||||
return new ValueTask();
|
||||
return default;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Callback to handle a streamed agent run response update, adding it to the list and writing output if final.
|
||||
/// </summary>
|
||||
/// <param name="streamedResponse">The <see cref="AgentRunResponseUpdate"/> to process.</param>
|
||||
/// <param name="isFinal">Indicates whether this is the final update in the stream.</param>
|
||||
/// <returns>A <see cref="ValueTask"/> representing the asynchronous operation.</returns>
|
||||
public ValueTask StreamingResultCallback(AgentRunResponseUpdate streamedResponse, bool isFinal)
|
||||
public ValueTask StreamingResultCallback(AgentRunResponseUpdate streamedResponse)
|
||||
{
|
||||
this.StreamedResponses.Add(streamedResponse);
|
||||
|
||||
if (isFinal)
|
||||
{
|
||||
WriteStreamedResponse(this.StreamedResponses);
|
||||
this.StreamedResponses.Clear();
|
||||
}
|
||||
|
||||
return new ValueTask();
|
||||
return default;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user