LLM & AI Agent Applications with LangChain and LangGraph — Part 28: Multi-Agent Discussion Panel…
LLM & AI Agent Applications with LangChain and LangGraph — Part 28: Multi-Agent Discussion Panel (Researcher, Expert, Critic, Moderator)

Hi. In this part I’ll present a multi-agent application. It 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 collected information, proposes a solution or a plan of action.
- Critic — asks additional questions, points out gaps and risks, and fills missing pieces.
- Moderator — oversees the discussion and keeps it on track.
Why LangGraph fits perfectly here
Because a graph lets us model conditions, loops, and branching, LangGraph is an ideal environment for building this kind of application.
How the application works
The flow is straightforward:
The Moderator manages the discussion and makes a decision:
- if the moderator decides we already have a satisfactory solution → we finish,
- if not → we go back to the Researcher with a new research question and continue the iteration.
This mirrors how real teams work:
collect data → propose a solution → critically verify → decide next steps
Where this pattern is useful
In practice, this template is great for “research & synthesis” tasks — market analysis, writing a specification, preparing a project plan, or doing an initial technical audit.
And the best part is: you can reuse the same structure for many topics. You just change the discussion subject and, if needed, slightly adjust the roles.
Architecture at a glance
In reality the discussion panels are led by moderator who manages the discussion and decides where to pass microphone next. We’ll use similar approach for our application by using “Agent Supervisor”. It’s described well in this article.
We’ll implement a Supervisor-routed panel of three agents:
- Researcher — gathers facts using web search.
- Expert — synthesizes a plan or recommendation
- Critic — finds risks, gaps, and counter-arguments.
and above them:
- Supervisor (Moderator) — decides turn-taking and produces the final answer.
Press enter or click to view image in full size

discussion panel with AI agents graph structure
What we will build
- A fully working LangGraph multi-agent debate panel.
- Tavily-powered web research integrated via LangChain’s langchain-tavily package.
- Streamed updates from subgraphs (agents) to understand who said what, when, and why.
- A structured final conclusion — the Moderator’s job.
Step-by-step: Build the Discussion Panel
Below I present each snippet and explain what it does. You can paste directly into a notebook or use link enclosed at the end, with a full, runnable notebook in my github repo.
1) Install libraries
%%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 the graph engine and prebuilt nodes; newer releases moved some “prebuilt” helpers into a sibling package, but langgraph.prebuilt remains a common import path showcased in their docs and 0.3 release notes. LangChain AI+1
- langchain-tavily is the official Tavily integration
2) Load API keys
from dotenv import load_dotenv
load_dotenv()
Put OPENAI_API_KEY=<key> and TAVILY_API_KEY=<key> in your .env file.
Find more information about dotenv here.
3) Web search with Tavily
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 printers for outputs
We’ll use helper functions below to stream and visualize the debate as it unfolds (you can skip reading this part, unless somehow you find it kind of 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’ll use LangGraph’s prebuilt ReAct agents to spin up role-specific agents quickly. Under the hood, these agents can call registered tools (e.g., 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",
)
- The Researcher uses TavilySearch to gather grounded facts.
- You can swap openai:gpt-4.1 for an Anthropic or other provider alias if configured. See https://platform.openai.com/docs/models
Why this role matters: Most hallucinations originate in insufficient evidence. A dedicated Researcher seeks, cites, and returns only what’s grounded.
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",
)
- The Expert doesn’t call tools; it transforms facts → plan.
- For production, you might also add domain-specific tools (e.g., cost calculators, policy validators).
- You can give also more detailed prompt related to specific domain for which expert agent specializes in (for example finances, health care, 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",
)
The Critic explicitly aims for adversarial completeness — a polite, constructive “red team.”
Debate-style agents add pressure to justify claims with evidence and to address counter-arguments — reducing unjustified 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 hand-offs
The Supervisor (Moderator) decides which agent should speak next and when to stop. We create “handoff tools” that let the Supervisor explicitly route turn-taking.
8) Moderator agent + handoff tools
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 happening here?
- Each handoff tool returns a Command telling the graph to go to a specific agent.
- The Supervisor calls exactly one of these tools per turn.
- When it decides the debate is over, it summarizes and emits the final answer.
9) Build the 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()
)
This defines nodes (agents) and edges (control flow). After each agent turn, the flow returns to the Supervisor. See LangGraph’s docs for how state, 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 — handy for jupyter notebook or docs.
Press enter or click to view image in full size

Run the debate
Hurray, we come to grande 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 enclose also part of conversation between researcher, expert, critic and moderator at the end of this article.
Why this structure outperforms single-agent ReAct
- Stronger grounding: The Researcher keeps everyone honest by anchoring in sources.
- Synthesis under pressure: The Expert must propose a concrete plan that survives criticism.
- Systematic stress-testing: The Critic surfaces risks (compliance, cost, feasibility) before the output leaves your system.
- Active orchestration: The Moderator prevents tunneling, decides when to continue vs. conclude, and formats the final answer for stakeholders.
Even compared with a classic ReAct agent, this debate + supervision loop yields better-argued, better-structured results for complex questions. (LangChain’s own docs nudge production users toward the LangGraph implementation of ReAct for robustness.)
Practical tips & variations
- Add tools per role
Researcher: Tavily (web), proprietary search, vector DBs, scraping tools.
Expert: domain calculators, scheduling/optimization, code execution sandboxes.
Critic: risk checklists, policy validators, test generators.
- Language switching
Prompts 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. - Stop conditions
Add explicit rules for when the Moderator should end the debate (e.g., confidence thresholds, evidence coverage, budget/tokens). - Citations
Have the Researcher return structured citations. The Moderator can include references in the final answer. - Cost & latency
Debates cost more tokens. Balance with: shorter turns, smaller models for Researcher/Critic, tool constraints, or a “one-round quick mode. - Evaluation
Add offline test sets and compare single-prompt vs. ReAct vs. Panel on accuracy, helpfulness, and decision quality.
That’s all int this chapter dedicated to AI agent application with agents debate panel. In the next chapter we will take a look at model-agnostic pattern and LLM API gateway that can simplify releasing and mainitain project on production environment.
see next chapter
see previous chapter
see the full code from this article in the GitHub repository
Appendix
Part of conversation between researcher, expert, critic and moderator:
================================== 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.
LLM & AI Agent Applications with LangChain and LangGraph — Part 28: Multi-Agent Discussion Panel… was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.