mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
4940d0ef36
Subworkflows run into issues with Checkpointing and the Chat Protocol: * The concurrency rework made subtle changes in behaviour that introduced a hang when using subworkflows with ChatProtocol and streaming execution. * The ResetAsync() implementation in WorkflowHostExecutor was improperly resetting the joinContext - this was happening on restore checkpoint _after_ the join context was attached when * Subworkflows cannot be used as the start node when hosted AsAgent due to inability to treat Catch-All as a Chat Protocol * Subworkflow ownership issue when used in non-concurrent mode after finishing a run Also fixes: * When ChatMessages are output by executors that are not agents, there is no corresponding AgentResponseUpdate/AgentResponse event Breaking Changes * [BREAKING CHANGE] It is possible to provide the wrong RunId when resuming from CheckpointInfo (even though the data already exists on CheckpointInfo)
52 lines
2.5 KiB
C#
52 lines
2.5 KiB
C#
// Copyright (c) Microsoft. All rights reserved.
|
|
|
|
using System.Collections.Generic;
|
|
using Microsoft.Extensions.AI;
|
|
|
|
namespace Microsoft.Agents.AI.Workflows;
|
|
|
|
/// <summary>
|
|
/// Provides extension methods for treating workflows as <see cref="AIAgent"/>
|
|
/// </summary>
|
|
public static class WorkflowHostingExtensions
|
|
{
|
|
/// <summary>
|
|
/// Convert a workflow with the appropriate primary input type to an <see cref="AIAgent"/>.
|
|
/// </summary>
|
|
/// <param name="workflow">The workflow to be hosted by the resulting <see cref="AIAgent"/></param>
|
|
/// <param name="id">A unique id for the hosting <see cref="AIAgent"/>.</param>
|
|
/// <param name="name">A name for the hosting <see cref="AIAgent"/>.</param>
|
|
/// <param name="description">A description for the hosting <see cref="AIAgent"/>.</param>
|
|
/// <param name="checkpointManager">A <see cref="CheckpointManager"/> to enable persistence of run state.</param>
|
|
/// <param name="executionEnvironment">Specify the execution environment to use when running the workflows. See
|
|
/// <see cref="InProcessExecution.OffThread"/>, <see cref="InProcessExecution.Concurrent"/> and
|
|
/// <see cref="InProcessExecution.Lockstep"/> for the in-process environments.</param>
|
|
/// <param name="includeExceptionDetails">If <see langword="true"/>, will include <see cref="System.Exception.Message"/>
|
|
/// in the <see cref="ErrorContent"/> representing the workflow error.</param>
|
|
/// <param name="includeWorkflowOutputsInResponse">If <see langword="true"/>, will transform outgoing workflow outputs
|
|
/// into into content in <see cref="AgentResponseUpdate"/>s or the <see cref="AgentResponse"/> as appropriate.</param>
|
|
/// <returns></returns>
|
|
public static AIAgent AsAgent(
|
|
this Workflow workflow,
|
|
string? id = null,
|
|
string? name = null,
|
|
string? description = null,
|
|
CheckpointManager? checkpointManager = null,
|
|
IWorkflowExecutionEnvironment? executionEnvironment = null,
|
|
bool includeExceptionDetails = false,
|
|
bool includeWorkflowOutputsInResponse = false)
|
|
{
|
|
return new WorkflowHostAgent(workflow, id, name, description, checkpointManager, executionEnvironment, includeExceptionDetails, includeWorkflowOutputsInResponse);
|
|
}
|
|
|
|
internal static FunctionCallContent ToFunctionCall(this ExternalRequest request)
|
|
{
|
|
Dictionary<string, object?> parameters = new()
|
|
{
|
|
{ "data", request.Data}
|
|
};
|
|
|
|
return new FunctionCallContent(request.RequestId, request.PortInfo.PortId, parameters);
|
|
}
|
|
}
|