0
0
Agentic AIml~5 mins

Single agent vs multi-agent systems in Agentic AI

Choose your learning style9 modes available
Introduction
Single agent and multi-agent systems help us understand how one or many decision-makers act to solve problems or complete tasks.
When you want to build a system where one agent makes all decisions alone.
When multiple agents need to work together or compete to solve a problem.
When simulating real-world scenarios like traffic with many cars (agents).
When designing robots that must cooperate to complete a task.
When studying how agents interact in games or markets.
Syntax
Agentic AI
class Agent:
    def act(self, state):
        # Decide action based on state
        pass

# Single agent system
agent = Agent()
state = ...
action = agent.act(state)

# Multi-agent system
n = 3
agents = [Agent() for _ in range(n)]
states = [...]  # states for each agent
actions = [agent.act(s) for agent, s in zip(agents, states)]
In single agent systems, only one agent interacts with the environment.
In multi-agent systems, multiple agents interact, possibly affecting each other.
Examples
A simple single agent always decides to 'move forward' regardless of state.
Agentic AI
class Agent:
    def act(self, state):
        return 'move forward'

agent = Agent()
action = agent.act('start')
print(action)
Three agents each decide actions based on their own state.
Agentic AI
class Agent:
    def act(self, state):
        return f"agent moves based on {state}"

agents = [Agent() for _ in range(3)]
states = ['north', 'east', 'south']
actions = [agent.act(s) for agent, s in zip(agents, states)]
print(actions)
Sample Model
This code shows how one agent acts alone and how multiple agents act with their own states.
Agentic AI
class Agent:
    def __init__(self, name):
        self.name = name
    def act(self, state):
        return f"{self.name} acts on {state}"

# Single agent example
single_agent = Agent('Agent1')
single_action = single_agent.act('state1')
print('Single agent action:', single_action)

# Multi-agent example
agents = [Agent(f'Agent{i}') for i in range(3)]
states = ['stateA', 'stateB', 'stateC']
actions = [agent.act(state) for agent, state in zip(agents, states)]
print('Multi-agent actions:', actions)
OutputSuccess
Important Notes
Multi-agent systems can be cooperative or competitive depending on the problem.
Communication between agents can improve multi-agent system performance.
Single agent systems are simpler but may not model complex interactions well.
Summary
Single agent systems have one decision-maker acting alone.
Multi-agent systems have many agents acting and interacting together.
Choosing between them depends on the problem's complexity and interaction needs.