把图 JSON 编译成 CreateHandoffBuilderWith + WithHandoff;Agent 固定 Id 以免交接工具名错位;DeepSeek 关闭 thinking,避免多轮丢掉 reasoning_content 导致 400。
36 lines
1.4 KiB
C#
36 lines
1.4 KiB
C#
using MAF1.Tools;
|
|
using MAF1.Utils;
|
|
using Microsoft.Agents.AI.Workflows;
|
|
|
|
namespace MAF1.Route;
|
|
|
|
/// <summary>把图编译成 WithHandoff 工作流并跑一轮。</summary>
|
|
public static class RouteOrchestrator
|
|
{
|
|
public static async Task RunAsync(
|
|
AgentFactory factory,
|
|
WeatherTools weatherTools,
|
|
RouteGraph graph,
|
|
RouteUserInput input)
|
|
{
|
|
string task = input.ToTask();
|
|
Console.WriteLine("模式 route:方案 C + MAF WithHandoff(图 = 白名单,边 = 允许交接)");
|
|
Console.WriteLine($"图节点: {string.Join("、", graph.Nodes.Select(DescribeNode))}");
|
|
Console.WriteLine(graph.HasEdges
|
|
? $"专家之间的边: {string.Join("、", graph.Edges.Select(e => $"{e.From}->{e.To}" + (string.IsNullOrWhiteSpace(e.When) ? "" : $" [{e.When}]")))}"
|
|
: "专家之间无边");
|
|
Console.WriteLine($"主管可第一跳: {string.Join("、", graph.Nodes.Select(n => n.Id))}(按用户原话选择,不必先抽城市)");
|
|
Console.WriteLine($"输入: {input.Describe()}");
|
|
Console.WriteLine();
|
|
|
|
Workflow workflow = HandoffGraphBuilder.Build(factory, weatherTools, graph, input);
|
|
await HandoffRun.RunAsync(workflow, task);
|
|
}
|
|
|
|
private static string DescribeNode(RouteNode node)
|
|
{
|
|
string title = string.IsNullOrWhiteSpace(node.Title) ? node.Type : node.Title;
|
|
return $"{node.Id}:{title}";
|
|
}
|
|
}
|