关于 typespec-create-agent
用于创建 Microsoft 365 Copilot TypeSpec 声明式 Agent 的技能。它根据 Agent 的职责和需求生成结构化的 `main.tsp`,包含能力配置和对话开场白。
主要功能
- 01生成 `main.tsp` Agent 定义
- 02设置 Agent 名称和描述
- 03编写行为指南
- 04添加 2–4 个对话开场白
- 05选择并限定所需能力
适用场景
- 01起草 Microsoft 365 Copilot Agent
- 02定义角色和行为准则
- 03选择并限定数据与工具能力
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ github/ awesome-copilot --skill typespec-create-agent安装后在 Claude Code 中输入/typespec-create-agent确认已加载。
详细介绍
创建 TypeSpec 声明式 Agent
为 Microsoft 365 Copilot 创建一个完整的 TypeSpec 声明式 Agent,结构如下:
要求
生成一个 main.tsp 文件,包含:
-
Agent 声明
- 使用
@agent装饰器,并提供描述性的名称和说明 - 名称应不超过 100 个字符
- 说明应不超过 1,000 个字符
- 使用
-
指令
- 使用
@instructions装饰器,并提供清晰的行为准则 - 定义 Agent 的角色、专长和个性
- 说明 Agent 应该做什么和不应该做什么
- 保持在 8,000 个字符以内
- 使用
-
对话开场提示
- 包含 2-4 个
@conversationStarter装饰器 - 每个都带有标题和示例查询
- 使其多样化,并展示不同能力
- 包含 2-4 个
-
能力(基于用户需求)
WebSearch- 用于 Web 内容,可选范围限定OneDriveAndSharePoint- 用于文档访问,支持 URL 筛选TeamsMessages- 用于 Teams 频道/聊天访问Email- 用于电子邮件访问,支持文件夹筛选People- 用于组织人员搜索CodeInterpreter- 用于 Python 代码执行GraphicArt- 用于图像生成GraphConnectors- 用于 Copilot 连接器内容Dataverse- 用于 Dataverse 数据访问Meetings- 用于会议内容访问
模板结构
import "@typespec/http";
import "@typespec/openapi3";
import "@microsoft/typespec-m365-copilot";
using TypeSpec.Http;
using TypeSpec.M365.Copilot.Agents;
@agent({
name: "[Agent Name]",
description: "[Agent Description]"
})
@instructions("""
[Detailed instructions about agent behavior, role, and guidelines]
""")
@conversationStarter(#{
title: "[Starter Title 1]",
text: "[Example query 1]"
})
@conversationStarter(#{
title: "[Starter Title 2]",
text: "[Example query 2]"
})
namespace [AgentName] {
// Add capabilities as operations here
op capabilityName is AgentCapabilities.[CapabilityType]<[Parameters]>;
}
最佳实践
- 使用描述性的、基于角色的 Agent 名称(例如 "Customer Support Assistant"、"Research Helper")
- 用第二人称撰写指令("You are...")
- 具体说明 Agent 的专长和限制
- 包含多样化的对话开场提示,以展示不同功能
- 只包含 Agent 实际需要的能力
- 尽可能限定能力范围(URL、文件夹等),以获得更好的性能
- 对多行指令使用三引号字符串
示例
询问用户:
- Agent 的用途和角色是什么?
- 它需要哪些能力?
- 它应该访问哪些知识来源?
- 典型的用户交互有哪些?
然后生成完整的 TypeSpec Agent 定义。
评论
支持 Markdown