You dont need CrewAI or AutoGen. Heres how to build a multi-agent pipeline in pure Python.
The Concept
5 AI agents collaborate in a pipeline:
Researcher → Writer → Editor → Reviewer → Publisher
Each agent has a role, a system prompt, and passes output to the next.
Implementation
class Agent:
def __init__(self, name, role, system_prompt):
self.name = name
self.role = role
self.system_prompt = system_prompt
def process(self, input_text):
"""Call LLM with system prompt + input"""
import requests
response = requests.post(
"http://localhost:11434/api/generate",
json={
"model": "llama3.2",
"prompt": f"{self.system_prompt}\n\nInput: {input_text}",
"stream": False
}
)
return response.json()["response"]
class Pipeline:
def __init__(self, agents):
self.agents = agents
def run(self, topic):
output = topic
for agent in self.agents:
print(f"🤖 {agent.name} working...")
output = agent.process(output)
print(f" ✅ Done ({len(output)} chars)")
return output
# Define agents
agents = [
Agent("Researcher", "research",
"Find 5 key facts about the topic. Be concise."),
Agent("Writer", "write",
"Write a 500-word article from the research."),
Agent("Editor", "edit",
"Improve clarity, fix grammar, make it engaging."),
Agent("Reviewer", "review",
"Score 1-10. List what works and what needs fixing."),
Agent("Publisher", "publish",
"Format as markdown with title, headings, and CTA."),
]
# Run
pipeline = Pipeline(agents)
result = pipeline.run("The Future of Local AI")
print(result)
Why No Framework?
- Simpler: 50 lines vs 500 lines with CrewAI
- Debuggable: You can see exactly whats happening
- Flexible: Add/remove agents easily
-
No dependencies: Just
requestslibrary - Works with any LLM: Ollama, OpenAI, Groq, anything
Pro Tips
- Different models per agent: Use codellama for code review, llama3.2 for writing
- Temperature: Lower for Researcher (factual), higher for Writer (creative)
- Fallback: If one model fails, try another
- Logging: Save each agents output for debugging
Use Cases
- Blog post pipeline
- Video script generation
- Social media content
- Research reports
- Code review chains
🔗 Full implementation: github.com/amrendramishra/ai-tools
🌐 amrendranmishra.dev
Building AI tools daily. Follow for more.
Top comments (0)