feat: 新增方案 C 的 Handoff 路由宿主,并让抽城市支持自然语言。

把图 JSON 编译成 CreateHandoffBuilderWith + WithHandoff;Agent 固定 Id 以免交接工具名错位;DeepSeek 关闭 thinking,避免多轮丢掉 reasoning_content 导致 400。
This commit is contained in:
2026-09-01 17:56:41 +08:00
parent 2c5c6fd118
commit b0e89b6092
25 changed files with 960 additions and 27 deletions
+19 -5
View File
@@ -11,16 +11,30 @@ namespace MAF1.Agents.Weather;
/// </summary>
public static class WeatherAgent
{
public const string DefaultDescription = "按城市列表查询天气并汇总。";
/// <summary>创建带 GetWeather 工具的 Agent。instructions 要求每个城市都调工具,禁止编造气温。</summary>
public static AIAgent Create(AgentFactory factory, WeatherTools weatherTools)
public static AIAgent Create(
AgentFactory factory,
WeatherTools weatherTools,
string name = "WeatherAgent",
string? description = null,
string? extraInstructions = null)
{
return factory.CreateAgent(
name: "WeatherAgent",
instructions:
string instructions =
"""
GetWeather
""",
""";
if (!string.IsNullOrWhiteSpace(extraInstructions))
{
instructions = instructions + "\n" + extraInstructions;
}
return factory.CreateAgent(
name: name,
instructions: instructions,
description: string.IsNullOrWhiteSpace(description) ? DefaultDescription : description,
tools: [AIFunctionFactory.Create(weatherTools.GetWeather)]);
}