> ## Documentation Index
> Fetch the complete documentation index at: https://phaseo.app/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# 使用 C# Agent SDK 为工单分类

> 使用 C# Agent SDK，在单个 .NET 服务中通过本地工具为工单分类。

当 .NET 服务需要为收到的支持工单分类或生成摘要时，可使用此示例。

## 1. 准备 SDK

<Note type="warning">C# Agent SDK 包尚未发布到 NuGet。请参阅[从源代码安装说明](../sdk-reference/csharp/agent-sdk-installation.mdx)。</Note>

## 2. 定义内部查询工具

```csharp theme={null}
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.",
    })
));
```

## 3. 创建并运行 Agent

```csharp theme={null}
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);
```

## 适用场景

* 工作流位于单个 ASP.NET 服务或工作进程中
* 本地运行时已能获取内部工单状态
* 你想先采用范围明确的 Agent 循环，再添加队列或审批

## 相关内容

* [C# Agent SDK](../sdk-reference/csharp/agent-sdk.mdx)
* [使用 preset 驱动的 Agent 为支持请求分类](./agent-sdk-support-triage.mdx)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.