1. 准备 SDK
C# Agent SDK 包尚未发布到 NuGet。请参阅从源代码安装说明。
2. 定义内部查询工具
3. 创建并运行 Agent
适用场景
- 工作流位于单个 ASP.NET 服务或工作进程中
- 本地运行时已能获取内部工单状态
- 你想先采用范围明确的 Agent 循环,再添加队列或审批
Documentation Index
Fetch the complete documentation index at: /docs/llms.txt
Use this file to discover all available pages before exploring further.
使用 C# Agent SDK,在单个 .NET 服务中通过本地工具为工单分类。
var loadTicket = AgentSdk.DefineTool(new Tool(
Id: "load-ticket",
Description: "Load one support ticket by id.",
Parameters: new Dictionary<string, object?>
{
["type"] = "object",
["properties"] = new Dictionary<string, object?>
{
["ticketId"] = new Dictionary<string, object?> { ["type"] = "string" },
},
["required"] = new[] { "ticketId" },
},
Execute: (input, ctx) => Task.FromResult<object?>(new Dictionary<string, object?>
{
["ticketId"] = "T-1042",
["severity"] = "medium",
["summary"] = "Customer cannot find preset routing settings.",
})
));
var agent = AgentSdk.CreateAgent(new AgentDefinition
{
Id = "ticket-triage-agent",
Model = "openai/gpt-5.4-nano",
Instructions = "Use tools when helpful and answer with a short triage summary.",
Tools = new[] { loadTicket },
});
var result = await agent.Run(new RunOptions
{
Input = "Review ticket T-1042 and summarize the next action.",
Client = AgentSdk.CreateGatewayAgentClient(),
});
Console.WriteLine(result.Output);