Agent Roles and Specialisations
Give each agent a narrow role (planner, coder, critic, executor) and they perform better than a generalist.
Agent Roles and Specialisations is a free AI Agents lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the AI Agents learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Why Specialisation Helps
A focused agent with a tight prompt and a small tool set beats a generalist with everything. Reasons:
- Prompts can be longer/more specific per role
- Tool descriptions cleaner (fewer options to confuse model)
- Easier to debug and evaluate
- Each agent can use a different model size
Common Roles
- Planner — breaks tasks into steps
- Researcher — gathers information
- Coder — writes code
- Reviewer / Critic — finds flaws
- Editor — polishes output
- Executor — runs commands / tools
Define a Role Clearly
RESEARCHER_PROMPT = '''
You are Researcher. Your job is to gather facts.
Never write code. Never make final decisions.
Return 3-5 sourced findings with URLs.
When finished, end your message with: HANDOFF: planner
'''
print(RESEARCHER_PROMPT.strip())
Per-Role Tools
Strict tool allowlist per role:
researcher_tools = ['web_search', 'fetch_url']
coder_tools = ['read_file', 'write_file', 'run_python']
reviewer_tools = [] # critique-only, no tools
print("Researcher tools:", researcher_tools)
print("Coder tools:", coder_tools)
print("Reviewer tools:", reviewer_tools)
Per-Role Models
Use cheap models for simple roles, big models for hard ones:
ROLE_MODELS = {
'planner': 'gpt-4o', # critical role
'researcher': 'gpt-4o-mini', # routine
'coder': 'gpt-4o', # hard
'reviewer': 'claude-sonnet-4-5' # second opinion
}
for role, model in ROLE_MODELS.items():
print(f"{role}: {model}")
Cross-Model Critique
For higher quality, use a different model family for critique. Reduces shared-bias errors:
- Coder: GPT-4
- Reviewer: Claude
- If both agree, ship; else, escalate
Hand-Off Protocol
Agents need a clear way to pass work. A simple convention:
# Each message ends with one of:
HANDOFF: <role_name>
FINAL: <answer>
ABORT: <reason>Specialisation by Task Type
Some teams add domain experts:
- Legal-Reviewer for compliance
- Security-Reviewer for code safety
- Domain-Specialist for industry knowledge
Role Caps
Caps per role prevent runaway:
MAX_ROLE_INVOCATIONS = {
'planner': 3,
'researcher': 5,
'coder': 10,
'reviewer': 3
}
for role, cap in MAX_ROLE_INVOCATIONS.items():
print(f"{role}: max {cap} invocations")
Don't Over-Specialise
Going from 3 roles to 30 hurts: supervisor selection becomes unreliable, latency balloons, and most "specialists" duplicate work.
Add roles only when you measure a real benefit.
Eval Per Role
Test each role independently:
- Researcher eval: does it return sourced facts?
- Coder eval: does the code compile and pass tests?
- Reviewer eval: does it catch known bugs?
Composability
Roles can be reused across multiple agent systems. A well-tuned Researcher works for both a doc-writer and a fact-checker workflow.
Why Roles?
Main benefit of giving each agent a clear role?
Recap
Plan -> Research -> Code -> Review is a great default pipeline. Tight prompts, narrow tools, per-role models, hand-off protocol. Add roles only when measured benefit exists.
Frequently asked questions
Is the “Agent Roles and Specialisations” lesson free?
Yes — the full text of “Agent Roles and Specialisations” is free to read here on the web, and the AI Agents course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the AI Agents course, upgrade to CoddyKit PRO.
What will I learn in “Agent Roles and Specialisations”?
Give each agent a narrow role (planner, coder, critic, executor) and they perform better than a generalist. You practise AI Agents with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start AI Agents?
No prior experience is required. AI Agents on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Agent Roles and Specialisations” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this AI Agents lesson?
Yes. Every AI Agents lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.