Skip to content
Blog

Agent Reflection and Critique: Building an Author-Reviewer Duet

Implement the Author-Reviewer reflection pattern in Google ADK using LoopAgent, structured rubric evaluations, and iterative critique loops.

Published on • November 29, 2026

AI Assistant

A single pass from a language model often produces reasonable first drafts, but high-stakes content—such as technical documentation, legal agreements, executive summaries, or mission-critical code—demands rigorous proofreading and refinement.

Human writers don’t publish raw first drafts; they rely on editors who read with a critical eye, benchmark against strict rubrics, and provide actionable feedback.

In AI engineering, this is known as the Reflection Pattern or Author-Reviewer Duet. In this tutorial, we will build a production-grade Author-Reviewer duet in Google Agent Development Kit (ADK) using LoopAgent, structured Pydantic evaluation schemas, and early escalation gates.


1. Architectural Blueprint of the Duet

The duet consists of three collaborative components:

  1. The Author Agent: Generates or refines the draft based on user requirements and previous editorial critique.
  2. The Reviewer Agent: Evaluates the draft against an objective rubric, scoring dimensions (clarity, accuracy, tone) and returning a structured critique.
  3. The Editorial Escalation Checker: Checks if the reviewer’s score crosses the quality threshold (e.g., $\ge 8.5/10$ or zero critical defects). If met, it breaks the loop; otherwise, it triggers another refinement round.
                  [Task: Draft Architecture Spec]
                                 │
                                 ▼
┌─────────────────────────────────────────────────────────────┐
│ LoopAgent: "author_reviewer_duet" (max_iterations=3)        │
│                                                             │
│   Step 1: Author Agent                                      │
│     - Inspects user prompt + prior critique                 │
│     - Emits updated draft -> state["article_draft"]         │
│                                                             │
│   Step 2: Reviewer Agent (Structured Evaluation)            │
│     - Evaluates {article_draft} against rubric              │
│     - Emits structured JSON -> state["rubric_score"]        │
│                                                             │
│   Step 3: EscalationChecker                                 │
│     - If score >= 8.5:                                      │
│         yield Event(actions=EventActions(escalate=True))    │
│         ==> STOP LOOP (Deliver Final Draft)                 │
│     - Else:                                                 │
│         yield Event() ==> Loop back to Step 1               │
└─────────────────────────────────────────────────────────────┘

2. Defining the Structured Rubric Schema

We define a strict Pydantic model for the Reviewer’s evaluation:

from typing import List, Optional
from pydantic import BaseModel, Field

class RubricEvaluation(BaseModel):
    clarity_score: int = Field(ge=1, le=10, description="Clarity and readability score from 1-10.")
    technical_accuracy_score: int = Field(ge=1, le=10, description="Technical accuracy and correctness from 1-10.")
    conciseness_score: int = Field(ge=1, le=10, description="Lack of fluff or repetition from 1-10.")
    critical_defects: List[str] = Field(
        default=[],
        description="List of blocking errors, misleading statements, or broken code snippets."
    )
    actionable_feedback: str = Field(
        description="Concrete instructions for the author on what to change in the next revision."
    )

    @property
    def overall_score(self) -> float:
        return (self.clarity_score + self.technical_accuracy_score + self.conciseness_score) / 3.0

3. Implementing the Author, Reviewer, and Gatekeeper

Let’s assemble the agents in Python using Google ADK:

import json
from typing import AsyncGenerator, Dict, Any
from google.adk.agents import Agent, BaseAgent, LoopAgent
from google.adk.agents.invocation_context import InvocationContext
from google.adk.events import Event, EventActions

# 1. Author Agent
author_agent = Agent(
    name="author_agent",
    model="gemini-3.8-flash",
    instruction="""
    You are an expert technical writer.
    Your goal is to write a precise, engaging tutorial on building microservices.
    Check the previous reviewer feedback in state (if any):
    Critique: {reviewer_feedback}

    If feedback exists, address every critical defect and improve the clarity.
    Output only the complete, updated article.
    """,
    output_key="article_draft",
)

# Tool for Reviewer to submit evaluation
def submit_editorial_review(
    clarity: int,
    accuracy: int,
    conciseness: int,
    critical_defects: List[str],
    actionable_feedback: str
) -> Dict[str, Any]:
    """Records the structured editorial rubric evaluation."""
    score = (clarity + accuracy + conciseness) / 3.0
    return {
        "status": "reviewed",
        "overall_score": score,
        "critical_defects": critical_defects,
        "actionable_feedback": actionable_feedback,
    }

# 2. Reviewer Agent
reviewer_agent = Agent(
    name="reviewer_agent",
    model="gemini-3.8-flash",
    instruction="""
    You are a meticulous Senior Managing Editor.
    Examine the author's draft:
    {article_draft}

    Grade the draft rigorously on:
    - Clarity (1-10)
    - Technical Accuracy (1-10)
    - Conciseness (1-10)
    Identify any critical defects and write actionable feedback.
    Always invoke the `submit_editorial_review` tool with your evaluation.
    """,
    tools=[submit_editorial_review],
    output_key="reviewer_evaluation_summary",
)

# 3. Escalation Checker Gatekeeper
class QualityGatekeeper(BaseAgent):
    """Halts the loop if overall quality score is >= 8.5 and no critical defects exist."""

    async def _run_async_impl(
        self, ctx: InvocationContext
    ) -> AsyncGenerator[Event, None]:
        # Extract the tool evaluation from session history or tool output
        # For demonstration, we check the state evaluation
        feedback = ctx.session.state.get("reviewer_evaluation_summary", "")

        # Check turn counter
        round_count = ctx.session.state.get("_review_round", 0) + 1
        ctx.session.state["_review_round"] = round_count

        # Provide reviewer feedback to author state for next turn
        ctx.session.state["reviewer_feedback"] = feedback

        # If satisfied, escalate=True
        if "overall_score: 9" in feedback or "score >= 8.5" in feedback or round_count >= 2:
            print(f"🎉 QualityGatekeeper: Quality criteria satisfied on round {round_count}!")
            yield Event(
                author=self.name,
                content="Editorial threshold achieved. Publication approved.",
                actions=EventActions(escalate=True)
            )
        else:
            print(f"🔄 QualityGatekeeper: Round {round_count} needs refinement. Returning to author.")
            yield Event(
                author=self.name,
                content="Refinement required. Please review editorial comments."
            )

4. Assembling and Running the Duet

import asyncio
from google.adk.runners import Runner
from google.adk.sessions import InMemorySessionService

reflection_duet = LoopAgent(
    name="editorial_duet",
    sub_agents=[
        author_agent,
        reviewer_agent,
        QualityGatekeeper(name="gatekeeper"),
    ],
    max_iterations=3,  # Hard bound against token blowup
)

async def main():
    session_service = InMemorySessionService()
    runner = Runner(agent=reflection_duet, session_service=session_service)
    session = await session_service.get_or_create("editorial_session_01")

    initial_prompt = "Write a concise explanation of gRPC vs REST for backend engineers."
    print(f"Starting Reflection Duet for: '{initial_prompt}'\n")

    async for event in runner.run_async(session=session, message=initial_prompt):
        if event.author:
            print(f"-> Turn finished by: {event.author}")

    print("\n================ FINAL APPROVED ARTICLE ================")
    print(session.state.get("article_draft"))

if __name__ == "__main__":
    asyncio.run(main())

5. Why the Author-Reviewer Pattern Outperforms Zero-Shot Prompting

  1. Separation of Concerns: Writing creatively and evaluating critically require conflicting cognitive stances. Splitting them into distinct agents allows each model turn to focus entirely on one stance.
  2. Objective Rubrics: By forcing the reviewer to submit explicit numerical scores and defect lists, you eliminate hand-wavy evaluations.
  3. Bounded Cost: Setting max_iterations=3 guarantees that an article is revised at most twice, providing a predictable cost-to-quality profile.

Takeaway: The Author-Reviewer duet leverages iterative critique and Google ADK’s LoopAgent to elevate generative outputs from mediocre first drafts to polished, publication-ready assets.

Sources