Authored by Dr. Tiziana Ligorio for AI Agents - CSCI 395.32 taught at Hunter College of The City University of New York¶
In this demo, we build a simple AI workflow that demonstrates a single round of reflection. One model call produces a draft, a second critiques it, and a third revises it.

Our workflow consists of three steps, each handled by an LLM with a distinct role:
Report Writer (think journalist): Generates an initial report based on a user-provided topic
Critic (think editor): Provides detailed critique and improvement suggestions
Reviser (think senior reporter): Takes the original report and critique to produce a final version
The purpose is to see how outputs from multiple LLM calls can be connected. A reflection workflow is more elaborate than a single call, but it is not automatically better. We will inspect the draft, critique, and revision to decide what changed and whether the change helped.
We use the OpenAI SDK directly, with OpenRouter as our provider, to keep the implementation transparent: no orchestration framework, just API calls that can be followed step by step.
Installs and Imports¶
%%capture
%pip install -q "openai>=2.0.0" "python-dotenv>=1.0.0"
%%capture hides installation output to keep the notebook readable. %pip installs packages into the Python environment used by the current notebook kernel.
# OpenAI SDK: provides a clean interface for calling LLMs
# We'll use it with OpenRouter, which is OpenAI API-compatible
from openai import OpenAI
# Standard library
import osOpenRouter provides access to models from multiple providers through one API. Model availability, pricing, and free-model options can change, so check the current OpenRouter model list before choosing a model.
This notebook follows OpenRouter’s documented integration with the OpenAI SDK. Other services may also describe themselves as OpenAI-compatible, but their supported endpoints and parameters can differ.
Setup your API Key¶
Step 1: Get an OpenRouter API key¶
For this demo we will use an LLM via OpenRouter, which requires an API key.
Go to https://
openrouter .ai Sign in (or create an account if you don’t have one)
Once logged in, navigate to https://
openrouter .ai /settings /keys Click Create Key
Give the key a name, e.g.
colab-reflection-workflowCopy the key immediately (you won’t be able to see it again)
Important: Treat this key like a password. Do not share it, paste it into notebooks, or commit it to GitHub.
Step 2: Store the API key¶
If running in Google Colab:¶
On the left sidebar, click 🔑 Secrets
Add a new secret:
Name:
OPENROUTER_API_KEYValue: your actual API key
Toggle the switch to give notebook access (you should see a checkmark)
If running locally:¶
Create a
.envfile in the project root:touch .envAdd the following (replace with your own key):
OPENROUTER_API_KEY=your_openrouter_key_here
Important: Never paste API keys directly into code cells.
Load the API Key¶
In Colab:¶
Uncomment and run the cell below if you’re using Google Colab.
# # Uncomment the lines below if running in Google Colab
# from google.colab import userdata
# os.environ["OPENROUTER_API_KEY"] = userdata.get("OPENROUTER_API_KEY")
# print("API key loaded from Colab Secrets")Locally:¶
Run the cell below if you’re running locally with a .env file.
# Load a local .env file when one is present.
# This does not replace a key already loaded from Colab Secrets.
from dotenv import load_dotenv
env_file_found = load_dotenv(dotenv_path=".env")
print("Local .env file found:", env_file_found)
Local .env file found: True
# Sanity check: verify that a non-empty API key is available.
api_key = os.getenv("OPENROUTER_API_KEY")
assert api_key, "OPENROUTER_API_KEY not found. Please check your setup."
print("OPENROUTER_API_KEY present:", bool(api_key))
OPENROUTER_API_KEY present: True
Initialize the LLM Client¶
We use the OpenAI SDK to communicate with OpenRouter. OpenRouter documents this SDK integration and provides an OpenAI-compatible Chat Completions endpoint.
This demo uses gpt-5.6-luna, a current OpenAI model that is cost-sensitive. It is not a source of verified facts: generated factual claims should still be checked, especially for changing topics.
Models do not all support the same request settings. OpenRouter’s current model information lists reasoning_effort for this model but does not list temperature, so this notebook does not send a temperature setting. If you choose another model, check its supported parameters in the OpenRouter model list.
# Initialize the OpenAI client pointing to OpenRouter.
client = OpenAI(
base_url="https://openrouter.ai/api/v1",
api_key=api_key,
)
# Use one model and one reasoning setting for all three roles.
MODEL = "openai/gpt-5.6-luna"
REASONING_EFFORT = "none"
print(f"Client initialized. Using model: {MODEL}")
print(f"Reasoning effort: {REASONING_EFFORT}")
Client initialized. Using model: openai/gpt-5.6-luna
Reasoning effort: none
Step 1: The Report Writer¶
Our workflow begins with the Report Writer, an LLM instructed to act as a journalist who writes an initial report on a given topic.
Giving the model a role¶
The system message supplies instructions that should guide the model when it responds to the user message. It is part of the list of messages sent in the API request.
The OpenAI SDK uses a message format like this:
messages = [
{"role": "system", "content": "You are a..."}, # Instructions for the model
{"role": "user", "content": "..."}, # The request and its context
]For our Report Writer:
System message: Instructs the LLM to behave as a journalist writing informative reports
User message: Supplies the topic and asks for a concise, well-structured report
The user message does not have to be the raw topic by itself. We can add context or instructions around it, for example, Write a concise, well-structured report on the following topic: {topic}.
# System prompt that defines the Report Writer persona
WRITER_SYSTEM_PROMPT = """You are a journalist who writes clear, informative reports.
When given a topic, write a short report (2-3 paragraphs) that:
- Provides a balanced overview of the topic
- Includes relevant context and background
- Is written in a professional, accessible style
Write only the report itself, without any preamble or meta-commentary."""def generate_initial_report(topic: str, system_prompt: str = WRITER_SYSTEM_PROMPT, model: str = MODEL) -> str:
"""
Generate an initial report on the given topic using the Report Writer role.
Args:
topic: The subject for the report
system_prompt: Instructions that define the writer role (override to experiment)
model: The model id to use for this call (override to experiment)
Returns:
The generated report as a string
"""
response = client.chat.completions.create(
model=model,
messages=[
{"role": "system", "content": system_prompt},
{
"role": "user",
"content": f"Write a concise, well-structured report on the following topic: {topic}",
},
],
reasoning_effort=REASONING_EFFORT,
)
return response.choices[0].message.content or ""The function above:
Takes a
topicstringWraps it with a more specific request
Sends the user message together with the writer’s system message
Asks the model not to spend extra tokens on additional reasoning for this simple task
Returns the generated report text
Some models accept a temperature setting that adjusts how varied their output is. This model’s current OpenRouter parameter list does not include temperature, so we do not send one. Model outputs can still vary between runs.
For this demonstration, we will make one writer call, inspect its response object, and reuse that same response as the initial report.
Pedagogical note¶
The SDK returns more than the generated text. We will keep the complete response object so we can inspect its fields before extracting the report.
# Make one writer call and keep the complete response object.
topic = "The impact of artificial intelligence on healthcare"
response = client.chat.completions.create(
model=MODEL,
messages=[
{"role": "system", "content": WRITER_SYSTEM_PROMPT},
{
"role": "user",
"content": f"Write a concise, well-structured report on the following topic: {topic}",
},
],
reasoning_effort=REASONING_EFFORT,
)
response.model_dump(){'id': 'gen-1789416251-iymyu0w3Rbtl9yj31kqL',
'choices': [{'finish_reason': 'stop',
'index': 0,
'logprobs': None,
'message': {'content': 'Artificial intelligence is reshaping healthcare by supporting diagnosis, treatment planning, drug discovery, and administrative work. Machine-learning systems can analyze medical images, identify patterns in patient data, and help clinicians detect conditions such as cancer or heart disease earlier. AI tools may also improve hospital efficiency by predicting demand, automating documentation, and enabling more personalized care.\n\nHowever, these benefits come with significant challenges. AI systems can reproduce biases in the data used to train them, produce incorrect recommendations, and raise concerns about privacy, cybersecurity, and accountability. Unequal access to advanced technology could also widen existing healthcare disparities. As a result, experts generally stress that AI should complement—not replace—medical professionals, with rigorous testing, transparent oversight, patient consent, and continued human judgment.',
'refusal': None,
'role': 'assistant',
'annotations': None,
'audio': None,
'function_call': None,
'tool_calls': None,
'reasoning': None},
'native_finish_reason': 'completed'}],
'created': 1789416251,
'model': 'openai/gpt-5.6-luna',
'object': 'chat.completion',
'moderation': None,
'service_tier': 'default',
'system_fingerprint': None,
'usage': {'completion_tokens': 154,
'prompt_tokens': 99,
'total_tokens': 253,
'completion_tokens_details': {'accepted_prediction_tokens': None,
'audio_tokens': 0,
'reasoning_tokens': 0,
'rejected_prediction_tokens': None,
'image_tokens': 0},
'prompt_tokens_details': {'audio_tokens': 0,
'cache_write_tokens': 0,
'cached_tokens': 0,
'video_tokens': 0},
'cost': 0.0002046,
'is_byok': False,
'cost_details': {'upstream_inference_cost': 0.0002046,
'upstream_inference_prompt_cost': 1.98e-05,
'upstream_inference_completions_cost': 0.0001848}},
'provider': 'OpenAI'}Now extract the report text from the same response. This avoids paying for a second writer call and ensures that the response object above corresponds to the report used in the rest of the workflow.
The generate_initial_report function packages the same request pattern for reuse with other topics.
# Reuse the text from the response we just inspected.
initial_report = response.choices[0].message.content or ""
initial_report
'Artificial intelligence is reshaping healthcare by supporting diagnosis, treatment planning, drug discovery, and administrative work. Machine-learning systems can analyze medical images, identify patterns in patient data, and help clinicians detect conditions such as cancer or heart disease earlier. AI tools may also improve hospital efficiency by predicting demand, automating documentation, and enabling more personalized care.\n\nHowever, these benefits come with significant challenges. AI systems can reproduce biases in the data used to train them, produce incorrect recommendations, and raise concerns about privacy, cybersecurity, and accountability. Unequal access to advanced technology could also widen existing healthcare disparities. As a result, experts generally stress that AI should complement—not replace—medical professionals, with rigorous testing, transparent oversight, patient consent, and continued human judgment.'Step 2: The Critic¶
Now that we have an initial report, we pass it to the Critic, an LLM prompted to act as an editor who reviews the work and provides constructive feedback.
The Critic doesn’t rewrite the report. Instead, it identifies:
Areas that need clarification or more detail
Structural or logical issues
Missing perspectives or context
Ways to improve clarity and impact
This separation of concerns (writing vs. critiquing) is key to the reflection pattern. By having a dedicated critic, we get focused, actionable feedback rather than a muddled attempt to both evaluate and fix at once.
# System prompt that defines the Critic persona
CRITIC_SYSTEM_PROMPT = """You are an editor who provides constructive feedback on reports.
When given a report, provide a detailed critique that:
- Identifies areas that need more clarity or detail
- Points out any structural or logical issues
- Suggests missing perspectives or context that would strengthen the piece
- Offers specific, actionable suggestions for improvement
Be constructive and specific. Focus on how to make the report better, not just what's wrong with it.
Do not rewrite the report, only provide feedback."""def generate_critique(report: str, system_prompt: str = CRITIC_SYSTEM_PROMPT, model: str = MODEL) -> str:
"""
Generate a critique of the given report using the Critic role.
Args:
report: The report to critique
system_prompt: Instructions that define the critic role (override to experiment)
model: The model id to use for this call (override to experiment)
Returns:
The critique as a string
"""
response = client.chat.completions.create(
model=model,
messages=[
{"role": "system", "content": system_prompt},
{"role": "user", "content": f"Please critique the following report:\n\n{report}"},
],
reasoning_effort=REASONING_EFFORT,
)
return response.choices[0].message.content or ""The output of Step 1 becomes the input to Step 2. This is the basic idea behind chaining LLM calls: each stage receives information produced by an earlier stage.
We use the same low-cost reasoning setting for the critic. Its focused behavior comes primarily from the critic’s instructions. The critique may still be incomplete or incorrect, so we will inspect what it says rather than assume it found every problem.
# Generate critique of the initial report
critique = generate_critique(initial_report)
critique'## Overall assessment\n\nThe report provides a clear, balanced overview of AI in healthcare. It effectively presents major applications, then contrasts them with risks and concludes with a sensible principle: AI should support rather than replace clinicians. Its main limitation is that it remains broad and general. It would be stronger with specific examples, clearer distinctions among types of AI, evidence supporting its claims, and more detail about how the proposed safeguards would work.\n\n## Clarity and detail\n\n- **“Artificial intelligence” is used very broadly.** The report groups together machine learning, medical imaging tools, predictive systems, generative AI, and administrative automation. These technologies have different capabilities, risks, and levels of maturity. Briefly distinguishing them would make the discussion more precise.\n- **The benefits are listed but not explained.** For example, “supporting diagnosis” could refer to detecting abnormalities in scans, estimating disease risk, or helping clinicians interpret laboratory results. A short example for each major application would clarify the claims.\n- **Some statements are overly general.** The claim that AI can identify cancer or heart disease “earlier” needs qualification. Earlier detection may be possible in particular settings, but performance can vary by disease, population, data quality, and clinical workflow.\n- **“More personalized care” is vague.** The report should explain whether this means tailoring treatment recommendations, monitoring patients remotely, adjusting medication, or identifying different risk profiles.\n- **The phrase “experts generally stress” is unsupported.** Either cite relevant professional bodies or replace it with a more direct, evidence-based statement.\n\n## Structural and logical issues\n\n- The structure is coherent, but the transition from benefits to risks could be more analytical. It would help to connect specific benefits to corresponding risks—for example:\n - diagnostic tools and false positives or false negatives;\n - administrative automation and errors in clinical documentation;\n - personalized care and privacy concerns;\n - predictive systems and biased decision-making.\n- The report combines technical, ethical, legal, and social concerns in one paragraph. Subdividing these categories would improve readability and show that they require different responses.\n- The conclusion lists “rigorous testing, transparent oversight, patient consent, and continued human judgment,” but it does not explain whether these safeguards apply equally to all AI applications. Administrative tools, diagnostic systems, and drug-discovery models may require different evaluation standards.\n- The phrase “AI should complement—not replace—medical professionals” is useful but somewhat absolute. Some narrow tasks may be automated, while high-stakes decisions should retain meaningful human oversight. The report should distinguish between replacing individual tasks and replacing professional responsibility.\n\n## Missing perspectives and context\n\nConsider adding the following:\n\n1. **Evidence of effectiveness and limitations** \n Explain that strong performance in a laboratory or benchmark setting does not necessarily translate into improved patient outcomes. AI systems should be assessed in real clinical environments.\n\n2. **Data quality and representativeness** \n Bias is not only a result of biased algorithms. Missing data, inaccurate records, unequal access to care, and underrepresentation of certain demographic groups can also affect performance.\n\n3. **False positives, false negatives, and automation bias** \n Clinicians may overtrust an AI recommendation, even when it is wrong. Conversely, excessive skepticism could prevent useful systems from being adopted. These risks deserve explicit attention.\n\n4. **Accountability and liability** \n The report mentions accountability but does not ask who is responsible when an AI-supported decision causes harm: the developer, hospital, clinician, or organization that deployed the system.\n\n5. **Patient autonomy and informed consent** \n Consent may need to address not only data use but also whether AI is involved in diagnosis or treatment. Patients may also need understandable explanations of AI-supported decisions.\n\n6. **Workforce implications** \n AI may reduce administrative burdens, but it could also change professional roles, require retraining, or increase monitoring and documentation demands.\n\n7. **Economic and global dimensions** \n The report mentions unequal access but could discuss costs, infrastructure, internet connectivity, availability of technical staff, and differences between high-resource and low-resource healthcare systems.\n\n8. **Regulation and ongoing monitoring** \n AI systems can change as data, software, or clinical conditions change. The report should mention post-deployment monitoring, auditing, updating, and mechanisms for reporting errors.\n\n## Actionable suggestions\n\n- Add a brief definition of AI and distinguish diagnostic, predictive, generative, and administrative applications.\n- Include two or three concrete examples, while making clear that results vary by clinical context.\n- Support claims about improved outcomes or early detection with studies, statistics, or references to authoritative health organizations.\n- Organize the risks under headings such as **accuracy and safety**, **bias and equity**, **privacy and cybersecurity**, and **accountability**.\n- Explain what “rigorous testing” should include: representative datasets, comparison with current clinical practice, prospective trials, subgroup analysis, and post-deployment monitoring.\n- Clarify that human oversight must be meaningful rather than merely nominal; clinicians need the authority, time, and training to question AI outputs.\n- End with a more specific conclusion identifying the conditions under which AI is most likely to benefit healthcare: reliable evidence, equitable access, secure data practices, transparent governance, and patient-centered implementation.\n\nOverall, the report is a strong introductory summary, but it would benefit from greater precision, supporting evidence, and a clearer account of how healthcare institutions can manage the risks it identifies.'print("Critique word count:", len(critique.split()))
Critique word count: 843
Step 3: The Reviser¶
The Reviser receives both the original report and the critique, then produces another version.
The Reviser has:
The initial draft
The critic’s comments
This gives it an opportunity to make targeted changes while preserving useful parts of the draft. However, the critic may miss a problem or suggest an unhelpful change, and the reviser may not follow good advice. We therefore need to inspect the final version rather than assume it improved.
# System prompt that defines the Reviser persona
REVISER_SYSTEM_PROMPT = """You are a senior reporter who produces polished, final versions of reports.
You will receive an original report and editorial feedback. Your task is to revise the report by:
- Addressing the specific points raised in the critique
- Improving clarity, structure, and flow
- Maintaining the original voice and intent
- Ensuring the final version is publication-ready
Write only the revised report, without any preamble or explanation of your changes."""def generate_revised_report(report: str, critique: str, system_prompt: str = REVISER_SYSTEM_PROMPT, model: str = MODEL) -> str:
"""
Generate a revised report using the Reviser role.
Args:
report: The original report to revise
critique: The editorial feedback to consider
system_prompt: Instructions that define the reviser role (override to experiment)
model: The model id to use for this call (override to experiment)
Returns:
The revised report as a string
"""
user_message = f"""Please revise the following report based on the editorial feedback provided.
ORIGINAL REPORT:
{report}
EDITORIAL FEEDBACK:
{critique}"""
response = client.chat.completions.create(
model=model,
messages=[
{"role": "system", "content": system_prompt},
{"role": "user", "content": user_message},
],
reasoning_effort=REASONING_EFFORT,
)
return response.choices[0].message.content or ""This function takes two inputs: the original report and the critique. The labeled sections help the model distinguish the draft from the comments about it.
Let’s generate the revised version and then compare it with the original. Exact requirements, such as a word limit, should be checked with Python rather than estimated by the model.
# Generate the final revised report
final_report = generate_revised_report(initial_report, critique)
final_report'Artificial intelligence (AI) in healthcare encompasses several distinct technologies. Machine-learning systems can analyze medical images or patient records; predictive models estimate risks such as hospital readmission; generative AI can draft clinical notes or summarize records; and automated systems can schedule appointments, process claims, or support other administrative tasks. Their capabilities, evidence requirements, and risks differ considerably.\n\nThese tools may assist diagnosis by flagging abnormalities in scans, identifying patterns in laboratory results, or estimating a patient’s likelihood of developing a condition. In some settings, such systems may help clinicians detect diseases such as cancer or heart disease earlier, but results vary according to the disease, patient population, data quality, and clinical workflow. Strong performance in a laboratory or benchmark test does not necessarily improve outcomes in routine care; systems must also be evaluated in real-world clinical environments.\n\nAI can support treatment planning by helping clinicians compare patient characteristics with evidence from medical records and research. It may also enable more individualized care by identifying different risk profiles, monitoring patients remotely, or alerting professionals when medication or follow-up may need adjustment. In drug discovery, AI can help identify promising compounds and predict how they might behave, potentially accelerating early research, although such models do not replace laboratory and clinical testing. Administrative applications may reduce time spent on documentation, scheduling, and claims processing, but inaccurate or incomplete automated records could create new clinical risks.\n\nThe challenges differ by application. Diagnostic tools can produce false positives, leading to unnecessary tests or treatment, or false negatives that delay care. Predictive systems may reflect missing or inaccurate records, unequal access to healthcare, or the underrepresentation of particular demographic groups—not simply flaws in an algorithm. Clinicians may also display “automation bias,” placing too much confidence in an AI recommendation, while excessive distrust could prevent a useful tool from being adopted. Administrative automation can introduce errors into clinical documentation, and generative systems may produce plausible but inaccurate information.\n\nAI also raises privacy and security concerns. Systems often require large amounts of sensitive health data, creating risks if information is collected without adequate consent, reused for unexpected purposes, or exposed through a cyberattack. Patients may reasonably want to know when AI is involved in their diagnosis or treatment and how their data are being used. Explanations should be understandable enough to support informed decisions, even when the underlying model is technically complex.\n\nAccountability is another unresolved issue. When an AI-supported decision causes harm, responsibility may involve the developer, healthcare organization, clinician, or other party that selected and deployed the system. Clear lines of liability, documented decision-making, and procedures for reporting and investigating errors are therefore essential. Human oversight must be meaningful rather than nominal: clinicians need the authority, time, training, and information required to question an AI output and override it when appropriate. That principle does not mean every task must remain manual. Narrow, low-risk functions may be automated, while high-stakes decisions should retain meaningful professional responsibility.\n\nHealthcare institutions should evaluate AI systems using representative datasets, comparisons with current clinical practice, prospective studies, and subgroup analyses to identify unequal performance. They should continue monitoring systems after deployment because software, patient populations, and clinical conditions can change. Regular audits, secure data practices, model updates, user training, and accessible mechanisms for patients and staff to report problems are also important safeguards.\n\nAccess and workforce effects require attention as well. AI may reduce administrative burdens and allow professionals to spend more time with patients, but it may also change job responsibilities, require retraining, or increase demands for monitoring and documentation. The cost of software, computing infrastructure, reliable internet access, and technical staff could limit adoption in lower-resource hospitals and widen existing disparities between regions and health systems.\n\nAI is therefore best understood as a set of tools whose value depends on how they are designed and used. It is most likely to benefit healthcare when supported by reliable clinical evidence, representative data, equitable access, strong privacy and cybersecurity protections, transparent governance, and patient-centered implementation. AI may automate selected tasks, but it should not transfer professional responsibility to an opaque system or substitute for informed clinical judgment in high-stakes care.'print("Initial report word count:", len(initial_report.split()))
print("Revised report word count:", len(final_report.split()))
Initial report word count: 119
Revised report word count: 687
Comparing the Results¶
Compare the initial report, critique, and revised report. Which comments were useful? Which changes helped? Did the revision introduce a new problem or leave an important issue unresolved?
from IPython.display import Markdown
comparison = f"""
## Initial Report
{initial_report}
---
## Critique
{critique}
---
## Final Report (After Reflection)
{final_report}
"""
Markdown(comparison)Experiments¶
The workflow above ran once, with one model and deliberately simple prompts. In the experiments below, change one thing at a time and use the comparison to decide whether it actually helped. Treat the Python word counts (and your own reading of the draft, critique, and revision) as the evidence, not the impression that a longer or more confident answer must be a better one.
Experiment 1: Give the critic an explicit rubric¶
The critic’s current instructions ask for “constructive, specific” feedback in general terms. A more useful rubric might tell the critic which criteria to check, to point to specific wording in the draft as evidence, and to prioritize the few changes that matter most.
Run the critic with the rubric-style prompt below and compare it with the original critique. Is the feedback more actionable? Does the revision improve more as a result, and did it introduce any new problem?
from IPython.display import Markdown
CRITIC_RUBRIC_PROMPT = """You are an editor. Evaluate the report against these criteria, one at a time:
1. Support: Are claims specific and grounded, or vague and unverifiable? Quote the weakest sentence.
2. Balance: Are multiple perspectives represented, or is the report one-sided?
3. Structure and clarity: Does the report flow logically? Point to any confusing transition.
4. Completeness: What important context or counterpoint is missing?
Rules:
- For each point, refer to specific wording in the draft as evidence.
- End with a line "Top 2 priorities:" naming the two highest-impact changes.
- Do not rewrite the report. Provide feedback only."""
# Re-run the critic and reviser using the rubric-style critic prompt.
rubric_critique = generate_critique(initial_report, system_prompt=CRITIC_RUBRIC_PROMPT)
rubric_revision = generate_revised_report(initial_report, rubric_critique)
print("Original critique word count:", len(critique.split()))
print("Rubric critique word count:", len(rubric_critique.split()))
print("Original revision word count:", len(final_report.split()))
print("Rubric revision word count:", len(rubric_revision.split()))
Markdown(f"""
## Original critique
{critique}
---
## Rubric critique
{rubric_critique}
---
## Revision using the rubric critique
{rubric_revision}
""")Experiment 2: Use a different model for the critic¶
Nothing requires all three roles to share a model; each is an independent API call. A model asked to critique its own output tends to miss the same things it missed while writing, so a common design choice is to give the critic a different (or stronger) model.
Before switching models, check the model’s supported parameters in the OpenRouter model list. This tutorial’s model, gpt-5.6-luna, accepts reasoning_effort but not temperature; another model may be the reverse. Because every call here sends reasoning_effort, a model that does not support it will raise an error; that error is itself a lesson that request parameters are model-specific. To keep this experiment simple, choose a second model that also supports reasoning_effort.
# Choose a second model that supports `reasoning_effort` (check the OpenRouter model list first).
ALT_CRITIC_MODEL = MODEL # <-- replace with a different model id to run this experiment
alt_critique = generate_critique(initial_report, model=ALT_CRITIC_MODEL)
alt_revision = generate_revised_report(initial_report, alt_critique)
print("Critic model:", ALT_CRITIC_MODEL)
print("Alt critique word count:", len(alt_critique.split()))
print("Alt revision word count:", len(alt_revision.split()))
Markdown(f"""
## Critique from {ALT_CRITIC_MODEL}
{alt_critique}
---
## Revision using the alternate-model critique
{alt_revision}
""")Reflect¶
When a revision comes out better, notice what this workflow can and cannot tell you. It cannot cleanly separate the critic’s contribution from the reviser’s: a better result might mean the critic gave sharp feedback, or that the reviser executed well despite mediocre feedback, or both. What additional information would you need to tell the two apart?
Now look back at all three prompts. Are there general requirements for these reports that should guide the Writer and the Critic from the start? What are the trade-offs between generality and specificity: are good criteria universal, or domain-specific? Modify the prompts and re-run the notebook to observe the effects.