Module 5 · Lesson 2 · 14 min read

Agent roles and communication between them

Agent Roles and Communication

Introduction

The success of any team starts with clear roles and a clear way of communicating. In this lesson we learn to write a role card for each agent, design structured messages that agents exchange, and compare the channels of direct communication, a shared blackboard and broadcast.

Learning objectives

  • Write a role card that defines the agent's goal, its tools and the shape of its output
  • Design a structured message between agents with clear fields
  • Distinguish between direct communication, a shared blackboard and broadcast
  • Define rules for ending the conversation between agents

The role card: a contract between the agent and the team

A role in a multi-agent system is not just a nice name; it is a contract that defines what the agent does and what it does not do. Frameworks such as CrewAI rely on this idea explicitly: each agent in them is defined by three required fields: role, goal and backstory (according to the official documentation, reviewed 18 November 2026). Independently of any framework, we suggest that the role card contain:

  • Name and role: such as "Source researcher".
  • Goal: a single measurable sentence, such as "Gather five documented facts about the topic".
  • Allowed tools: a short list, such as knowledge_search only.
  • Expected inputs: what it receives and from whom.
  • Output shape: a specific structure that is easy for the next agent to read.
  • Limits: what it must not do, such as "Do not write the final report".

Structured messages

When people communicate we accept ambiguity because we ask and clarify. Between agents, an ambiguous message produces a chain of errors. So we prefer a structured message with fixed fields instead of free text. An example of a message from the researcher to the writer:

json
{
  "task_id": "report-17",
  "sender": "researcher",
  "receiver": "writer",
  "type": "result",
  "content": {
    "facts": ["Photovoltaic panels convert sunlight into electricity."],
    "sources": ["kb://energy/solar"]
  },
  "round": 1
}

Common message types: a request to assign a task to an agent, a result to return the output, feedback to ask for a revision, and an error when the agent fails. The task_id field links the messages to the same task, and the round field helps stop loops.

Communication channels

ChannelHow it worksWhen it fits
DirectOne agent sends to a specific agentClear paths, such as researcher then writer
Shared blackboardEveryone writes to a single state and reads from itTeams whose members need to see all the progress
BroadcastA message that reaches all the agentsAnnouncing a change of goal or stopping work

The direct channel is easier to trace, and the shared blackboard is more flexible but needs clear rules about who writes to which field. Broadcast is used with care, because a single message that reaches everyone may make every agent start work it was not asked to do. Many practical systems combine the channels: direct messages for assignments, a shared blackboard to record progress, and a rare broadcast to stop work.

A practical example: a small message bus

We build a simple message bus that checks the required fields and logs every message, then we pass a task between a researcher and a writer. The agents here are deterministic functions for teaching only:

python
REQUIRED = {"task_id", "sender", "receiver", "type", "content"}
log = []

def send(msg, agents):
    missing = REQUIRED - msg.keys()
    if missing:
        raise ValueError(f"Incomplete message, missing fields: {sorted(missing)}")
    log.append(msg)
    return agents[msg["receiver"]](msg)

def researcher(msg):
    facts = ["Wind turns turbines that generate electricity."]
    return {"task_id": msg["task_id"], "sender": "researcher",
            "receiver": "writer", "type": "result", "content": {"facts": facts}}

def writer(msg):
    text = " ".join(msg["content"]["facts"])
    return {"task_id": msg["task_id"], "sender": "writer",
            "receiver": "user", "type": "result", "content": {"text": text}}

agents = {"researcher": researcher, "writer": writer}
request = {"task_id": "t1", "sender": "user", "receiver": "researcher",
           "type": "request", "content": {"topic": "Wind energy"}}
reply = send(request, agents)
final = send(reply, agents)
print(final["content"]["text"])
for m in log:
    print(m["sender"], "->", m["receiver"], ":", m["type"])

The message log log is not a minor detail; it is the first thing you will open when the team gives a strange result, because it shows who sent what to whom.

When does the conversation end?

One of the most dangerous communication problems between agents is that they keep exchanging notes endlessly. Set explicit termination rules:

  1. A maximum number of rounds, such as three review rounds.
  2. A checkable success condition, such as "no notes from the reviewer".
  3. A message of type error that stops the path and returns the reason to the user or the supervisor.

With these rules communication turns from an open chat into a working protocol that can be tested and traced.

Summary

The role card defines each agent's goal, its tools, its inputs, the shape of its output and its limits. Structured messages with fixed fields such as task_id, sender, receiver and type are clearer than free text and easier to trace. Communication channels vary between direct, shared blackboard and broadcast according to the team's needs. And explicit termination rules are a must to prevent infinite loops.

Terms

TermEnglishDefinition
RoleRoleA description of the agent's responsibility and its limits within the team
Structured messageStructured MessageA message with fixed fields that another agent can easily read
Message busMessage BusA component that passes messages between agents and logs them
Shared blackboardBlackboardA shared state that agents read from and write to
BroadcastBroadcastSending a single message to all the agents
Termination ruleTermination RuleA condition that stops communication between agents

Review questions

  1. What fields would you suggest for the role card of a reviewer agent?
  2. Why are structured messages preferred to free text between agents?
  3. Compare the shared blackboard and direct communication in terms of flexibility and ease of tracing.
  4. Suggest two termination rules for a conversation between a writer and a reviewer.

References