Worker Agents
Worker agents are the doers of the multi-agent system. Each handles a specific type of task and reports results back to the coordinator.
6 min•By Priygop Team•Updated 2026
Worker Agent Design Principles
- Single responsibility: each worker does one type of task well
- Clear inputs and outputs: the worker receives a structured task and returns a structured result
- No side effects: workers should not take actions outside their defined scope
- Self-contained: workers should not call other workers directly — route through the coordinator
- Fail gracefully: if a worker cannot complete its task, it returns a structured error rather than crashing
Worker Agent Template
Worker Agent Template
# Reusable worker agent template
class WorkerAgent:
def __init__(self, name: str, tools: dict, system_prompt: str):
self.name = name
self.tools = tools
self.system_prompt = system_prompt
def run(self, instruction: str, context: dict = None) -> dict:
"""
Execute a task. Returns a structured result.
In a real implementation, this calls the language model with
the system_prompt and available tools.
"""
context = context or {}
print(f" [{self.name}] Running: {instruction[:50]}...")
# Simulate tool use and result generation
# In production: call LLM with system_prompt + instruction + context
result = {
"agent": self.name,
"instruction": instruction,
"status": "success",
"output": f"Completed: {instruction}",
"tools_used": list(self.tools.keys()),
"confidence": 0.9
}
return result
# Create specialised worker agents
research_worker = WorkerAgent(
name="ResearchAgent",
tools={"web_search": ..., "extract_data": ..., "summarise": ...},
system_prompt="You are a focused research agent..."
)
analysis_worker = WorkerAgent(
name="AnalysisAgent",
tools={"calculate": ..., "compare": ..., "chart": ...},
system_prompt="You are a data analysis agent..."
)
writing_worker = WorkerAgent(
name="WritingAgent",
tools={"format_markdown": ..., "spellcheck": ...},
system_prompt="You are a professional writing agent..."
)
result = research_worker.run("Find top 5 Python AI frameworks")
print(f"Result: {result['status']}, Tools: {result['tools_used']}")Key Takeaways
- Worker agents are the doers of the multi-agent system.
- Single responsibility: each worker does one type of task well
- Clear inputs and outputs: the worker receives a structured task and returns a structured result
- No side effects: workers should not take actions outside their defined scope