The key to a successful multi-agent system lies in clearly defining agent roles. Each agent needs a precise task, a defined input/output contract, and a specialized prompt. Poorly defined roles lead to overlaps, conflicts, and inconsistent results.
The researcher collects and structures information. It serves as the system's knowledge base.
System prompt (example):
You are a research specialist. Your task:
- Collect relevant information on the given topic
- Structure results into clear sections
- Rate the reliability of each source (1-5)
- Explicitly flag uncertainties
Output format: JSON with { "findings": [], "confidence": 0-100, "gaps": [] }
The writer creates content based on the researcher's findings.
System prompt (example):
You are a content writer. Your task:
- Create well-structured texts based on research data
- Keep the tone professional and accessible
- Use subheadings and bullet points
- Maximum length: 800 words
Input: Research results (JSON)
Output: Formatted text (Markdown)
The reviewer checks quality and provides feedback.
System prompt (example):
You are a quality reviewer. Your task:
- Check factual accuracy against research data
- Evaluate style, structure, and completeness
- Provide concrete, actionable feedback
- Decide: APPROVE, REVISE (with notes), or REJECT
Output format: JSON with { "decision": "", "score": 0-100, "feedback": [] }
Effective agent prompts follow the RACE Framework:
| Element | Description | Example |
|---|---|---|
| Role | Who is the agent? | "You are a financial analyst" |
| Action | What should it do? | "Analyze the quarterly figures" |
| Context | What constraints apply? | "For a Fortune 500 company, in English" |
| Expectation | What does the result look like? | "JSON with metrics and assessment" |
Beyond the three core roles, you can deploy specialized agents:
| Agent | Task | Trigger |
|---|---|---|
| Validator | Schema and format checking | After each agent output |
| Translator | Multilingual output | After the writer |
| Summarizer | Summarize lengthy results | Before the end user |
| Router | Decides which agent acts next | Dynamic pipelines |
| Guardrail | Checks for compliance and safety | Before output |
Define a clear contract for each agent:
{
"agent": "researcher",
"input_schema": {
"topic": "string (required)",
"depth": "shallow | medium | deep",
"max_sources": "number (default: 5)"
},
"output_schema": {
"findings": "array of { title, content, source, confidence }",
"overall_confidence": "number 0-100",
"knowledge_gaps": "array of string"
},
"constraints": {
"max_tokens": 2000,
"timeout_seconds": 30
}
}
Practical tip: Start with three agents (researcher, writer, reviewer) and expand incrementally. Each new agent increases complexity exponentially. Document input/output contracts in a shared schema — this saves debugging time and makes agents interchangeable.