QA Interview Hub · Knowledge base · Quizzes · Українська

Product Engineering › Orchestrating agents

Orchestration patterns: executor and reviewer, fan-out

In the executor and reviewer pattern the benefit is a separate context: the reviewer sees the task and the diff but not the author's reasoning. So it does not repeat the author's assumptions. It returns findings with a location and a reason, in two or three rounds, and a human settles disputes. Fan-out suits uniform independent parts with one result format; a sequential pipeline is safer for dependent steps.

Agentic development · Orchestration

An agent wrote the code and reviewed it itself: "all good". Why is that not a review?

An agent implemented a request rate limit, then in the same conversation was asked to "check yourself". It answered that everything was correct and offered arguments for its own decisions. It did not see the missing handling of an empty key: in its context that key was "obviously non-empty". The brief, parallelism and isolation are covered in the previous article of the section. Here are the two most common patterns and when each is justified.

How it works and why. An agent that wrote the code tends to explain its own decisions and sees in the code what it intended, not what came out. A fresh context looks at the result the way a human would: without the history of reasoning. So the "executor and reviewer" pattern gives a benefit not from model strength but from the separate context. The same with parallelism: it is justified when the parts are independent and harmful when they are not.

Executor and reviewer

Executorwrites the change for the taskReviewer: fresh contexttask + diff, no reasoningFindingsplace in the code and the reasonExecutor fixesno more than two or three roundsHumandecides when agents disagree
Figure 1. The reviewer does not see the executor's report and reasoning: otherwise it inherits its wrong assumptions.

Executor and reviewer: how to set it up.

  • the reviewer gets the task, the done criteria and the diff, but not the executor's report or reasoning;
  • the reviewer's instruction lists what to look for (logic errors, missed boundary cases, leaving the task limits, weakened tests) and requires findings with a place in the code and a reason, not a general rating;
  • the number of rounds is limited to two or three: without a limit the reviewer finds trifles, the executor fixes them and the loop never ends;
  • when agents disagree, a human decides. A reviewer agent reduces the load but does not remove responsibility.

The reviewer may also be a stronger model, but the main benefit is the separate context, not the model's strength.

Example: what the reviewer saw that the author did not. An instruction to the reviewer (shortened):

Task (unchanged): limit of 100 requests per minute per key.
Data: the diff in review.diff.
Look for: logic, boundary values (0, 100, 101, an empty
key), leaving the task limits, weak tests.
Format: a list "file:line, problem, why". No general
rating. Fix nothing.

The reviewer returned: "limiter.ts:14, an empty key is counted as one shared counter for everybody, why: the key is taken from a header that may be absent". The executor did not see it because it knew the header is always present. The disputed question "should a request without a key be rejected" is decided by a human, because it is a requirement, not a bug.

Fan-out / fan-in. The main session splits the work into several independent parts, launches a subagent for each (fan-out) and collects the results (fan-in). It suits uniform tasks: porting twenty test files to a new API, checking several modules for the same problem, testing several hypotheses about a failure at once.

  • the parts are truly independent, otherwise agents get in each other's way;
  • each gets its own complete brief and the same result format so that collecting answers is simple;
  • it is decided beforehand who collects and verifies the result: that is the main session's job, not a separate agent "on trust";
  • the cost grows in proportion to the number of agents, so the number of parts is not made larger than the benefit.

A sequential pipeline. When a step depends on the previous one (plan → implementation → check), agents are launched one after another and pass on only what is needed. It is often more reliable than parallelism.

In parallel or in turn

Fan-out

Independent uniform parts

20 files to a new API, several modules for the same problem. Faster by the clock, costlier in tokens.

Pipeline

Dependent steps

Plan, implementation, check: each step needs the result of the previous. Simpler and more reliable.

Figure 2. Both are legitimate: the choice depends on whether the parts depend on each other.

Limits and alternatives. A small change, tightly coupled edits, a task where the brief is longer than the work: several agents here add brief and merge costs with no gain. Start with one and complicate only when it gives a tangible benefit. A reviewer agent does not find what is not visible from the diff and the task (requirements, agreements, decision history), so it complements human review, not replaces it.

Common mistakes.

  • Giving the reviewer the executor's report and reasoning: it repeats the same assumptions and the benefit disappears.
  • Not limiting the number of rounds: endless minor fixes.
  • Fan-out for dependent parts: agents conflict and the result has to be untangled.
  • Handing the collection of the result to another agent "on trust": nobody verifies the outcome.

Check yourself

Why should the reviewer not have the executor's report and how does that differ from just "one more agent"?

Answer

The report holds the executor's reasoning and assumptions: after reading them the reviewer looks at the code with the same eyes and repeats the omissions. The benefit of a separate context exists only when the reviewer sees the task and the result, not the path to it.

You need to port 20 independent test files to a new API. When is fan-out justified and what must be decided beforehand?

Answer

The files are independent and the task is uniform, so yes. Decide beforehand the result format and who collects and verifies the outcome (the main session), plus how many agents to launch, because cost grows with their number.

In an interview. Junior: The executor writes the code and a reviewer with a clean context looks for problems. I use fan-out for uniform independent parts and do dependent steps in turn. Middle/Senior: The reviewer's value is the separate context: it sees the task and the diff, without the author's reasoning, and returns findings with a place and a reason. A limit of two or three rounds, and disputes are decided by a human. Fan-out always with one result format and collection in the main session, because cost grows with the number of agents. For dependent steps a pipeline is more reliable.

More articles in this chapter