Goal
Build a system where three specialized agents collaborate on a task:- Researcher — gathers information from the web
- Writer — synthesizes research into a draft document
- Reviewer — reviews the draft and provides feedback
Prerequisites
- An Allternit API key
@allternit/sdkinstalledTAVILY_API_KEYfor web search
Implementation
1. Set up the tool registry
2. Create the agents
3. Orchestrate the workflow
Explanation
- Sequential coordination — The orchestrator runs agents one at a time, passing output from one as input to the next. This is the simplest coordination pattern.
- Feedback loops — The reviewer-writer loop runs until the reviewer approves or the iteration limit is reached. This prevents infinite loops.
- Specialized agents — Each agent has a focused system prompt and limited tool set, reducing the chance of hallucination.
Next steps
- Replace sequential calls with async parallel runs for the research phase (fan out multiple researchers).
- Use the CommRails protocol for persistent inter-agent messaging across sessions.
- Add a budget limit per agent run to control costs.