Looking for the documented pattern for conditional branching in multi agent workflows

DipenduSingh-7445 80 Reputation points
2026-07-12T02:18:27.7066667+00:00

I have background with basic orchestration tools generally but I'm still learning Foundry's multi agent workflow canvas specifically.

My scenario has three agents: retrieval_agent, planning_agent, action_agent. The planning agent's structured output should determine routing:

{
  "next_step": "action_agent",
  "reason": "sufficient context retrieved",
  "loop_back": false
}

In some cases loop_back should be true and route back to retrieval_agent instead.

What I built:

  • Connected the three agents in the workflow canvas as a linear sequence (retrieval_agent → planning_agent → action_agent), which runs correctly for the simple case.
  • Could not find a node type or connector for conditional routing off a structured field like next_step or loop_back, only fixed sequential edges.
  • As a workaround, had planning_agent emit the routing JSON above, then wrote this outside the canvas to route manually:
result = planning_agent_run.output
if result["loop_back"]:
    next_agent = retrieval_agent
else:
    next_agent = action_agent

This works but bypasses the native workflow feature for the part that actually needs logic. I read through the multi agent orchestration overview and workflow canvas docs but every example was linear. Is there a router node or condition edge type I'm missing in the canvas, or is branching genuinely expected to be handled at the application layer via SDK once flows exceed a fixed sequence?

Foundry Agent Service
Foundry Agent Service

A fully managed platform in Microsoft Foundry for hosting, scaling, and securing AI agents built with any supported framework or model

0 comments No comments

Answer accepted by question author

Jubin Soni 620 Reputation points
2026-07-12T03:58:31.13+00:00

Hi @Dipendu Singh , thank you for your question!

There is a native way to do this, you're not missing a completely separate node type, you're missing the If/Else flow node, which is exactly the router you're looking for. In the workflow canvas, select the + icon after planning_agent, then under the Flow category choose If/Else (not a plain sequential edge). This creates a branching node where the condition is written as a Power Fx expression referencing your agent's captured output, for example, checking Local.PlanningOutput.loop_back = true (assuming you've captured planning_agent's structured JSON output into a local variable via Set variable, or directly via the agent node's "Save agent output as" field). One branch of the If/Else can route back to retrieval_agent (creating a loop in the canvas), and the other routes forward to action_agent.

A couple of things that trip people up here, since your JSON output needs to be usable in a condition:

  • Make sure planning_agent's structured output is saved into a local variable (via the agent node config, not just returned as raw chat output), Power Fx conditions in If/Else nodes reference Local.* or System.* variables, not raw unstructured agent text.
  • Conditions are written with the Local. or System. prefix (e.g. Local.LatestMessage or your captured JSON field), and comparisons use Power Fx syntax, not Python/JS boolean syntax, so Local.PlanningOutput.loop_back = true, not ==.
  • If/Else nodes can be nested, so for more than two routing outcomes (not just your current binary case) you can chain a second If/Else inside the Else branch.

So to directly answer your question: branching is a first-class canvas feature via If/Else + Power Fx conditions, not something you're expected to push out to the SDK, your workaround is correct in spirit, but the native equivalent keeps the whole flow (including the loop back to retrieval_agent) visible and traceable inside the canvas rather than split across canvas + application code.

One caveat worth flagging: Microsoft has announced workflows (the visual canvas) are being retired December 1, 2026 in favor of a code-first model via Microsoft Agent Framework, so if this is going into a long-lived production system, it may be worth building the conditional routing directly in Agent Framework's conditional edges (WorkflowBuilder.AddEdge with a condition parameter) instead of the canvas, to avoid a migration later.

Please upvote or accept answer if this is helpful!

Was this answer helpful?

2 people found this answer helpful.
0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.