
Agent Roles: Supervisors, Workers, and Evaluators
Build a high-performance AI team. Learn to define and implement specific agent roles—from high-level Supervisors to specialized Workers and rigorous Evaluators—using the Gemini ADK.
Agent Roles: Supervisors, Workers, and Evaluators
In a team of humans, "everyone doing everything" leads to chaos. Teams succeed because roles are clearly defined: managers oversee the plan, specialists execute the tasks, and auditors check the quality. To scale your Gemini ADK systems, you must apply this same organizational structure to your AI agents.
In this lesson, we will define the three primary agent archetypes: The Supervisor, The Worker, and The Evaluator. We will learn how to write system prompts for each role and how to manage the flow of information between them.
1. The Archetype 1: The Supervisor (The Brain)
The Supervisor is the "Project Manager" of your AI team. It rarely uses tools itself; instead, it coordinates the actions of other agents.
Responsibilities:
- Planning: Decomposing the user's goal into tasks.
- Delegation: Deciding which "Worker" should handle each task.
- Synthesis: Combining the outputs of various workers into a final answer.
- Conflict Resolution: Resolving contradictions between different worker reports.
Key Prompt Constraint:
"You are the Supervisor. Your task is to delegate work to 'Researcher' and 'Writer'. You do not write the reports yourself; you only coordinate the delivery."
2. The Archetype 2: The Worker (The Doer)
The Worker is a highly specialized specialist. It has access to specific tools and a narrow domain of expertise.
Responsibilities:
- Execution: Performing the technical labor (Searching, Coding, Data Analysis).
- Reporting: Providing concise "Observations" back to the Supervisor.
Types of Workers:
- The Searcher: Master of the Google Search tool.
- The Data Analyst: Master of the Python Code Interpreter.
- The API Integrator: Master of specific enterprise endpoints.
3. The Archetype 3: The Evaluator (The Critic)
The Evaluator is the most important role for production safety. Its only goal is to find errors in the Worker's output.
Responsibilities:
- Validation: Checking if the output matches the requirements.
- Safety Checking: Looking for PII, bias, or offensive content.
- Fact-Checking: Verifying the Worker's claims against the search results.
Key Prompt Constraint:
"You are the Critic. You are rewarded for finding errors. If the Worker's output is perfect, say 'APPROVED'. If you find even one minor error, provide a 'REJECTION' with specific feedback."
4. The Flow of Power: Hierarchical Architecture
A common multi-agent pattern is the Hierarchical Loop.
graph TD
A[User Request] --> B[Supervisor]
B --> C[Worker 1: Research]
C --> D[Evaluator 1: Fact Check]
D -->|Fail| C
D -->|Pass| B
B --> E[Worker 2: Drafting]
E --> F[Evaluator 2: Quality Check]
F -->|Fail| E
F -->|Pass| B
B --> G[Final Response]
style B fill:#4285F4,color:#fff
style D fill:#EA4335,color:#fff
style F fill:#EA4335,color:#fff
5. Defining the "Job Description"
In the Gemini ADK, the "Role" is defined entirely in the System Instruction.
Example: The "Security Auditor" Role
# YOUR ROLE
You are a "Worker Agent" specialized in Cloud Security.
# YOUR TOOLS
- check_iam_permissions
- scan_public_buckets
# YOUR OPERATIONAL BOUNDARIES
- You ONLY report vulnerabilities.
- You NEVER attempt to remediate them.
- Your report must be in JSON format for the 'Supervisor' to read.
6. Implementation: Defining Roles in Python
import google.generativeai as genai
def create_specialized_agent(role_type: str):
if role_type == "supervisor":
instruction = "You are a Coordinator. Delegate tasks to 'Coder'. Summarize the result."
model_name = "gemini-1.5-pro" # High reasoning
elif role_type == "coder":
instruction = "You are a Programmer. Write Python code based on delegator requests."
model_name = "gemini-1.5-flash" # Speed
elif role_type == "auditor":
instruction = "You are a QA Engineer. Find bugs in Python code."
model_name = "gemini-1.5-pro" # Precision
return genai.GenerativeModel(
model_name=model_name,
system_instruction=instruction
)
# Use Case:
supervisor = create_specialized_agent("supervisor")
coder = create_specialized_agent("coder")
auditor = create_specialized_agent("auditor")
7. Role-Based "Tool Gating"
A major security benefit of roles is that you can bind different tools to different agents.
- Worker Agent: Has access to
delete_file. - Supervisor Agent: Has NO access to
delete_file. - Why?: This prevents the Supervisor (who is processing un-vetted user input) from accidentally calling a destructive tool. Only the specialized Worker (who has a narrow, safety-filtered instruction set) can pull the trigger.
8. Summary and Exercises
Roles are the Identity of the team.
- Supervisors manage the plan and the people.
- Workers execute the specific, narrow tasks.
- Evaluators ensure the quality and safety of the output.
- Hierarchical loops enable self-correction before the user sees the output.
Exercises
- Drafting Job Descriptions: Write a System Instruction for an "Evaluator" agent whose only job is to check for "Tone and Brand Consistency." What should it look for?
- Architecture Mapping: You are building a "Creative Newsletter" agent. Map out which roles you would need and how they would talk to each other.
- Security Review: Why should an agent with access to the "Company Credit Card" tool NEVER be the same agent that interacts directly with the user? Which "Role" would sit between them?
In the next lesson, we will look at Coordination Strategies, exploring how these different roles communicate and pass data between each other.