LLM and AI Agent Applications with Langchain and Langgraph – Part 28: Multi-Agent Discussion Panel (Researchers, Experts, Critics, Moderators)

by
0 comments
LLM and AI Agent Applications with Langchain and Langgraph - Part 28: Multi-Agent Discussion Panel (Researchers, Experts, Critics, Moderators)

Author(s): michaelczarnecki

Originally published on Towards AI.

hello. In this part I will present a multi-agent applicationsThis will be a discussion panel with four roles:

  • researcher – Has access to a search tool and brings facts and sources into the conversation.
  • expert – Based on the information gathered, proposes a solution or plan of action.
  • reviewer – Asks additional questions, points out shortcomings and risks, and fills in missing pieces.
  • Mediator – Monitors the discussion and keeps it on track.

Why Langgraph fits perfectly here

Because a graph lets us model conditions, loops, and branches, langgraph An ideal environment for building this type of application.

How the app works

The flow is straightforward:

Mediator Manages discussions and takes decisions:

  • If the moderator decides that we already have a satisfactory solution → we end,
  • If not → we go back researcher Continue further iteration with a new research question.

This shows how real teams work:

Collect data → Propose solution → Critically verify → Decide next steps

Where this pattern is useful

In practice, this template is great for “research and synthesis” tasks – market analysis, writing a specification, preparing a project plan, or performing a preliminary technical audit.

And the best part is: you can reuse the same structure for multiple topics. You simply change the topic of discussion and, if necessary, adjust the roles slightly.

Architecture at a glance

Actually the discussion panel is led by the moderator who manages the discussion and decides where to pass the microphone next. We will use the same approach for our application using an “Agent Supervisor”. This is well described in Article,
we will implement a observer-directed panel Of the three agents:

  • researcher – Collects facts using web search.
  • expert – synthesizes a plan or recommendation
  • reviewer – Finds risks, gaps and countermeasures.

And above them:

  • Supervisor (Operator) – Makes and produces turn-taking decisions final answer,

Press Enter or click to view the image full size

Discussion panel with AI agent graph structure

what will we make

  • A fully working Langgraph Multi-Agent Debate Panel.
  • Tawili-Integrated powered web research through Langchain langchain-tavily package.
  • Streamed updates from subgraphs (agents) to understand who said what, When?And Why,
  • A Structured final conclusion – Moderator’s work.

Step-by-Step: Create a Discussion Panel

Below I present each snippet and explain what it does. You can paste directly into a notebook or use the link attached at the end to my Github repo with a complete, runnable notebook.

1) Install the library

%%capture --no-stderr
%pip install -U dotenv langchain_core langgraph langgraph-supervisor langchain-tavily "langchain(openai)"
!apt install libgraphviz-dev
!pip install pygraphviz
  • langgraph Provides graph engine and prebuilt nodes; The new release moved some “prebuilt” helpers to sibling packages, but langgraph.prebuilt There remains a common import path displayed in their documentation and 0.3 release notes. Langchen AI+1
  • langchain-tavily Is Officer tavil integration

2) Load API Key

from dotenv import load_dotenv
load_dotenv()

Keep OPENAI_API_KEY= And TAVILY_API_KEY= in your .env file.
Find out more about Dotenv Here,

3) Web Search with Tavili

from langchain_tavily import TavilySearch
from langchain_tavily import TavilySearch

web_search = TavilySearch(max_results=3)
web_search_results = web_search.invoke("Who is the president of Poland?")

print(web_search_results("results")(0)("content"))

Output:

The president of Poland officially the president of the Republic of Poland is the head of state of Poland. The president's prerogatives and duties are

4) Pretty printer for output

We’ll use the helpful functions below to stream and visualize the debate as it begins (you can skip reading this part, unless somehow you find it interesting ;).

from langchain_core.messages import convert_to_messages

def pretty_print_message(message, indent=False):
pretty_message = message.pretty_repr(html=True)
if not indent:
print(pretty_message)
return

indented = "n".join("t" + c for c in pretty_message.split("n"))
print(indented)

def pretty_print_messages(update, last_message=False):
is_subgraph = False
if isinstance(update, tuple):
ns, update = update
# skip parent graph updates in the printouts
if len(ns) == 0:
return

graph_id = ns(-1).split(":")(0)
print(f"Update from subgraph {graph_id}:")
print("n")
is_subgraph = True

for node_name, node_update in update.items():
update_label = f"Update from node {node_name}:"
if is_subgraph:
update_label = "t" + update_label

print(update_label)
print("n")

messages = convert_to_messages(node_update("messages"))
if last_message:
messages = messages(-1:)

for m in messages:
pretty_print_message(m, indent=is_subgraph)
print("n")

Agents with dedicated roles

we will use langgraph Prebuilt React Agent Quickly deploying role-specific agents. Under the hood, these agents can call registered tools (for example, TavilySearch) and report back to the supervisor.

5) Researcher Agent

from langgraph.prebuilt import create_react_agent

research_agent = create_react_agent(
model="openai:gpt-4.1",
tools=(web_search),
prompt=(
"You're the Researcher. You have access to fragments from the 'search engine' (RESEARCH).n"
"Your goal is to provide factual, concise facts and data supporting the topic.n"
"Refer to the fragments and do not invent. Write concisely and briefly."
"- After you finish your task, respond directly to the moderatorn"
"- Reply using only the results of your work, do not include the text."
),
name="research_agent",
)

Why does this role matter?: Most hallucinations originate from insufficient evidenceA dedicated researcher searches, cites and returns Only What a grounded person.

6) Expert Agent

expert_agent = create_react_agent(
model="openai:gpt-4.1",
tools=(),
prompt=(
"You're the Expert. From the available facts, propose a practical solution/plan.n"
"Include steps, requirements, and a minimal set of decisions. Write concretely."
"- After you finish your task, respond directly to the moderatorn"
"- Reply using only the results of your work, do not include the text."
),
name="expert_agent",
)
  • expert Does not call tools; it is transformed Fact → Plan,
  • For production, you can also add Domain-Specific Tools (For example, cost calculator, policy validator).
  • You can also provide more detailed indications related to the specific domain for which the expert agent is an expert (e.g. finance, healthcare, physics, chemistry, etc.).

7) Critic Agent

critic_agent = create_react_agent(
model="openai:gpt-4.1",
tools=(),
prompt=(
"You're the Critic. Your role is to find gaps, risks, and ambiguities in the proposal.n"
"Ask probing questions and point out missing elements. Be constructive."
"- After you finish your task, respond directly to the moderatorn"
"- Reply using only the results of your work, do not include the text."
),
name="critic_agent",
)

reviewer clearly aims adverse completion – A polite, creative “red team.”

Debate-style agents push to justify claims with evidence and address counter-arguments – reducing undue overconfidence.

from typing import Annotated
from langchain_core.tools import tool, InjectedToolCallId
from langgraph.prebuilt import InjectedState
from langgraph.graph import StateGraph, START, MessagesState
from langgraph.types import Command

def create_handoff_tool(*, agent_name: str, description: str | None = None):
name = f"transfer_to_{agent_name}"
description = description or f"Ask {agent_name} for help."

@tool(name, description=description)
def handoff_tool(
state: Annotated(MessagesState, InjectedState),
tool_call_id: Annotated(str, InjectedToolCallId),
) -> Command:
tool_message = {
"role": "tool",
"content": f"Successfully transferred to {agent_name}",
"name": name,
"tool_call_id": tool_call_id,
}
return Command(
goto=agent_name,
update={**state, "messages": state("messages") + (tool_message)},
graph=Command.PARENT,
)

return handoff_tool

# Handoffs
assign_to_research_agent = create_handoff_tool(
agent_name="research_agent",
description="Assign task to a researcher agent.",
)

assign_to_expert_agent = create_handoff_tool(
agent_name="expert_agent",
description="Assign task to a expert agent.",
)

assign_to_critic_agent = create_handoff_tool(
agent_name="critic_agent",
description="Assign task to a critic agent.",
)

Supervisor/Moderator and Assistant

supervisor (The Moderator) decides which agent should speak next and when to stop. We create a “handoff tool” that lets the supervisor explicitly route turn-taking.

8) Moderator Agent + Handoff Tool

supervisor_agent = create_react_agent(
model="openai:gpt-4.1",
tools=(assign_to_research_agent, assign_to_expert_agent, assign_to_critic_agent),
prompt=(
"You're the Moderator of a discussion in which 3 agents take part: Researcher, Critic and Expert. You decide whether we finish or continue.n"
"If we continue, provide a SHORT next research query (research_query) for the Researcher, Critic or Expert. If we finish, summarize the discussion and present in a structured and clear way the answer to the question."
"- Researcher. Searches for information and provides facts that form the basis of further discussionn"
"- Critic. Looks assertively at the conclusions so far and points out weak points and elements to change or improven"
"- Expert. Draws conclusions and makes theses. Tries to solve the task based on the information received from the Researcher and Criticn"
"Assign the work to one agent at a time, do not call agents in parallel.n"
"Do not take part in the work discussion yourself."
),
name="supervisor",
)

What’s going on over here?

  • Everyone handoff tool return a Command Asking the graph to go to a specific agent.
  • supervisor Calls one of these tools per turn.
  • When it is decided that the debate is over, it sum up And emits the final answer.

9) Make a graph

from langgraph.graph import END

# Define the multi-agent supervisor graph
supervisor = (
StateGraph(MessagesState)
# NOTE: `destinations` is only needed for visualization and doesn't affect runtime behavior
.add_node(supervisor_agent, destinations=("research_agent", "expert_agent", "critic_agent", END))
.add_node(research_agent)
.add_node(expert_agent)
.add_node(critic_agent)
.add_edge(START, "supervisor")
# always return back to the supervisor
.add_edge("research_agent", "supervisor")
.add_edge("expert_agent", "supervisor")
.add_edge("critic_agent", "supervisor")
.compile()
)

it defines nodes (agent) and edges (control flow). After each agent turn, the flow returns to supervisorSee LangGraph’s documentation for how states, nodes, and edges fit together,

10) Visualize the graph

from IPython.display import display, Image

display(Image(supervisor.get_graph().draw_png()))

This produces a crisp PNG of the graph – useful for Jupyter notebooks or documents.

Press Enter or click to view the image full size

start a debate

Hooray, we’ve come to the grand finale where we can run our discussion and check the results!

for chunk in supervisor.stream(
{
"messages": (
{
"role": "user",
"content":"What field is best to study in order to have a well-paid and interesting job in 10 years.",
}
)
},
subgraphs=True,
):
pretty_print_messages(chunk, last_message=True)

Sample Result:

To have a well-paid and interesting job in 10 years:
Define what "interesting" means for you (creative, technical, people-oriented, etc.).
Choose a field resilient to automation and tech shifts, e.g.:
• Computer Science (AI, cybersecurity, data science)
• Green tech & energy, environmental engineering
• Automation & robotics, biotechnology
• Services for aging societies (medicine, health)
• Law & ethics of new technologies, UX design
Develop soft skills: flexibility, creativity, collaboration, problem-solving.
Embrace interdisciplinarity (combine multiple domains).
Plan continuous learning and readiness for career changes.
No single field guarantees success - the key is combining your strengths with future-proof competencies and staying open to growth.

I am also attaching an excerpt of the conversation between the researcher, expert, critic and moderator at the end of this article.

Why does this structure outperform single-agent React?

  • strong grounding: The researcher keeps everyone honest by anchoring in sources.
  • synthesis under pressure: The expert must propose a solid plan that will survive criticism.
  • systematic stress testing: The critic exposes risks (compliance, cost, feasibility) before the output leaves your system.
  • active orchestra: Moderator stops tunneling, decides when to continue vs. when to end, and formats final answer For stakeholders.

Even compared to a classic feedback agent, this debate+observation loop yield better-argued, better-structured Results of complex questions. (Langchain’s own documentation steers production users toward React’s Langgraph implementation for robustness.)

Practical Tips and Variations

researcher: Tavili (web), proprietary search, vector DB, scraping tools.

expert: Domain Calculator, Scheduling/Optimization, Code Execution Sandbox.

reviewer: Risk Checklists, Policy Validator, Test Generator.

  • language change
    The signs here are in Polish; Keep user-facing answers in the user’s language, and consider translating the final moderator summary if your audience is multilingual.
  • stopping conditions
    Add clear rules for when the moderator should end the debate (e.g., trust thresholds, evidence coverage, budget/tokens).
  • Citation
    ask the researcher to come back structured quotesThe moderator may include references in the final answer,
  • cost and latency
    Debates cost more tokens. Balance this with: shorter turns, smaller models for the researcher/critic, equipment constraints, or “one-round quick mode.
  • Evaluation
    Add and compare offline test sets Single-Prompt vs React vs Panel On accuracy, helpfulness and decision quality.

That’s all in this chapter dedicated to AI agent applications with agent debate panels. In the next chapter we will take a look at the model-agnostic pattern and the LLM API gateway that can simplify releasing and maintaining the project on a production environment.

Look next chapter

Look previous chapter

See the full code from this article in GitHub treasury

appendix

Part of the conversation between researchers, experts, critics and moderators:

================================== Ai Message ==================================
Name: expert_agent

Practical Solution/Plan:

Field of Study Recommendation: Choose a degree in Data Science, Artificial Intelligence, Computer Science, or Cybersecurity for maximum potential of high salary and continued job interest over the next 10 years. Alternative strong options are Engineering, Specialized Healthcare (e.g., Nurse Practitioner or Epidemiology), and Logistics/Supply Chain Management.

Steps:
1. Assess your personal interests—technical, analytical, people-oriented, etc.—to ensure motivation and long-term satisfaction, as "interesting" is subjective.
2. Research national and regional job market trends for your target location; while global trends favor tech and healthcare, local demand may vary.
3. Select an accredited program at a university or technical school in one of these fields.
4. During your studies, seek internships or work-study positions in growing industries (tech, healthcare, logistics).
5. Build interdisciplinary skills: Communication, management, problem-solving, and adaptability are highly valued alongside technical competence.
6. Reassess trends every few years to pursue relevant certifications or continued education, staying agile to adapt to any significant field shifts.

Minimal Set of Decisions:
- Choose a field that aligns with both high-paying forecasts and your interest.
- Decide between technology (data, AI, cybersecurity), healthcare, or logistics based on aptitude and market.
- Select a reputable, adaptable program.
- Commit to ongoing learning and skill-building.

Requirements:
- Completion of secondary education with strong math/science background.
- Admission into a relevant undergraduate program.
- Willingness to engage in practical learning and continuous professional development.

This plan balances future salary prospects, long-term employability, and personal fulfillment.

 ================================== Ai Message ==================================
Name: supervisor
Tool Calls:
transfer_to_research_agent (call_IQ9yFVRsojCORDeOkO8ZLIDU)
Call ID: call_IQ9yFVRsojCORDeOkO8ZLIDU
Args:
Update from subgraph research_agent:
Update from node agent:
================================== Ai Message ==================================
Name: research_agent
Tool Calls:
tavily_search (call_OapqfUplIcEEN0gIi8icqXPP)
Call ID: call_OapqfUplIcEEN0gIi8icqXPP
Args:
query: best fields of study for high-paying and interesting professions in 10 years
search_depth: advanced
Update from subgraph research_agent:
Update from node tools:
================================= Tool Message =================================
Name: tavily_search

{"query": "best fields of study for high-paying and interesting professions in 10 years", "follow_up_questions": null, "answer": null, "images": (), "results": ({"url": "https://global.nmsu.edu/blog/general/in-demand-college-majors-2025/", "title": "Top Degrees in Demand for the Future | Best Majors", "content": "With the increasing amount of data being generated globally, companies are in need of data scientists who can analyze and interpret this data to make informed decisions. The BLS estimates that jobs for data scientists will grow by 36% over the next decade. 10 Fields like machine learning, artificial intelligence (AI), and data visualization will only continue to grow in importance. (...) Finally, median salaries and job stability are major factors in determining demand. High-paying careers, especially those that offer job security, naturally attract more students. Majors tied to fields like finance, engineering, and technology are often in high demand not just for the exciting job roles they offer, but for the competitive salaries and stability they provide. Websites like PayScale and Glassdoor give you access to salary trends and job stability projections, helping you (...) 8. “Occupational Outlook Handbook: Information Security Analysts.” U.S. Bureau of Labor Statistics, last updated 29 August 2024.nn9. “Occupational Outlook Handbook: Registered Nurses.” U.S. Bureau of Labor Statistics, last updated 29 August 2024.nn10. “Occupational Outlook Handbook: Data Scientists.” U.S. Bureau of Labor Statistics, last updated 29 August 2024.", "score": 0.41534993, "raw_content": null}, {"url": "https://www.themuse.com/advice/high-paying-jobs-in-demand-for-future", "title": "15 High-Paying Jobs That'll Be in Demand for Years to Come |", "content": "For the purposes of this list, we’ve defined “high-paying” as jobs whose median pay was above the median household income in the U.S., which was $80,610 in 2023. “Poised for serious growth” means BLS has projected this occupation will grow “faster than average” or “much faster than average” over the next 10 years. (For reference, the average growth rate for all occupations is 5.3%.) Here is the list:nn### 1. Nurse practitioner (...) ### 15. Nursing instructor and teacher, postsecondarynnMedian salary in 2023: $80,780 nProjected growth rate between 2023 and 2033: 17.9%nnNursing instructors and teachers, postsecondary teach, instruct, and demonstrate patient care for nursing students. Like health specialties teachers, these professionals often go beyond teaching and engage in research. (...) Epidemiologists research, monitor, and investigate diseases (and general public health issues) to identify patterns and potential causes for epidemics. By analyzing statistics, they're able to develop models to predict future occurrences.", "score": 0.4059909, "raw_content": null}, {"url": "https://www.globaladmissions.com/blog/top-15-future-jobs-in-high-demand-by-2030-and-what-to-study", "title": "Top 15 Future Jobs in High Demand by 2030 (And What to Study)", "content": "Transport goods to businesses, homes, and distribution centersn Load and unload products, ensuring proper handlingn Plan delivery routes for efficiency and timely deliveriesn Inspect vehicles for safety and perform basic maintenancennWhat You Can Study:nn Logistics and Transportationn Supply Chain Managementn Business Operationsnn## 10. Internet of Things (IoT) Specialists (...) Develop machine learning models and AI algorithmsn Train systems to recognize patterns and make predictionsn Analyze large data sets to improve AI performancen Work with teams to integrate AI solutions into real-world applicationsnnWhat You Can Study:nn Artificial Intelligencen Machine Learningn Roboticsn Computer Sciencen Data Sciencenn## 4. Software and Applications Developers (...) Design and develop IoT devices and systemsn Integrate hardware with software for seamless connectivityn Monitor and optimize network performancen Ensure data security and manage large-scale IoT infrastructuresnnWhat You Can Study:nn Internet of Things (IoT)n Computer Engineeringn Embedded Systemsn Information Technologyn Network Engineeringnn## 11. Data Analysts and Scientists", "score": 0.37765598, "raw_content": null}), "response_time": 2.04, "request_id": "9038a1f7-3d4a-4144-82ee-50be43b8fe7d"}

Update from subgraph research_agent:
Update from node agent:
================================== Ai Message ==================================
Name: research_agent

Fields projected to be both high-paying and interesting in the next 10 years include:

1. Data Science and Artificial Intelligence: Significant job growth (36% for data scientists by 2033) with roles in machine learning, AI, and data analytics. These fields are expanding across industries and offer high salaries.
2. Engineering and Technology: Majors in computer science, robotics, software development, and embedded systems lead to well-paid, future-proof careers.
3. Healthcare: Roles such as nurse practitioners, epidemiologists, and nursing instructors are projected to grow faster than average with high median salaries and engaging work.
4. Information Security: Cybersecurity experts and information security analysts are in increasing demand as digital threats grow.
5. Supply Chain and Logistics: With global trade and e-commerce growth, expertise in logistics, supply chain management, and business operations will remain vital.

Degree areas: Data Science, AI, Computer Science, Engineering, Nursing, Healthcare, Cybersecurity, Supply Chain Management, Logistics.
Sources: New Mexico State University, The Muse, Global Admissions

Update from subgraph supervisor:
Update from node agent:
================================== Ai Message ==================================
Name: supervisor
Tool Calls:
transfer_to_critic_agent (call_TARszeki4nbied4s3zyldIl8)
Call ID: call_TARszeki4nbied4s3zyldIl8
Args:
Update from subgraph critic_agent:
Update from node agent:
================================== Ai Message ==================================
Name: critic_agent

The answer lists several promising fields for future high-paying, interesting professions, focusing on data science, AI, technology, healthcare, cybersecurity, and logistics. However, there are some ambiguities and gaps:

1. Lack of Contextual Variability: The proposal does not account for geographical differences or local market demands that could shift these projections. Is this advice universally applicable, or does it skew toward the US/Western economies?
2. Definition of “Interesting”: “Interesting” is subjective. What are the criteria—problem-solving, impact on society, work-life balance, creativity?
3. Volatility & Risk: Technology rapidly changes. Fields considered “future-proof” now could be disrupted by automation, regulation, or shifts in public policy (e.g., healthcare funding, cybersecurity regulation).
4. Interdisciplinary Skills: The specific value of soft skills, adaptability, or interdisciplinary approaches (e.g., combining tech with humanities or business) is omitted but often crucial for the future workforce.
5. Job Nature & Quality: Growth rate and high salaries do not always equate to job satisfaction or work-life balance. What about burnout in healthcare, ethical dilemmas in AI, or security stress in cybersecurity?
6. Overlooked Fields: The response focuses heavily on STEM and healthcare, potentially overlooking emerging fields in sustainability, environmental science, or creative industries powered by new technology.
7. Source Limitations: The proposal cites projections but does not discuss their underlying assumptions or limitations.

Moderator, I recommend clarifying the target location, the individual’s values/interests, and acknowledging that adaptability across fields will be a key asset. More nuanced guidance would help ensure relevance and resilience for the next decade.

Published via Towards AI

Related Articles

Leave a Comment