Multi AI agents

 

 

Introduction (From micro-services to multi-agents)

Since the 2010s, software systems have grown a lot in size and complexity. As the number of lines of code increased, developers realized that monolithic applications are not always the best choice. This is why microservices became very popular.

Microservices work well, especially in large companies with big teams, for several reasons:

  • Teams can be split by business domain (one team per department).
  • Each service can use a different programming language or different dependencies.
  • Big and risky upgrades are easier to avoid (for example, migrating from Python 2 to Python 3).
  • Testing becomes simpler.
  • Code is more reusable: the same microservice can be used by multiple teams.

Interestingly, AI agents have followed the same path: At first, people tried to build large, very smart agents that do everything. Over time, it became clear that this approach has many problems:

  • The more general an agent is, the worse its performance becomes. This is similar to prompt engineering: vague prompts produce weaker results.
  • Evaluating a complex agent is very hard. It is often impossible to know if it followed the right reasoning path.
  • An agent without a clear mission is difficult for other teams to reuse.

For these reasons, multi-agent systems have become popular. Instead of one big agent, we build many small, specialized agents that communicate with each other.

In this article, we will explore common multi-agent architectures and walk through a practical example.

 

Why Use Multi-Agent Systems?

Multi-agent systems have several clear advantages:

  • Each agent can use the best tools for its specific task.
  • Prompts and workflows can be simple and focused.
  • Current LLMs struggle when they have too many tools at once. A good practice is to limit each agent to 5–15 tools.

This makes the system easier to understand, maintain, and improve.

 

Common Multi-Agent Architectures

There is no perfect architecture. The best choice always depends on your use case. That said, some patterns are used very often.

1. Planner-Executor Architecture:

In this setup, one main agent (the planner) breaks a task into smaller subtasks. These subtasks are then sent to specialized agents (the executors).

capture d’écran 2026 01 07 à 14.30.43

Example: For a travel planning system:

  • One agent searches for hotels.
  • Another looks for flights.
  • A third builds a sightseeing plan.

The orchestrator agent combines all results and provide the final result

capture d’écran 2026 01 07 à 14.35.17

2. Consensus-Based Architecture

In this approach, multiple agents work on the same task at the same time. These agents can have different “personalities”: Some may be more creative, Others may be more strict or data-focused.

Each agent produces its own solution. Then, a consensus mechanism selects the best one.

This approach costs more (because several agents run in parallel), but the extra cost is usually small compared to the improvement in result quality.

capture d’écran 2026 01 07 à 14.46.07

3. Collaborative Architecture

Here, agents talk to each other and improve the solution together.

A common example is cross-reflection:

  1. Agent A produces a solution.
  2. Agent B reviews it and gives feedback.
  3. Agent A updates its solution.
  4. This continues until the result is validated.

This works very well for tasks that need reasoning, review, and refinement.

capture d’écran 2026 01 07 à 14.49.09

Tutorial: A Simple Multi-Agent Financial Advisor

Let’s look at a concrete example: building a financial advisor using multiple agents. You can find all the code in this google colab notebook.

Step 1: The Specialized Agents

  • Technical Analysis Agent:
    • A Python executor agent (LangChain ReAct).

    • Uses the model claude-sonnet-4-5-20250929 from Anthropic, known for strong coding skills.

    • Its job is to compute technical and fundamental financial indicators (like SMA25, RSI, …)

    • Example: calculating technical metrics for the MSFT stock by running Python code.

Python
for event in python_agent.stream({"messages": ["Please compute SMA25 and RSI for ALphabet (GOOG) ?"]}, stream_mode="updates"):
  message = event.get("model", event.get("tools"))["messages"][0]
  message.pretty_print()

Here is an example of code executed by this agent

Python
import yfinance as yf
import pandas as pd
import numpy as np

# Fetch historical data for GOOG
ticker = "GOOG"
data = yf.download(ticker, period="3mo", progress=False)

# Calculate SMA25 (25-day Simple Moving Average)
data['SMA25'] = data['Close'].rolling(window=25).mean()

# Calculate RSI (Relative Strength Index)
def calculate_rsi(prices, period=14):
    """Calculate RSI indicator"""
    delta = prices.diff()
    gain = (delta.where(delta > 0, 0)).rolling(window=period).mean()
    loss = (-delta.where(delta < 0, 0)).rolling(window=period).mean()
    rs = gain / loss
    rsi = 100 - (100 / (1 + rs))
    return rsi

data['RSI'] = calculate_rsi(data['Close'], period=14)

# Display the last 10 rows with relevant columns
result = data[['Close', 'SMA25', 'RSI']].tail(10)
print(f"Technical Indicators for {ticker}")
print("=" * 70)
print(result)
print("\n" + "=" * 70)
print(f"\nLatest Values (as of {data.index[-1].strftime('%Y-%m-%d')}):")
print(f"Close Price: ${data['Close'].iloc[-1]:.2f}")
print(f"SMA25: ${data['SMA25'].iloc[-1]:.2f}")
print(f"RSI (14): {data['RSI'].iloc[-1]:.2f}")

 

  • Market News Agent
    • A standard ReAct agent.
    • Uses Yahoo Finance to fetch company news.

      Example: retrieving the latest MSFT news from the past month.

Python
market_news_agent.invoke({"messages": "retrieving the latest MSFT news from the past month"})
>> The latest news highlights Microsoft (MSFT) as a top artificial intelligence investment pick for 2026, with Wedbush analyst Dan Ives calling the company the “clear front-runner” in this area. Additionally, experts discuss how Microsoft's Azure cloud growth is favored in the AI race compared to Google's potential risk to its advertising revenue. Would you like more detailed information on any of these news items?

Step 2: Putting Everything Together

We use a plan-and-solve agent as the main orchestrator:

  • It breaks the user request into steps.
  • For each step, it calls the right sub-agent as a tool.
  • Each sub-agent returns focused results.
  • The main agent combines everything into a clear final answer.

This design is very similar to microservices: small, independent components working together.

capture d’écran 2026 01 07 à 15.52.07

Let’s ask our multi-agent one question:

Python
human_message_content = """
  Which stock is better to buy currently: microsoft (MSFT) or google (GOOG) ? Here are my constraints:
  - Investment horizon (e.g., 1 year, 5+ years): 5+ year
  - Risk tolerance (low/medium/high): medium
  - No diversification or task consideration constraint
  - I want one winner between both
"""
messages = [
    HumanMessage(content=human_message_content)
]


for step in  plan_and_solve_agent.stream({"messages": messages}):
  print(step)

step["final_answer"]["final_answer"].pretty_print()
>> ================================== Ai Message ==================================

**Recommendation: Buy Microsoft (MSFT)**

**Reasoning:**

1. **Valuation and Growth Potential:**
   - Microsoft (MSFT) demonstrated stronger intrinsic value and growth prospects compared to Google (GOOG) under both base case and alternative scenarios. Despite a current market price above its intrinsic value, MSFT's diversified business model and cloud growth provide a stable foundation for long-term investment.

2. **Financial Strength and Profitability:**
   - MSFT has a robust balance sheet and superior cash flow quality, which aligns well with a medium risk tolerance. It also shows sustainable earnings power, supported by its strong operating margins and cash flow generation.

3. **Risk Assessment:**
   - While both companies face regulatory and competitive risks, Google's regulatory uncertainty is higher, particularly concerning its advertising and data practices. MSFT's diversified business mix offers a more stable risk profile.

4. **Market and Economic Sensitivity:**
   - MSFT is more sensitive to interest rate changes, which could impact its valuation in a rising rate environment. However, its leadership in AI and cloud services positions it well for future growth, mitigating some of these risks.

5. **Practical Considerations:**
   - For entry points, consider gradual investment to capture potential valuation inflection points. Monitor quarterly earnings, regulatory developments, and macroeconomic indicators to adjust the investment strategy as needed.

Overall, MSFT is recommended for a 5+ year investment horizon with medium risk tolerance due to its strong financials, growth potential, and relatively stable risk profile compared to GOOG.

Conclusion

Multi-agent systems are a natural evolution of agent design. Instead of building one large and complex agent, we get better results by using small, focused agents that:

  • Are easier to evaluate.
  • Are easier to reuse.
  • Perform better at their specific tasks.

Just like microservices changed how we build software, multi-agent systems are changing how we build AI applications. As models and tools improve, we can expect even more flexible, collaborative, and powerful agent systems in the future.