Call an agent from a workflow agent node

Completed

A connected agent handles requests that arrive in a conversation, but some work starts from an event in an automation instead of a user's message. In this unit, you learn how to call a published agent from a workflow agent node, write the message for each run, decide when a step needs a new agent that can request human assistance, and use the agent's response in later workflow steps.

Call a GitHub Copilot harness agent from automation

To call an agent powered by the GitHub Copilot harness from automation, add an agent node to a Copilot Studio workflow. The Microsoft Copilot Studio connector in Power Automate cloud flows doesn't support agents powered by the GitHub Copilot harness.

When the agent node runs, the workflow waits for the agent to complete its task. The agent's response is then available to later steps.

Choose an existing agent or a new agent for the workflow

The agent node offers two options under Agent:

Option What runs When it fits
An existing agent A published agent, with the instructions, tools, and knowledge it's already configured with The agent is used in more than one workflow or outside workflows, or another team owns it.
New agent for this workflow An inline agent, configured in the node and scoped to this workflow The agent's job is specific to this automation, and you don't need it elsewhere.

An inline agent can't be reused in other workflows. If you need the same agent in more than one place, build it as a published agent and select it as an existing agent. Agent node evaluations, which check a test run's output against criteria you describe, are available only for inline agents.

In the example, the onboarding workflow runs when a new-hire record is created, and one step needs a benefits summary for the new employee. The HR team already publishes and maintains the HR benefits agent, so the workflow calls it as an existing agent.

Add an agent node that calls a published agent

  1. In Copilot Studio, go to Workflows, and open an existing workflow or create one. For an existing workflow, go to the Build tab.
  2. Select the Agent icon on the Add panel. The configuration panel for the agent node opens.
  3. Under Agent, select An existing agent, and then select the published agent from the list.
  4. In the Message field, write what the agent should do for this run.

Write the message for each run

The published agent already has its instructions, tools, and knowledge. The Message field tells it what to do for this run. Use the dynamic content picker to insert values from earlier steps, so the agent works with the data for this run.

Write the message as a complete task. State what the agent should do, include the inputs it needs, and describe the response you want back.

In the example, the message reads: "Draft a benefits summary for a new employee who starts on Start date in the Location office. List the benefit plans they can enroll in and the enrollment deadline." Start date and Location are dynamic content from the workflow trigger.

Decide when to request human assistance

When you configure a new agent for the workflow, you can turn on Request human assistance when unsure. With this setting on, the agent can escalate when it isn't confident enough to act on its own. The agent emails the connection owner for input and waits for a reply before it continues.

Turn on this setting for high-stakes decisions, where being wrong costs more than being slow. Examples include exception handling on financial transactions, edge-case approvals, and judgment calls on customer escalations.

In the example, the benefits summary is informational and comes from an existing agent, so it doesn't need human assistance. A step that uses a new agent for the workflow to approve exceptions to a benefits policy is a better fit for the setting.

Use the agent's response in later steps

The agent response becomes dynamic content that any later step can use:

  1. Select the next action where you want to use the result.
  2. Open the dynamic content picker on the field you want to fill.
  3. Pick the agent's response from the outputs of the Agent step.

In the example, the next step inserts the agent response into a welcome email to the new employee.

Test the agent node

Before you publish the workflow, test the node on its own:

  1. Select the agent node to open its side panel.
  2. Select the Test tab.
  3. Enter inputs manually, or use inputs from a previous workflow run.
  4. Select Run test.

The test runs the agent with its current configuration and shows the generated output. Testing might consume Copilot Credits.

Reflect: Pick a step in one of your automations that needs judgment. Would you call an existing published agent for that step, or configure a new agent for the workflow so that it can request human assistance?