Search techniques

  • Black belt
  • Premium
  • Tip 174

Self-healing calls for agents

Quiz question

Why can't an agent correct errors from a directly bound connector itself?

Solution

  1. A) Agents cannot use connectors in Copilot StudioWrong. Connectors can be bound directly as a tool. The problem is what happens with an error status.
  2. B) Connectors only report errors by email to the ownerWrong. The call ends as a failed tool call with an error code such as HTTP404NotFound, not with an email.
  3. C) The call fails before the API message arrivesCorrect. Any status outside 2xx ends the tool call with an error code. Only a flow that always returns readable JSON makes the message visible to the agent.

What it is about

If you bind a connector directly as a tool to a Copilot Studio agent, every status outside 2xx ends as an error, for example HTTP404NotFound or HTTP422UnprocessableEntity. The explanation from the API never reaches the agent, so it cannot correct itself. The fix is a flow in between. The call sits in a scope, and the next action runs after "is successful", "has failed" and "has timed out". At the end, "Respond to the agent" always returns the same shape: ok, status, error and data. coalesce() reads the status and returns 0 when there is no response. Now the agent sees the message, adjusts the path or body and tries again. Limit the attempts in the instructions, for example to three. Corrections that always apply go into the tool description.

The expression from the tip

coalesce(outputs('HTTP')?['statusCode'], 0)

When to use it, when not

Use it

When an agent calls an API through a connector or the HTTP action and wrong paths or bodies can occur.

Better not

When the call regularly takes longer than 100 seconds. The flow then ends with FlowActionTimedOut before any answer arrives.

Most common mistake

Not limiting the attempts. The agent then keeps repeating the call and burns tokens instead of explaining the error.

License

Premium Premium connectors or features require suitable usage rights, for example from Power Automate Premium, Process, Power Apps or Dynamics 365. Check existing licenses in the license check. Source on Microsoft Learn: List of all Premium tier connectors, FAQ for agent flows. For your whole flow: License check.

Full tip on powerplatformtip.comPowerPlatformTip #174, with screenshots

Share

Short link: powerautomate.ninja/en/174

Source: PowerPlatformTip #174, Microsoft Learn: Resolve Microsoft Copilot Studio agent error codes.

Prefer to continue with guidance? The Power Automate live course (in German) at the Power Platform Academy runs over four weeks. The next dates are not set yet, you can join the waiting list on the course page.