Multi-Agent solution using connected agents
In the ever-evolving landscape of AI, the transition from monolithic chatbots to specialized Agentic AI is the defining trend. While previous patterns relied heavily on manual orchestration, a new paradigm has emerged: Connected Agents.
This article explores how to architect intelligent systems using the Azure AI Foundry Agent Service to delegate complex tasks without the overhead of hardcoded routing.
1. What are Connected Agents?
Connected agents are a specialized feature in the Azure AI Foundry Agent Service that allows you to decompose large, monolithic tasks into smaller, specialized sub-agents. Instead of relying on a single "jack-of-all-trades" model, you create multiple agents with clearly defined responsibilities that collaborate to accomplish a common goal.
At the heart of this system is a Main Agent. This central orchestrator interprets user input and delegates specific sub-tasks to the connected sub-agents.
The Core Architecture:
- The Main Agent (Orchestrator): Interprets the intent behind a request and determines which connected agent is best suited to handle it.
- The Connected Agents (Specialists): Designed with a single domain of responsibility. This single-responsibility design makes the entire system easier to debug, extend, and reuse.
2. Connected Agents vs. AgentGroupChat
For developers familiar with Semantic Kernel, the concept of AgentGroupChat is often the point of comparison. However, there is a fundamental difference in the "Logic of Delegation":
| Feature | AgentGroupChat (Semantic Kernel) | Connected Agents (Azure AI Foundry) |
| Orchestration | Manual / Custom defined. | Implicit / Native delegation. |
| Routing | Requires a Selection Strategy (Sequential or Kernel Function) and a Termination Strategy to be hardcoded. | The Main Agent uses its instructions and the descriptions of sub-agents to figure out routing and sequence. |
| Complexity | Higher "boilerplate" code to define the whole flow. | Modular approach that boosts efficiency and maintainability. |
In short, while AgentGroupChat requires you to manual route one agent to another, Connected Agents use natural language descriptions to handle delegation automatically.
3. Real-World Scenario: The Engineering Support Triage
Imagine an engineering team receiving a constant flow of support tickets, including bugs, feature requests, and infrastructure issues. Manually sorting these slows down response times.
With a Connected Agent approach, you can build a Triage Assistant that assigns different sub-tasks to specialized sub-agents:
- Priority Agent: Classifies the severity of the ticket.
- Team Assigning Agent: Suggests the right internal team for the work.
- Efforts Estimation Agent: Estimates the hours or complexity required.
The Human-in-the-loop remains connected to the Main Agent, while the backend handles the specialized delegation seamlessly.
4. Setup: Building a Multi-Agent Solution
To implement this in Azure, the success of the solution depends on clearly defining the responsibilities and collaboration instructions.
The Workflow:
- Initialize the Agents Client: Create a client that connects to your Azure AI Foundry Project.
- Create Specialized Sub-Agents: Use the
create_agentmethod on theAgentClientobject to build your specialists (e.g., the Priority Agent). - Initialize the Connected Agent Tool: Use the
ConnectedAgentToolclass. Assign each sub-agent a Name and Description so the main agent knows when and how to use it. - Create the Main Agent: Use
create_agentand add your sub-agents via thetoolsproperty using theConnectedAgentTooldefinitions. - Thread and Message Management: Create a conversation thread and send the user request.
- Run the Workflow: Create a Run to process the request; the Main Agent will delegate to sub-agents as needed.
- Handle Results: Capture the final output once the specialized agents have completed their sub-tasks.
5. Why Choose Connected Agents?
This modular approach is the future of enterprise AI for several reasons:
- Maintainability: You can update the "Priority Agent" without touching the "Team Assigning" logic.
- Scalability: You can add a new "Security Auditor Agent" to the system simply by adding it to the Main Agent's toolset.
- Natural Orchestration: It reduces the need for "hardcoded routing," making the system more flexible to diverse user inputs.
Lab Section:
This lab section provides the practical implementation for building a Multi-Agent Triage Solution using the Connected Agents feature of Azure AI Foundry. Unlike the manual orchestration required in AgentGroupChat, this solution uses a central orchestrator that delegates tasks based on the descriptions of the sub-agents.
Lab: Implementing a Support Triage Orchestrator
In this exercise, you will create a main Triage Agent that leverages three specialized connected agents to analyze support tickets for Priority, Team Assignment, and Effort Estimation.
1. Project Prerequisites
Create a directory for your project and include the following files:
requirements.txt:
python-dotenv
azure-identity
azure-ai-projects.env:
PROJECT_ENDPOINT="https://<your-project-name>.services.ai.azure.com/api/projects/<project-id>"
MODEL_DEPLOYMENT_NAME="gpt-4.1"2. Implementation: agent_triage.py
This script initializes the specialized sub-agents, wraps them in ConnectedAgentTool definitions, and attaches them to the primary Triage Agent.
import os
from dotenv import load_dotenv
# Add references
from azure.ai.agents import AgentsClient
from azure.ai.agents.models import ConnectedAgentTool, MessageRole, ListSortOrder, ToolSet
from azure.identity import DefaultAzureCredential
# Clear the console
os.system('cls' if os.name=='nt' else 'clear')
# Load environment variables
load_dotenv()
project_endpoint = os.getenv("PROJECT_ENDPOINT")
model_deployment = os.getenv("MODEL_DEPLOYMENT_NAME")
# --- Specialist Agent Instructions ---
priority_agent_instructions = """
Assess how urgent a ticket is based on its description. Respond with:
- High: User-facing or blocking Issues
- Medium: Time-sensitive but not breaking anything
- Low: Cosmetic or non-urgent tasks
Only output the urgency level and a very brief explanation.
"""
team_agent_instructions = """
Decide which team should own each ticket: Frontend, Backend, Infrastructure, or Marketing.
Base your answer on the content. Respond with the team name and a brief explanation.
"""
effort_agent_instructions = """
Estimate work required:
- Small: < 1 day
- Medium: 2-3 days
- Large: Multi-day/cross-team effort
Provide a brief justification for your estimate.
"""
triage_agent_instructions = """
Triage the given ticket. Use connected tools to determine priority, assigned team, and effort.
"""
# Connect to the agents client
agents_client = AgentsClient(
endpoint=project_endpoint,
credential=DefaultAzureCredential(
exclude_environment_credential=True,
exclude_managed_identity_credential=True
),
)
with agents_client:
# 1. Create Specialist Sub-Agents
priority_agent = agents_client.create_agent(
model=model_deployment, name="priority_agent", instructions=priority_agent_instructions
)
team_agent = agents_client.create_agent(
model=model_deployment, name="team_agent", instructions=team_agent_instructions
)
effort_agent = agents_client.create_agent(
model=model_deployment, name="effort_agent", instructions=effort_agent_instructions
)
# 2. Wrap Specialist Agents in ConnectedAgentTools
priority_tool = ConnectedAgentTool(
id=priority_agent.id, name="priority_agent", description="Assess the priority of a ticket"
)
team_tool = ConnectedAgentTool(
id=team_agent.id, name="team_agent", description="Determines which team should take the ticket"
)
effort_tool = ConnectedAgentTool(
id=effort_agent.id, name="effort_agent", description="Determines the effort required"
)
# 3. Create the Main Orchestrator Agent
agent = agents_client.create_agent(
model=model_deployment,
name="triage-agent",
instructions=triage_agent_instructions,
tools=[
priority_tool.definitions[0],
team_tool.definitions[0],
effort_tool.definitions[0]
]
)
# 4. Chat Session Implementation
thread = agents_client.threads.create()
print("\n=== Ticket Triage Chat ===")
print("Enter ticket descriptions for triage analysis (Type 'quit' to exit).\n")
while True:
try:
prompt = input("User > ").strip()
if prompt.lower() in ['quit', 'exit', 'bye', '']:
break
print("Processing. Please wait...\n")
agents_client.messages.create(
thread_id=thread.id, role=MessageRole.USER, content=prompt
)
# Delegate workflow happens natively here
run = agents_client.runs.create_and_process(thread_id=thread.id, agent_id=agent.id)
if run.status == "failed":
print(f"Run failed: {run.last_error}")
continue
last_msg = agents_client.messages.get_last_message_text_by_role(
thread_id=thread.id, role=MessageRole.AGENT
)
if last_msg:
print(f"Agent > {last_msg.text.value}\n")
except KeyboardInterrupt:
break
except Exception as e:
print(f"Error: {e}")
# 5. Cleanup Resources
print("Cleaning up agents...")
for a in [agent, priority_agent, team_agent, effort_agent]:
agents_client.delete_agent(a.id)
print("Cleanup complete.")
Execution Command
To run your Connected Agents triage program, you will need to execute a few standard Python and Azure CLI commands within your terminal (such as VS Code Terminal or PowerShell).
Command
Once your environment is set up and your files are ready, run the following command to start the chat session:
python .\agent_triage.py
(Use python3 instead of python if you are on macOS or Linux)
Full Execution Checklist
If you haven't prepared the environment yet, follow these steps in order to ensure the program runs without errors:
- Authenticate with Azure:
Before running the script, you must be logged into your Azure account so the DefaultAzureCredential can verify your identity.
az login- Activate your Virtual Environment:
Ensure you are working within your isolatedmy-envso the required libraries are available.
# For PowerShell (Windows)
.\my-env\Scripts\Activate.ps1
# For Command Prompt (Windows)
.\my-env\Scripts\activate.bat- Install Dependencies:
If you haven't installed the libraries from yourrequirements.txtyet, do so now.
pip install -r requirements.txt
- Run the Program:
Execute your main triage script.
python .\agent_triage.py
Common Troubleshooting
- ModuleNotFoundError: If Python says it can't find
azure.ai.agents, ensure your virtual environment is activated (you should see(my-env)at the start of your command prompt). - Authentication Error: If the program fails at the
DefaultAzureCredentialstep, runaz loginagain to refresh your local token. - Environment Variables: Double-check that your
.envfile is in the same folder as your script and that thePROJECT_ENDPOINTis correct.
Key Lab Takeaways
- Delegation over Logic: Note that the code does not specify which sub-agent to call first. The Triage Agent uses its instructions and the tool definitions to interpret the intent and determine the best specialized agent for the job.
- Modular Debugging: Each connected agent is designed for a single responsibility (Priority, Team, or Effort), making the system easier to test and extend in production.Unified Client: A single
AgentsClientmanages the lifecycle of the orchestrator and all its connected specialists.
