Four different approaches to breaking down tasks into subtasks using AI agents.
- Create conda environment:
conda create -n testing python=3.12 -y
conda activate testing
- Install dependencies:
pip install uv
uv pip install openai
uv pip install python-dotenv
- Create
.env
file:
OPENROUTER_API_KEY=your_api_key_here
01-unreliable.py - Parallel sub-agents. No shared context.
02-still-unreliable.py - Parallel sub-agents. Shared conversation log.
03-simple-and-reliable.py - Sequential sub-agents. Full shared context.
04-reliable-on-longer-tasks.py - Sequential sub-agents. Context compression between steps.
Run any file:
python 01-unreliable.py
Enter your task when prompted. The agent will break it into two subtasks and execute them.
All files use OpenRouter API with GPT-4o model. You need an OpenRouter API key to run these examples.
These resources provide deeper insights into effective agent architectures:
-
Don't Build Multi-Agents - Cognition AI
Core principles of context engineering and why parallel agents often fail -
Building Effective Agents - Anthropic
Best practices for building reliable agentic systems -
A Practical Guide to Building Agents - OpenAI
Comprehensive guide with real-world implementation strategies