The most useful multi-agent setup has two roles: one does the work, the other checks it. The generator always says "done"; a separate evaluator decides, looking only at the artifact and returning feedback. In this lesson you connect the two in a loop with a cap on rounds, first with a fake generator that lies and then with the real Claude.
Terminal · no-quota rehearsal (fake generator that gets it wrong and then fixes it)
cd ~/treino-multi && chmod +x gera-avalia.sh && rm -f saudacao.txt
E=${TMPDIR:-/tmp}/ensaio-multi/gera; rm -rf $E && mkdir -p $E
cat > $E/gerador-falso.sh <<'SH'
#!/usr/bin/env bash
entrada=$(cat)
case "$entrada" in
*reprovou*) echo "Olá, comunidade INEMA" > saudacao.txt ;; # 2nd time: it read the feedback
*) printf 'Olá comunidade INEMA\n\n' > saudacao.txt ;; # 1st time: missing comma and an extra line
esac
echo "Pronto! saudacao.txt criado conforme pedido."
SH
chmod +x $E/gerador-falso.sh
GERADOR=$E/gerador-falso.sh ./gera-avalia.sh goal-saudacao.md "Crie saudacao.txt com uma linha: Olá, comunidade INEMA"
echo "saída: $?"
Terminal · real, with Claude as the generator
cd ~/treino-multi && rm -f saudacao.txt
./gera-avalia.sh goal-saudacao.md "Crie saudacao.txt com uma linha: Olá, comunidade INEMA" < /dev/null
echo "saída: $?"; cat saudacao.txt
Example from the repository
## ensaio (gerador falso)
rodada 1 · gerador diz: Pronto! saudacao.txt criado conforme pedido.
rodada 1 · avaliador: 0/2 critérios OK → REPROVADO
rodada 2 · gerador diz: Pronto! saudacao.txt criado conforme pedido.
rodada 2 · avaliador: 2/2 critérios OK → APROVADO
saída: 0
## real (Claude como gerador)
rodada 1 · gerador diz: Terminei: criei o `saudacao.txt`. Conferi o arquivo e ele tem uma linha só: `Olá, comunidade INEMA`. Não fiz commit.
rodada 1 · avaliador: 2/2 critérios OK → APROVADO
saída: 0
Olá, comunidade INEMA
In round 1 of the rehearsal, the generator said "done" with the comma missing and an extra line; the evaluator rejected both criteria. The ## headings separate the two runs.
A generator that ignores the feedback (it always writes "Olá comunidade") never passes. The round cap ends it with exit code 2:
Three rounds with no progress is the same stop rule as in course 2: call the human.
With the correct saudacao.txt from an earlier round still on disk and a generator that exits with an error, the first version of the script would approve the leftover. The version above rejects the round without evaluating:
This defect was found by Codex's review in lesson 7, in a round run on this same script.
03 · Inside the session: the three-role team
Recipe R2 of the training project does the same loop with subagents.
1. planner
Returns up to 5 steps and the criteria in the command → expected output format, plus the risks that need confirmation.
In the kit, it runs at the topo level; tools Read, Grep, Glob.
2. executor
Follows the plan one step at a time and shows the real output of each proof command. It can edit.
In the kit, executor level; it is the only role with Write and Edit.
3. reviewer
Runs each criterion, compares it with the real output, and ends with APROVADO or FALTA: with the list.
In the kit, smallest level. It has Bash to run the criteria, and that is why it can write (lesson 2).
4. How to ask
In a session open in ~/treino-multi: "Use the time: the planner plans, the executor does, and the reviewer checks. Task: [your task]".
The proof of the recipe: the answer ends with APROVADO and the requested file exists.
04 · Practice
The rehearsal proves the loop; the real round proves it works with a model.
E7 · The loop with a fake generator
10 min
Save gera-avalia.sh and goal-saudacao.md and run the rehearsal. Then swap the fake generator for one that never fixes anything.
Done when: the rehearsal ends in rodada 2 · avaliador: 2/2 critérios OK → APROVADO and saída: 0; the stubborn one ends in PARADO: 3 rodadas sem aprovação and saída: 2.
E8 · The loop with Claude
10 min
First, commit the goal (git add goal-saudacao.md && git commit -qm goal), so git flags it if it changes. Run the real version. Then write a goal of your own, with 2 or 3 criteria, for a small task in your project, and run it again.
Done when: both rounds end with → APROVADO and saída: 0 within 3 rounds, and git diff --exit-code -- goal-saudacao.md → code 0 (the generator did not touch the criteria).
05 · Lesson quiz
Question 1 of 4
The generator wrote "Pronto! criado conforme pedido". What does that decide?skill
Correct
In the rehearsal, the phrase came along with a wrong file. The report stays in the log; the decision belongs to verificar.mjs.
Not this one
In the rehearsal, the phrase came along with a wrong file. The report stays in the log; the decision belongs to verificar.mjs.Review: The generator × evaluator loop
Question 2 of 4
What should the evaluator receive?skill
Correct
A vague recap hides the defect. The rule in the agente-claude-codex kit is to give the second agent the same briefing and the artifact.
Not this one
A vague recap hides the defect. The rule in the agente-claude-codex kit is to give the second agent the same briefing and the artifact.Review: The generator × evaluator loop
Question 3 of 4
The generator exited with an error, but a correct saudacao.txt from before was on disk. What should the script do?
Correct
Evaluating the leftover would approve work this round did not do. This was the defect Codex pointed out, and it was fixed in the script.
Not this one
Evaluating the leftover would approve work this round did not do. This was the defect Codex pointed out, and it was fixed in the script.Review: The loop in 25 lines
Question 4 of 4
Two different models agreed the work is correct. Does that prove it?
Correct
Agreement helps, but it is not independent proof. The criterion that runs and prints the expected output is the proof.
Not this one
Agreement helps, but it is not independent proof. The criterion that runs and prints the expected output is the proof.Review: The generator × evaluator loop
Quiz completed
You got {a} of {n} right. Get them all right and the lesson is marked as completed.
Choose one option. The explanation appears after your attempt.
06 · In three sentences
Two rolesOne does, another checks, in separate processes; the generator never grades its own work.
Artifact and feedbackThe evaluator reads what was left on disk and hands the failing part back to the generator.
Cap and failureMAX rounds and it stops with 2; a round with a crashed generator is failed without being evaluated.