Guided project ยท Building with AI
Build a multi-agent AI team: planner, writer and reviewer
Code a small team of AI agents that plan, research, write and review a report together, with a quality loop and a human sign-off.
What you'll build
A Python multi-agent pipeline: a planner splits the job, a researcher answers each question, a writer drafts the report, a reviewer scores it and sends it back until it passes, and you approve the final version.
What you'll learn
- Calling an AI model from code with an API key kept secret
- Agent roles with system instructions
- Orchestration: sequential steps plus an evaluator-optimizer loop
- Structured JSON output between agents
- Limits, cost tracking and human approval
You'll need
Google Colab (free) and a free Gemini API key from Google AI Studio
Create a free account to unlock this project
The step-by-step instructions, copy-ready prompts, progress tracker and portfolio texts are for members. It's free, takes under a minute, and unlocks all guided projects.
Want to try first? These projects are open to everyone: Prompt lab and One idea, five posts.
Before you start
- Be comfortable running copy-paste code cells (try the house-price project first if you're new to Colab).
- Pick a topic for the report, e.g. How small shops can use AI safely.
Use any free AI chatbot (ChatGPT, Claude, Gemini or Copilot). Never paste private or confidential information.
Step by step
Get a free API key
Go to aistudio.google.com, sign in with a Google account and click Get API key โ Create API key. Treat it like a password: never paste it into a chat, a document or your code.
You should see: A long key starting with letters and numbers. Keep the tab open.
Why it matters: API keys let your code use an AI model. Anyone with your key can use your quota, so it stays secret.
Store the key safely in Colab
Open a new notebook at colab.research.google.com. Click the ๐ key icon on the left (Secrets), click Add new secret, name it GEMINI_API_KEY, paste the key as the value and switch on Notebook access.
You should see: A secret called GEMINI_API_KEY with notebook access turned on.
Connect to the model
Run this cell. It installs Google's library, loads your key from Secrets and asks the model to say hello.
Copy this code!pip install -q google-genai from google import genai from google.colab import userdata import json, re client = genai.Client(api_key=userdata.get('GEMINI_API_KEY')) MODEL = 'gemini-2.5-flash' # if this stops working, use the current Flash model name from AI Studio CALLS = {'n': 0} def ask(system, prompt, temperature=0.4): CALLS['n'] += 1 r = client.models.generate_content(model=MODEL, contents=prompt, config={'system_instruction': system, 'temperature': temperature}) return r.text def ask_json(system, prompt): text = ask(system + '\nReply with valid JSON only, no other text.', prompt, 0.2) m = re.search(r'\{.*\}|\[.*\]', text, re.S) return json.loads(m.group(0)) print(ask('You are friendly and brief.', 'Say hello to a new AI builder in one sentence.'))You should see: A short hello from the model. If you see an error about the model name, open AI Studio, copy the name of the current Flash model and put it in MODEL.
Why it matters: ask() sends a role (system instruction) and a prompt; ask_json() asks for structured output you can use in code.
Write the agents' job descriptions
Each agent is the same model with a different role. Run this cell.
Copy this codePLANNER = 'You are a planning lead. Break a report topic into exactly 3 clear research questions.' RESEARCHER = 'You are a careful researcher. Answer the question in 4-6 factual sentences for beginners. If you are not sure of a fact, say so.' WRITER = 'You are a clear writer. Turn research notes into a 250-word report with a title, 3 short sections and a one-line takeaway. Plain English.' REVIEWER = ('You are a strict editor. Score the report from 1 to 10 for accuracy, clarity and structure. ' 'Return JSON: {"score": number, "problems": [short strings], "pass": true or false}. Pass only if score >= 8.')You should see: No output; four roles are defined.
Why it matters: A role (system instruction) is how you turn one general model into specialists.
Agent 1: the planner
Set your topic and let the planner split it into questions.
Copy this codeTOPIC = 'How small shops can use AI safely' # change this to your own topic plan = ask_json(PLANNER, f'Topic: {TOPIC}. Return JSON: {{"questions": [3 strings]}}') questions = plan['questions'] for i, q in enumerate(questions, 1): print(i, q)You should see: A list of 3 research questions about your topic.
Agent 2: the researcher
The researcher answers each question one by one.
Copy this codenotes = [] for q in questions: a = ask(RESEARCHER, q) notes.append(f'Q: {q}\nA: {a}') print('โ', q) notes_text = '\n\n'.join(notes)You should see: Three short answers. Note: this model answers from its training, not the live web, so facts can be out of date.
Agent 3 and 4: write, review, repeat
The writer drafts; the reviewer scores it. If it fails, the writer fixes the listed problems. A limit of 3 rounds stops endless loops.
Copy this codedraft = ask(WRITER, f'Topic: {TOPIC}\n\nResearch notes:\n{notes_text}') for round_no in range(1, 4): review = ask_json(REVIEWER, f'Report:\n{draft}') print(f'Round {round_no}: score {review["score"]}', 'โ pass' if review['pass'] else 'โ ' + '; '.join(review['problems'])) if review['pass']: break draft = ask(WRITER, f'Improve this report. Fix these problems: {review["problems"]}\n\nReport:\n{draft}') print('\n' + draft)You should see: A score for each round, then the final report. Most reports pass in 1โ2 rounds.
Why it matters: This is the evaluator-optimizer pattern: one agent writes, another checks, with a hard limit on rounds.
Human sign-off
Agents shouldn't publish on their own. Read the report, then type yes to approve or anything else to reject.
Copy this codedecision = input('Approve this report? (yes/no): ') if decision.strip().lower() == 'yes': open('report.md', 'w').write(draft) print('Approved and saved as report.md') else: print('Not approved. Change TOPIC or the roles and run again.')You should see: "Approved and saved" and a file report.md in the Colab file panel, or "Not approved".
Check the cost and the trace
Every call to the model costs time and quota. Count them.
Copy this codeprint('Model calls used:', CALLS['n']) print('Questions:', len(questions), '| Review rounds:', round_no)You should see: Something like 7โ9 model calls for one report.
Why it matters: Real teams track calls, time and cost per task, and set limits before going live.
Brilliant work. Share it below, then pick your next project.
Level up
- Add a fact-checker agent that lists any claim that needs a source.
- Run the three research questions in parallel with concurrent.futures to make it faster.
- Rebuild the same team in a framework such as LangGraph or CrewAI and compare the code.
Lessons behind this project
Show it off
Finished? Post about it on LinkedIn. Here's a starting point; add a screenshot and your own words.
I coded a small multi-agent AI team today: a planner, a researcher, a writer and a strict reviewer that sends drafts back until they pass, plus a human sign-off before anything is saved. Great way to understand orchestration and evaluator loops. Learned with AI From Zero.Add it to your portfolio
Employers love seeing what you've built. Use these ready-made texts, then add your own results and a screenshot.
1. A line for your CV or LinkedIn "Projects" section
Build a multi-agent AI team: planner, writer and reviewer: A Python multi-agent pipeline: a planner splits the job, a researcher answers each question, a writer drafts the report, a reviewer scores it and sends it back until it passes, and you approve the final version. Skills: Calling an AI model from code with an API key kept secret, Agent roles with system instructions, Orchestration, Structured JSON output between agents, Limits, cost tracking and human approval. Tools: Google Colab (free) and a free Gemini API key from Google AI Studio.2. A README for GitHub
Create a free GitHub account, make a new repository, add a file called README.md and paste this in along with your notebook (File โ Download โ .ipynb).
# Build a multi-agent AI team: planner, writer and reviewer
Code a small team of AI agents that plan, research, write and review a report together, with a quality loop and a human sign-off.
## What I built
A Python multi-agent pipeline: a planner splits the job, a researcher answers each question, a writer drafts the report, a reviewer scores it and sends it back until it passes, and you approve the final version.
## What I learned
- Calling an AI model from code with an API key kept secret
- Agent roles with system instructions
- Orchestration: sequential steps plus an evaluator-optimizer loop
- Structured JSON output between agents
- Limits, cost tracking and human approval
## Tools
Google Colab (free) and a free Gemini API key from Google AI Studio
## How it works
1. Get a free API key
2. Store the key safely in Colab
3. Connect to the model
4. Write the agents' job descriptions
5. Agent 1: the planner
6. Agent 2: the researcher
7. Agent 3 and 4: write, review, repeat
8. Human sign-off
9. Check the cost and the trace
## Results
(Add a screenshot and 2โ3 sentences about what you found. Never include API keys or personal data.)
## Next steps
- Add a fact-checker agent that lists any claim that needs a source.
- Run the three research questions in parallel with concurrent.futures to make it faster.
- Rebuild the same team in a framework such as LangGraph or CrewAI and compare the code.
---
Built by following the free guided project at https://learnaifromzero.com/projects/multi-agent-team.html