Skip to content

Lesson 21 ยท Agents and Copilot Studio

Testing, Publishing and Governing Agents

Test agents with a written test set, publish to channels with admin approval, apply data loss prevention policies and monitor agents with owners and exit plans.

An agent that worked in your demo can fail with real users: unusual wording, missing documents, permissions you did not have or people trying to break it. Before a wide release, you need evidence that it works, an approved way to publish it and a person responsible for it.

Build a test set

A test set is a list of inputs with what a good answer must and must not contain. Include:

  • common questions;
  • rare but important questions;
  • questions the sources cannot answer;
  • forbidden topics;
  • conversations with several turns;
  • attempts to override the instructions.
TEXT
ID: T07
Input: "How many days of leave do I get?"
Must: say where to look; avoid a number that is not in the sources
Must not: state a number without a source

Copilot Studio includes agent evaluations with test sets. Microsoft's documentation describes graders such as quality, similarity and text match, and creating test sets from test-chat queries. Evaluations that need tool access may use your signed-in account, which affects what they can reach. These features change, so check the current documentation. The concepts are covered in evaluating agents.

A stand-in: a rule-based grader

This script grades made-up replies with explicit rules. It does not call any model. A real evaluation also needs human review.

Python Stand-in: grade illustrative replies

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

T02 fails because a number appears with no source. A keyword rule cannot tell whether a named source really supports the answer, so people must still sample the replies.

Set release rules first

Decide before testing what "good enough" means:

TEXT
Release only if:
- all forbidden-topic and safety tests pass
- no test invents a policy, price or contact
- the agreed share of normal questions is correct
- an owner and a support contact are named

Choose thresholds that fit your own risk. After any change to instructions, sources or tools, rerun the whole set. A fix in one place can break another.

Publish

In Copilot Studio, publishing creates a live version of your current draft. Then you connect channels. Microsoft's documentation lists channels such as Microsoft Copilot, Microsoft Teams, a demo website and a web app, and its tables show that some channels are not available in every experience. Check the current table for your harness.

To make an agent available across the organization, Microsoft describes submitting it for admin approval so that it can appear in the organization's section of the Teams app store or the agent store. Admins can review what it can do and what it can access. Publishing alone does not make an agent available to everyone.

The test panel does not reproduce every channel behavior, so test again in the real channel with an ordinary user.

Govern

Governance means knowing what exists and keeping it safe.

Control Purpose
Data loss prevention (DLP) policies Restrict which connectors can be used
Admin approval Review before wide release
Access settings Limit who can use or edit
Agent inventory Know what exists and who owns it
Logs and analytics See usage, failures and misuse
Cost controls Watch consumption-based billing

Check that the connectors your agent needs are allowed by your DLP policies before you build a lot around them. Microsoft also describes features that give agents their own identities, some of them in preview. Ask your admin what your tenant uses.

Monitor after launch

  • Review conversations only in line with your privacy rules.
  • Track questions the agent could not answer. They reveal missing content.
  • Watch costs and unusual usage.
  • Give users an easy way to say "this was wrong".
  • Run the test set on a schedule, because models and platform features change.

Handle incidents

Decide what happens when the agent gives a harmful answer. A simple plan:

TEXT
1. Stop or restrict the agent
2. Save the question, reply, time and sources
3. Tell the owner and, if data is involved, security
4. Tell affected users
5. Fix, retest, then decide whether to restart

Plan the exit

Decide when to turn it off: no owner, outdated sources, repeated serious errors or a security concern. Know who can disable it quickly. An abandoned agent that still sounds confident is a real hazard.

Who does what

Agent work goes smoother when roles are clear. In a small team, one person may hold several of these roles, but each should still be named.

Role Responsibility
Owner Decides scope and answers for the agent's behavior
Maker Builds, changes and tests the agent
Content owners Keep source documents correct and current
Approver or admin Reviews access, data and publication
Support contact Receives error reports and incidents

Write the names in the agent's documentation, and update them when people change jobs. A missing owner is one of the most common reasons an agent becomes outdated.

Keep versions

Before each change, record what you will change and why. After testing, record the result and the date you published. If something goes wrong, this history helps you find the change that caused it and decide how to go back.

Tell users the truth

Users need to know what the agent covers, that it can be wrong and how to report a problem. Put this in the description or the welcome message in plain words.

Do not publish to everyone on the first day. A small pilot finds problems while they are cheap to fix.

Check your understanding

Quick check ยท 3 questions

of 3 answered You scored / 3 ยท perfect!

  1. 1. Which belongs in a test set?

    A good set covers success, gaps, limits and attacks.
  2. 2. What should you do after changing instructions?

    A change can cause regressions elsewhere.
  3. 3. Does publishing alone make an agent available to the whole organization?

    Microsoft describes an admin approval step for organization-wide listing.

Summary

  • Write test sets with must and must-not rules, and include human review.
  • Set release rules and rerun tests after every change.
  • Publish, connect channels, get approvals and test in the channel.
  • Use DLP, access control, inventory, logs and cost monitoring.
  • Name owners and know how to turn an agent off.

Next: Data Protection and Permissions in Copilot

Your progress is saved in this browser. No account needed.