AGENT SKILL

Copilot Studio 全局变量添加

add-global-variable

向 Copilot Studio 智能体添加全局变量。当用户需要跨同一会话中多个主题持久保存、且可选择对 AI 编排器可见的变量时使用。

适用职业AI 工程师
使用场景智能体开发
License 许可
MIT
最近更新
2026-11-12
Stars
★ 493
Forks
103

01 前言 Front Matter

agent
copilot-studio-author
context
fork
description
Add a global variable to a Copilot Studio agent. Use when the user needs a variable that persists across topics in the same conversation and can optionally be visible to the AI orchestrator.
allowed-tools
Read, Write, Glob, Grep
argument-hint
<variable name and purpose>
user-invocable
false

03 SKILL.md 正文

Add Global Variable

Create a global variable that persists across all topics within a conversation.

Instructions

  1. Auto-discover the agent directory:

    Glob: **/agent.mcs.yml
    

    Use the top-level agent. NEVER hardcode an agent name.

  2. Read settings.mcs.yml to get the schemaName prefix:

    Read: <agent-dir>/settings.mcs.yml
    

    Extract the root-level schemaName value (e.g., copilots_header_cre3c_fullagent).

  3. Determine from the user:

    • Variable name (PascalCase, e.g., LastDiscussedCity)
    • Description of what it stores
    • Whether the AI orchestrator should be aware of it (aIVisibility)
    • Default value (if any)
    • DO NOT skip any of these properties. If the user doesn't provide them, ask follow-up questions to get the necessary information.
  4. Create the variable file at <agent-dir>/variables/<VariableName>.mcs.yml:

# Name: <Human-readable Name>
# <Description>
name: <VariableName>
aIVisibility: <UseInAIContext or HideFromAIContext>
scope: Conversation
description: <Description of what the variable stores>
schemaName: <prefix>.globalvariable.<VariableName>
kind: GlobalVariableComponent
defaultValue: <DEFAULT or specific value>
  1. Key fields explained:
    • name — PascalCase identifier. This is how topics reference the variable: Global.<name> (e.g., Global.LastDiscussedCity).
    • aIVisibility — Controls orchestrator awareness:
      • UseInAIContext — The orchestrator can read and reason about this variable. Use when the variable influences routing or response generation (e.g., user preferences, conversation state the AI should track).
      • HideFromAIContext — The variable exists but the orchestrator doesn't see it. Use for internal bookkeeping (e.g., counters, flags) that topics use but the AI doesn't need to reason about.
    • scope: Conversation — Always Conversation for global variables (persists for the session).
    • schemaName — Must follow the pattern <agent-schemaName>.globalvariable.<VariableName>. Read the prefix from settings.mcs.yml.
    • defaultValue — Initial value. Use DEFAULT if no specific initial value is needed.

How Topics Use Global Variables

Topics reference global variables with the Global. prefix:

# Reading a global variable in a condition
- kind: ConditionGroup
  id: conditionGroup_Xk9mPq
  conditions:
    - id: conditionItem_Lw3nRs
      condition: =!IsBlank(Global.LastDiscussedCity)
      actions:
        - kind: SendActivity
          id: sendMessage_Yt7vBw
          activity:
            text:
              - "Last time we discussed {Global.LastDiscussedCity}."

# Setting a global variable from a topic
- kind: SetTextVariable
  id: setTextVariable_Qp4kMn
  variable: Global.LastDiscussedCity
  value: =Topic.CityName

When to Use Global Variables

  • Cross-topic state: A value set in one topic needs to be read in another (e.g., user's preferred language, last search query)
  • AI-aware context: The orchestrator should know something about the conversation state to make better routing decisions (use UseInAIContext)
  • Conversation-wide defaults: A default value that multiple topics can read and optionally override
  • Dynamic knowledge sources: A global variable can hold a URL that a knowledge source references via =$"{Global.VarName}". This enables routing to different SharePoint folders or websites per user (e.g., by geolocation or department). See /copilot-studio:add-knowledge for the full pattern. Important: the variable value must be a clean, direct URL — not a SharePoint AllItems.aspx link with query parameters.

04 同仓库更多 Skills

microsoft
microsoft/skills-for-copilot-studio

Copilot Studio YAML 校验

validate

使用 LSP 二进制文件的完整诊断能力(YAML 结构、Power Fx、schema、跨文件引用)校验 Copilot Studio 智能体的 YAML 文件。当用户要求检查、验证或核对 YAML 文件时使用。

AI 工程师智能体开发
★ 493
microsoft
microsoft/skills-for-copilot-studio

Copilot Studio 测试身份验证

test-auth

为 Copilot Studio 评估 API 和 SDK 聊天进行身份验证。缓存一个在 run-eval 和 chat-sdk 技能之间共享的令牌。在任何评估或 SDK 聊天工作流之前运行此技能。要求使用具有 MakerOperations 和 Copilots.Invoke 权限的 App Registration。

AI 工程师智能体开发
★ 493
microsoft
microsoft/skills-for-copilot-studio

Copilot Studio Kit 批量测试

run-tests-kit

通过 Copilot Studio Kit (Dataverse API) 运行批量测试套件。使用 Power CAT Copilot Studio Kit 对已发布的智能体执行测试用例,并生成包含延迟的通过/失败结果。要求环境中已安装 Kit、具有 Dataverse 权限的 App Registration,以及已发布的智能体。

AI 工程师测试与质量保障
★ 493
microsoft
microsoft/skills-for-copilot-studio

Copilot Studio 智能体评估运行

run-eval

通过 Power Platform Evaluation API 对 Copilot Studio 智能体运行评估。适用于草稿(DRAFT)智能体——无需发布步骤。列出测试集、启动运行、轮询直至完成、获取结果,并针对失败提出 YAML 修复建议。当用户希望在不发布的情况下测试智能体更改时使用。

AI 工程师智能体开发
★ 493
microsoft
microsoft/skills-for-copilot-studio

Copilot Studio 主题创建

new-topic

创建一个新的 Copilot Studio 主题(topic)YAML 文件。当用户要求为其智能体创建新主题、对话流程或对话框时使用。

AI 工程师智能体开发
★ 493
microsoft
microsoft/skills-for-copilot-studio

Copilot Studio 智能体管理

manage-agent

通过 VS Code 扩展的 LanguageServerHost LSP 二进制文件推送/拉取 Copilot Studio 智能体内容。处理身份验证(推送/拉取使用交互式浏览器登录,聊天令牌使用设备代码流)、同步推送、同步拉取、克隆和差异比较操作。

AI 工程师智能体开发
★ 493