How To Use Multi-Agent Orchestration In Copilot Studio

How To Use Multi-Agent Orchestration In Copilot Studio

You can use multi-agent orchestration in Copilot Studio to enable collaboration among agents, allowing them to solve complex problems. In this pattern, a parent agent co-ordinates the workflow by calling child agents to perform specific tasks. Child agents can either be embedded in the parent agent and use a subset of the parent’s knowledge tools. Or child agents can be separate standalone agents having their own knowledge and tools.




Introduction: The Expense Report Reviewer Agent

The Expense Report Reviewer Agent built in Copilot Studio reads Excel based expense reports and determines whether they meet the requirements for reimbursement.



Users upload their an expense report inside of a chat window and the Agent tells them if there are any issues. In this example, the has found duplicate expense items and expenses with an incorrect accounting code.



The Agent uses a multi-agent pattern to accomplish its goal where each type of review conducted is performed by a child agent.




Write Instructions For The Parent Agent

Open Copilot Studio and create a new Agent named the “Expense Report Reviewer Agent”.



The Agent will call child agents to perform expense report reviews and answer general questions about the company travel policy.



Use this set of instructions for the Expense Report Reviewer Agent. Placeholder values for calling child agents will be replaced with direct references once the agents are created.

When the user asks for an Expense Report Review

1. Run [Read Excel File Topic] to read the Excel file.
2. Use the following Agents once each, and act according to their instructions to review the expense report: [Duplicate Expense Items Checker], [Expense Classification Checker].
3. Output the updated Excel file using

When the user asks a Question About Travel Expense Policy & Reimbursement use the [Travel Policy FAQ Agent] to answer them.

Strict Instructions: – Do not assist the User with any other tasks




Create A Topic To Read The Excel File

The Agent will accept an Excel file in the chat window and read the values on each worksheet. To do this, create a new topic named “Read The Excel File.” Use a question node to ask for the Excel file. Then include a prompt to read the Excel file and store the output in a global variable so it can be used by the child agents.



Ensure the variable varExcelExpenseReportJSON is configured as a global variable.




Get Cell Values From A Worksheet With A Code Interpreter Prompt

The prompt action “Read An Excel File And Return All Values” will iterate through all worksheets in the Excel file and return a JSON of all cell addresses & values.



Copy and paste this prompt into the instructions window. Choose a document data type for the Excel File variable.

Goal:
Read an Excel File and extract the values of the cells in each worksheet .

Inputs:
Excel file: [Excel File]

Instructions:
1. Open the Excel workbook and get all worksheets.
2. Get the used range of each worksheet
3. Extract the value of all non-blank cells in the used range as strings and load into a Python dictionary
4. Output the response as a JSON in the following format:

{
  “worksheets”: [
    {
      “worksheet_name”: “Tab1”,
      “cells”: [
        { “range”: “A1”, “value”: “myvalue1” },
        { “range”: “B1”, “value”: “myvalue2” },
        { “range”: “C3”, “value”: “myvalue3” }
      ]
    },
    {
      “worksheet_name”: “Tab2”,
      “cells”: [
        { “range”: “A1”, “value”: “myvalue1” },
        { “range”: “B1”, “value”: “myvalue2” },
        { “range”: “C3”, “value”: “myvalue3” }
      ]
    }
  ]
}



The Excel file variable will not accept an Excel file type unless Code Interpreter is enabled in the Settings menu.



Go to the settings menu and turn on Code Interpreter. If the code interpreter setting cannot be turned on go to Copilot setting in the Power Platform Admin Center and enable it for the environment.




Output The Excel File Cell Values As A JSON

Test the prompt to ensure it works by uploading a sample file. The travel expense report for this tutorial can be downloaded here.



Then change the model response output type to JSON and press the Test button. The JSON output by the prompt will look like this:




Add A Child Agent To Check For Duplicate Expenses

Each type of review performed on the expense report will be completed by a child agent.



Choose the create an agent option. This will embed the child agent directly into the parent agent. The child agent will not be available for re-use by other agents.



A child agent has its own set of instructions, knowledge and tools it can use to accomplish its goal.



Copy and paste these instructions into the Duplicate Expense Item Checker child agent.

1. Review the [Global.varExcelExpenseReportJSON] for any potential duplicate expense items

2. If duplicate expense items are found, output the message to the user in this format.

Sample message format:
“The following duplicate expense items were found in your report:
* McDonalds
* Date: 2002-04-23
* Total Amount: $123.45 (appears twice)

* Uber
* Date: 2013-06-15
* Total Amount: $57.46 (appears three times)”

3. “Or, if there are no duplicate items found, output a message variation that says “No duplicate expense items were found.”

Strict Instructions:
DO NOT output any additional text after the sample message format.




Upload Accounting Expense Codes As Agent Knowledge

The next child agent we create will review the account code applied to each expense item and determine if the proper selection was made. It will use a PDF with a list of account codes, account names and descriptions as knowledge to help make a decision.

The accounting expense codes PDF file is available here.



Go the knowledge tab of the parent agent and upload the accounting expense codes PDF file.



Include a description to provide context so the Agent knows when to use Accounting Expense Codes.pdf.



Copy and paste this text into the description field.

This knowledge source contains accounting expense codes and their descriptions to help employees correctly classify their expense items.




Build Another Child Agent To Review Expense Classifications

Go to the agents menu and create another agent named Expense Classification Checker.

The Expense Classification Checker will review each line item in the Excel file to determine if the proper accounting code was applied. Add the Accounting Expense Codes.pdf to the child agent’s knowledge.



Copy and paste these instructions into the child agent’s instructions.

1. Apply this reasoning-method for each expense item in [Global.varExcelExpenseReportJSON] to check if the correct expense code was used:
– Item 1: JD Marriot on 2025-03-04 in the amount of $425.25 was classified was 5004 – Hotel & Lodging. The correct accounting code is 5004 – Hotel & Lodging because JD Marriot is a company in the hotel & resort industry. [Correct expense code was applied]
– Item 2: McDonalds on 2002-04-23 in the amount of $123.45 was classified as 5004 – Hotel & Lodging. The correct accounting code is 5001 – Meals And Entertainment because McDonalds is a restaurant. [Incorrect expense code was applied.

2. If the Agent identifies any misclassified items send a message to the user as shown below.
Sample message format:
“Expense codes should be changed for the following items :
* McDonalds
* Date: 2002-04-23
* Total Amount: $123.45
* Current Accounting Code: 5004 – Hotel & Lodging
* Corrected Accounting Code: 5001 – Meals And Entertainment
* Uber
* Date: 2013-05-01
* Total Amount: $456.78
* Current Accounting Code: 5004 – Hotel & Lodging
* Corrected Accounting Code: 5003 – Ground Transportation”

Or, if there are no misclassified expense items found, send a message variation that says “All items on the expense report have the correct account codes.”

Strict Instructions:
– MUST include whether each expense item in [Global.varExcelExpenseReportJSON] is correct or incorrect in the response.
– STRICTLY DO NOT send any messages other than described in step 2.
– DO NOT ask the user any questions in the message output to the user.




Review An Expense Report In Copilot Studio Using Agent-To-Agent

Before we test the Expense Report Reviewer agent we must update the parent agent instructions with references to the topic and agents we created.



The expense report we will upload to the Agent has two issues:

  • Air Canada airfare expense for $502.16 is a duplicate expense item
  • Yellow Cab Taxi service for $22.30 and $999.99 should be classified as Ground Transportation but are incorrectly assigned Hotel & Lodging and Office Supplies



Open the test pane in Copilot Studio and ask the agent to “review my expense report.” Upload the expense report file and wait for the review to be performed.



The agent will return the following results.



And the activity map shows the child agents we built were used to review the Excel file.




Connect An Existing Copilot Studio Agent To The Parent Agent

Agents can connect to existing Copilot agents and use them as sub-agents. We will create a standalone Copilot Studio to add to our parent agent in the next section of this tutorial.

Use this description for the Travel Policy FAQ Agent once it is added.




Make A Standalone Travel Policy FAQ Agent In Copilot Studio

Create a new agent in Copilot Studio named Travel Policy FAQ Agent. This agent will answer common questions about the travel policy. It can be used independently or connected as a child agent.



Copy and paste these instructions into the Travel Policy FAQ Agent.

* Respond to employee questions in a clear & concise manner and provide actionable advice.
* Cite the section number where the answer was found in the “Travel Expense Policy.pdf”, for example: “(see 8.1 Approvals for Travel)”
* Use bullet-points to make long responses easier to understand.
* Ask follow up questions if needed



Upload the Travel Expense Policy.pdf file as knowledge. The PDF file can be downloaded from this location.



Ask The Expense Report Reviewer Agent A Travel Policy Question

Go back to the Travel Expense Report Reviewer Agent ask the question “What items are reimbursable for travel expense related to hotels?” The Agent responds with an answer like the one below.



The parent agent calls the Travel Policy FAQ agent as a child agent, uses its knowledge to find the answer and responds in the chat window.



Video: Master Multi-Agent Orchestration In Copilot Studio

Watch this video for a full demonstration of how to build the expense report reviewer agent using multi-agent orchestration.





Questions?

If you have any questions or feedback about How To Use Multi-Agent Orchestration In Copilot Studio please leave a message in the comments section below. You can post using your email address and are not required to create an account to join the discussion.

Matthew Devaney

Subscribe
Notify of
guest

0 Comments
Oldest
Newest
Inline Feedbacks
View all comments