Hierarchical Teams
Hierarchical Agent Teams¶
In our previous example (Agent Supervisor), we introduced the concept of a single supervisor node to route work between different worker nodes.
But what if the job for a single worker becomes too complex? What if the number of workers becomes too large?
For some applications, the system may be more effective if work is distributed hierarchically.
You can do this by composing different subgraphs and creating a top-level supervisor, along with mid-level supervisors.
To do this, let's build a simple research assistant! The graph will look something like the following:

This notebook is inspired by the paper AutoGen: Enabling Next-Gen LLM Applications via Multi-Agent Conversation, by Wu, et. al. In the rest of this notebook, you will:
- Define the agents' tools to access the web and write files
- Define some utilities to help create the graph and agents
- Create and define each team (web research + doc writing)
- Compose everything together.
But before all of that, some setup:
# %%capture --no-stderr
# %pip install -U langgraph langchain langchain_openai langchain_experimental
import getpass
import os
import uuid
def _set_if_undefined(var: str):
if not os.environ.get(var):
os.environ[var] = getpass(f"Please provide your {var}")
_set_if_undefined("OPENAI_API_KEY")
_set_if_undefined("LANGCHAIN_API_KEY")
_set_if_undefined("TAVILY_API_KEY")
# Optional, add tracing in LangSmith.
# This will help you visualize and debug the control flow
os.environ["LANGCHAIN_TRACING_V2"] = "true"
os.environ["LANGCHAIN_PROJECT"] = "Multi-agent Collaboration"
Create Tools¶
Each team will be composed of one or more agents each with one or more tools. Below, define all the tools to be used by your different teams.
We'll start with the research team.
Research team tools
The research team can use a search engine and url scraper to find information on the web. Feel free to add additional functionality below to boost the team performance!
from typing import Annotated, List, Tuple, Union
import matplotlib.pyplot as plt
from langchain_community.document_loaders import WebBaseLoader
from langchain_community.tools.tavily_search import TavilySearchResults
from langchain_core.tools import tool
from langsmith import trace
tavily_tool = TavilySearchResults(max_results=5)
@tool
def scrape_webpages(urls: List[str]) -> str:
"""Use requests and bs4 to scrape the provided web pages for detailed information."""
loader = WebBaseLoader(urls)
docs = loader.load()
return "\n\n".join(
[
f'<Document name="{doc.metadata.get("title", "")}">\n{doc.page_content}\n</Document>'
for doc in docs
]
)
Document writing team tools
Next up, we will give some tools for the doc writing team to use. We define some bare-bones file-access tools below.
Note that this gives the agents access to your file-system, which can be unsafe. We also haven't optimized the tool descriptions for performance.
from pathlib import Path
from tempfile import TemporaryDirectory
from typing import Dict, Optional
from langchain_experimental.utilities import PythonREPL
from typing_extensions import TypedDict
_TEMP_DIRECTORY = TemporaryDirectory()
WORKING_DIRECTORY = Path(_TEMP_DIRECTORY.name)
@tool
def create_outline(
points: Annotated[List[str], "List of main points or sections."],
file_name: Annotated[str, "File path to save the outline."],
) -> Annotated[str, "Path of the saved outline file."]:
"""Create and save an outline."""
with (WORKING_DIRECTORY / file_name).open("w") as file:
for i, point in enumerate(points):
file.write(f"{i + 1}. {point}\n")
return f"Outline saved to {file_name}"
@tool
def read_document(
file_name: Annotated[str, "File path to save the document."],
start: Annotated[Optional[int], "The start line. Default is 0"] = None,
end: Annotated[Optional[int], "The end line. Default is None"] = None,
) -> str:
"""Read the specified document."""
with (WORKING_DIRECTORY / file_name).open("r") as file:
lines = file.readlines()
if start is not None:
start = 0
return "\n".join(lines[start:end])
@tool
def write_document(
content: Annotated[str, "Text content to be written into the document."],
file_name: Annotated[str, "File path to save the document."],
) -> Annotated[str, "Path of the saved document file."]:
"""Create and save a text document."""
with (WORKING_DIRECTORY / file_name).open("w") as file:
file.write(content)
return f"Document saved to {file_name}"
@tool
def edit_document(
file_name: Annotated[str, "Path of the document to be edited."],
inserts: Annotated[
Dict[int, str],
"Dictionary where key is the line number (1-indexed) and value is the text to be inserted at that line.",
],
) -> Annotated[str, "Path of the edited document file."]:
"""Edit a document by inserting text at specific line numbers."""
with (WORKING_DIRECTORY / file_name).open("r") as file:
lines = file.readlines()
sorted_inserts = sorted(inserts.items())
for line_number, text in sorted_inserts:
if 1 <= line_number <= len(lines) + 1:
lines.insert(line_number - 1, text + "\n")
else:
return f"Error: Line number {line_number} is out of range."
with (WORKING_DIRECTORY / file_name).open("w") as file:
file.writelines(lines)
return f"Document edited and saved to {file_name}"
# Warning: This executes code locally, which can be unsafe when not sandboxed
repl = PythonREPL()
@tool
def python_repl(
code: Annotated[str, "The python code to execute to generate your chart."]
):
"""Use this to execute python code. If you want to see the output of a value,
you should print it out with `print(...)`. This is visible to the user."""
try:
result = repl.run(code)
except BaseException as e:
return f"Failed to execute. Error: {repr(e)}"
return f"Successfully executed:\n```python\n{code}\n```\nStdout: {result}"
Helper Utilities¶
We are going to create a few utility functions to make it more concise when we want to:
- Create a worker agent.
- Create a supervisor for the sub-graph.
These will simplify the graph compositional code at the end for us so it's easier to see what's going on.
from typing import Any, Callable, List, Optional, TypedDict, Union
from langchain.agents import AgentExecutor, create_openai_functions_agent
from langchain.output_parsers.openai_functions import JsonOutputFunctionsParser
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
from langchain_core.runnables import Runnable
from langchain_core.tools import BaseTool
from langchain_openai import ChatOpenAI
from langgraph.graph import END, StateGraph
def create_agent(
llm: ChatOpenAI,
tools: list,
system_prompt: str,
) -> str:
"""Create a function-calling agent and add it to the graph."""
system_prompt += "\nWork autonomously according to your specialty, using the tools available to you."
" Do not ask for clarification."
" Your other team members (and other teams) will collaborate with you with their own specialties."
" You are chosen for a reason! You are one of the following team members: {team_members}."
prompt = ChatPromptTemplate.from_messages(
[
(
"system",
system_prompt,
),
MessagesPlaceholder(variable_name="messages"),
MessagesPlaceholder(variable_name="agent_scratchpad"),
]
)
agent = create_openai_functions_agent(llm, tools, prompt)
executor = AgentExecutor(agent=agent, tools=tools)
return executor
def agent_node(state, agent, name):
result = agent.invoke(state)
return {"messages": [HumanMessage(content=result["output"], name=name)]}
def create_team_supervisor(llm: ChatOpenAI, system_prompt, members) -> str:
"""An LLM-based router."""
options = ["FINISH"] + members
function_def = {
"name": "route",
"description": "Select the next role.",
"parameters": {
"title": "routeSchema",
"type": "object",
"properties": {
"next": {
"title": "Next",
"anyOf": [
{"enum": options},
],
},
},
"required": ["next"],
},
}
prompt = ChatPromptTemplate.from_messages(
[
("system", system_prompt),
MessagesPlaceholder(variable_name="messages"),
(
"system",
"Given the conversation above, who should act next?"
" Or should we FINISH? Select one of: {options}",
),
]
).partial(options=str(options), team_members=", ".join(members))
return (
prompt
| llm.bind_functions(functions=[function_def], function_call="route")
| JsonOutputFunctionsParser()
)
import functools
import operator
from langchain_core.messages import AIMessage, BaseMessage, HumanMessage
from langchain_openai.chat_models import ChatOpenAI
import functools
# Research team graph state
class ResearchTeamState(TypedDict):
# A message is added after each team member finishes
messages: Annotated[List[BaseMessage], operator.add]
# The team members are tracked so they are aware of
# the others' skill-sets
team_members: List[str]
# Used to route work. The supervisor calls a function
# that will update this every time it makes a decision
next: str
llm = ChatOpenAI(model="gpt-4-1106-preview")
search_agent = create_agent(
llm,
[tavily_tool],
"You are a research assistant who can search for up-to-date info using the tavily search engine.",
)
search_node = functools.partial(agent_node, agent=search_agent, name="Search")
research_agent = create_agent(
llm,
[scrape_webpages],
"You are a research assistant who can scrape specified urls for more detailed information using the scrape_webpages function.",
)
research_node = functools.partial(agent_node, agent=research_agent, name="Web Scraper")
supervisor_agent = create_team_supervisor(
llm,
"You are a supervisor tasked with managing a conversation between the"
" following workers: Search, Web Scraper. Given the following user request,"
" respond with the worker to act next. Each worker will perform a"
" task and respond with their results and status. When finished,"
" respond with FINISH.",
["Search", "Web Scraper"],
)
Now that we've created the necessary components, defining their interactions is easy. Add the nodes to the team graph, and define the edges, which determine the transition criteria.
research_graph = StateGraph(ResearchTeamState)
research_graph.add_node("Search", search_node)
research_graph.add_node("Web Scraper", research_node)
research_graph.add_node("supervisor", supervisor_agent)
# Define the control flow
research_graph.add_edge("Search", "supervisor")
research_graph.add_edge("Web Scraper", "supervisor")
research_graph.add_conditional_edges(
"supervisor",
lambda x: x["next"],
{"Search": "Search", "Web Scraper": "Web Scraper", "FINISH": END},
)
research_graph.set_entry_point("supervisor")
chain = research_graph.compile()
# The following functions interoperate between the top level graph state
# and the state of the research sub-graph
# this makes it so that the states of each graph don't get intermixed
def enter_chain(message: str):
results = {
"messages": [HumanMessage(content=message)],
}
return results
research_chain = enter_chain | chain
We can give this team work directly. Try it out below.
for s in research_chain.stream(
"when is Taylor Swift's next tour?", {"recursion_limit": 100}
):
if "__end__" not in s:
print(s)
print("---")
{'supervisor': {'next': 'Search'}}
---
{'Search': {'messages': [HumanMessage(content='Taylor Swift\'s next tour, named "The Eras Tour," has dates scheduled for both 2023 and 2024. Some of the upcoming dates mentioned in the search results include:\n\n- November 25-26, 2023, in São Paulo, Brazil at the Allianz Parque\n- February 7-9, 2024, in Tokyo, Japan at the Tokyo Dome\n\nFor a complete and detailed list of all the dates and locations for Taylor Swift\'s "The Eras Tour," you would need to visit official sources or ticketing websites such as Ticketmaster, as the search results suggest additional dates have been added due to overwhelming demand. The tour is set to wrap up in Indianapolis on November 3, 2024. Keep in mind that the schedule may be subject to change, and it\'s a good idea to verify the dates on an official ticketing or event site for the latest information.', name='Search')]}}
---
{'supervisor': {'next': 'FINISH'}}
---
Document Writing Team¶
Create the document writing team below using a similar approach. This time, we will give each agent access to different file-writing tools.
Note that we are giving file-system access to our agent here, which is not safe in all cases.
import operator
from pathlib import Path
# Document writing team graph state
class DocWritingState(TypedDict):
# This tracks the team's conversation internally
messages: Annotated[List[BaseMessage], operator.add]
# This provides each worker with context on the others' skill sets
team_members: str
# This is how the supervisor tells langgraph who to work next
next: str
# This tracks the shared directory state
current_files: str
# This will be run before each worker agent begins work
# It makes it so they are more aware of the current state
# of the working directory.
def prelude(state):
written_files = []
if not WORKING_DIRECTORY.exists():
WORKING_DIRECTORY.mkdir()
try:
written_files = [
f.relative_to(WORKING_DIRECTORY) for f in WORKING_DIRECTORY.rglob("*")
]
except:
pass
if not written_files:
return {**state, "current_files": "No files written."}
return {
**state,
"current_files": "\nBelow are files your team has written to the directory:\n"
+ "\n".join([f" - {f}" for f in written_files]),
}
llm = ChatOpenAI(model="gpt-4-1106-preview")
doc_writer_agent = create_agent(
llm,
[write_document, edit_document, read_document],
"You are an expert writing a research document.\n"
# The {current_files} value is populated automatically by the graph state
"Below are files currently in your directory:\n{current_files}",
)
# Injects current directory working state before each call
context_aware_doc_writer_agent = prelude | doc_writer_agent
doc_writing_node = functools.partial(
agent_node, agent=context_aware_doc_writer_agent, name="DocWriter"
)
note_taking_agent = create_agent(
llm,
[create_outline, read_document],
"You are an expert senior researcher tasked with writing a paper outline and"
" taking notes to craft a perfect paper.{current_files}",
)
context_aware_note_taking_agent = prelude | note_taking_agent
note_taking_node = functools.partial(
agent_node, agent=context_aware_note_taking_agent, name="NoteTaker"
)
chart_generating_agent = create_agent(
llm,
[read_document, python_repl],
"You are a data viz expert tasked with generating charts for a research project."
"{current_files}",
)
context_aware_chart_generating_agent = prelude | chart_generating_agent
chart_generating_node = functools.partial(
agent_node, agent=context_aware_note_taking_agent, name="ChartGenerator"
)
doc_writing_supervisor = create_team_supervisor(
llm,
"You are a supervisor tasked with managing a conversation between the"
" following workers: {team_members}. Given the following user request,"
" respond with the worker to act next. Each worker will perform a"
" task and respond with their results and status. When finished,"
" respond with FINISH.",
["DocWriter", "NoteTaker", "ChartGenerator"],
)
With the objects themselves created, we can form the graph.
# Create the graph here:
# Note that we have unrolled the loop for the sake of this doc
authoring_graph = StateGraph(DocWritingState)
authoring_graph.add_node("DocWriter", doc_writing_node)
authoring_graph.add_node("NoteTaker", note_taking_node)
authoring_graph.add_node("ChartGenerator", chart_generating_node)
authoring_graph.add_node("supervisor", doc_writing_supervisor)
# Add the edges that always occur
authoring_graph.add_edge("DocWriter", "supervisor")
authoring_graph.add_edge("NoteTaker", "supervisor")
authoring_graph.add_edge("ChartGenerator", "supervisor")
# Add the edges where routing applies
authoring_graph.add_conditional_edges(
"supervisor",
lambda x: x["next"],
{
"DocWriter": "DocWriter",
"NoteTaker": "NoteTaker",
"ChartGenerator": "ChartGenerator",
"FINISH": END,
},
)
authoring_graph.set_entry_point("supervisor")
chain = authoring_graph.compile()
# The following functions interoperate between the top level graph state
# and the state of the research sub-graph
# this makes it so that the states of each graph don't get intermixed
def enter_chain(message: str, members: List[str]):
results = {
"messages": [HumanMessage(content=message)],
"team_members": ", ".join(members),
}
return results
# We reuse the enter/exit functions to wrap the graph
authoring_chain = (
functools.partial(enter_chain, members=authoring_graph.nodes)
| authoring_graph.compile()
)
for s in authoring_chain.stream(
"Write an outline for poem and then write the poem to disk.",
{"recursion_limit": 100},
):
if "__end__" not in s:
print(s)
print("---")
{'supervisor': {'next': 'NoteTaker'}}
---
{'NoteTaker': {'messages': [HumanMessage(content='The outline and poem have been successfully written and saved. The poem, titled "Whispers of the Wind," captures the essence of the wind\'s journey from a gentle beginning to a powerful crescendo and then a calming end, concluding with the cyclical nature of this elemental force.\n\nHere is the completed poem:\n\n---\n\n**Whispers of the Wind**\n\nEmbracing the essence of nature\'s breath,\nA zephyr stirs, the dawn\'s own cheer,\nWhispering secrets, meant for no ear,\nThe gentle beginnings, a soft caress.\n\nA gale ascends, midday\'s fierce guest,\nTwirling leaves in a wild, untamed dance,\nNature\'s raw power in its vast expanse,\nThe crescendo of gusts, a forceful dance.\n\nAs dusk falls, the tempest does wane,\nA soft sighing through the willow\'s mane,\nIn the quietude, peace finds its chance,\nThe calming aftermath, a serene trance.\n\nThrough whispers, roars, and silent chants,\nThe wind carries on, no pause nor glance,\nIn its journey, a boundless, spirited lance,\nThe enduring cycle, a timeless romance.\n\n---\n\nThe poem is a testament to the wind\'s ever-present and ever-changing presence in the world around us.', name='NoteTaker')]}}
---
{'supervisor': {'next': 'FINISH'}}
---
Add Layers¶
In this design, we are enforcing a top-down planning policy. We've created two graphs already, but we have to decide how to route work between the two.
We'll create a third graph to orchestrate the previous two, and add some connectors to define how this top-level state is shared between the different graphs.
from langchain_core.messages import AIMessage, BaseMessage, HumanMessage
from langchain_openai.chat_models import ChatOpenAI
llm = ChatOpenAI(model="gpt-4-1106-preview")
supervisor_node = create_team_supervisor(
llm,
"You are a supervisor tasked with managing a conversation between the"
" following teams: {team_members}. Given the following user request,"
" respond with the worker to act next. Each worker will perform a"
" task and respond with their results and status. When finished,"
" respond with FINISH.",
["Research team", "Paper writing team"],
)
# Top-level graph state
class State(TypedDict):
messages: Annotated[List[BaseMessage], operator.add]
next: str
def get_last_message(state: State) -> str:
return state["messages"][-1].content
def join_graph(response: dict):
return {"messages": [response["messages"][-1]]}
# Define the graph.
super_graph = StateGraph(State)
# First add the nodes, which will do the work
super_graph.add_node("Research team", get_last_message | research_chain | join_graph)
super_graph.add_node(
"Paper writing team", get_last_message | authoring_chain | join_graph
)
super_graph.add_node("supervisor", supervisor_node)
# Define the graph connections, which controls how the logic
# propagates through the program
super_graph.add_edge("Research team", "supervisor")
super_graph.add_edge("Paper writing team", "supervisor")
super_graph.add_conditional_edges(
"supervisor",
lambda x: x["next"],
{
"Paper writing team": "Paper writing team",
"Research team": "Research team",
"FINISH": END,
},
)
super_graph.set_entry_point("supervisor")
super_graph = super_graph.compile()
for s in super_graph.stream(
{
"messages": [
HumanMessage(
content="Write a brief research report on the North American sturgeon. Include a chart."
)
],
},
{"recursion_limit": 150},
):
if "__end__" not in s:
print(s)
print("---")
{'supervisor': {'next': 'Research team'}}
---
{'Research team': {'messages': [HumanMessage(content='Based on the information gathered from the provided URLs, here is a detailed research report on the North American sturgeon along with a chart that summarizes some of the key data:\n\n**North American Sturgeon Research Report**\n\n**Overview:**\nNorth American sturgeons are ancient fish that belong to the Acipenseridae family. These bony, bottom-dwelling fish are characterized by their elongated bodies, scutes (bony plates), and barbels near the mouth. They are anadromous, meaning they migrate from saltwater to freshwater to spawn.\n\n**Species and Distribution:**\n- Atlantic Sturgeon (*Acipenser oxyrinchus*): Found along the East Coast from Canada to Florida.\n- Green Sturgeon (*Acipenser medirostris*): Found on the West Coast from Alaska to California.\n- Shortnose Sturgeon (*Acipenser brevirostrum*): Distributed along the East Coast in estuarine and riverine habitats.\n\n**Conservation Status:**\n- Atlantic Sturgeon: Multiple distinct population segments (DPSs) listed as endangered or threatened under the Endangered Species Act (ESA).\n- Green Sturgeon: Southern DPS listed as threatened under the ESA.\n- Shortnose Sturgeon: Listed as endangered throughout its range under the ESA.\n\n**Threats:**\n- Bycatch in commercial fisheries.\n- Habitat degradation and loss due to dams, pollution, and development.\n- Climate change affecting water temperatures and spawning conditions.\n- Vessel strikes, particularly for Atlantic sturgeon in high-traffic rivers.\n\n**Conservation Efforts:**\nEfforts include habitat restoration, removal of barriers to improve fish passage, protection from bycatch, and public education. Critical habitat has been designated for certain species, and regulations prohibit the retention of green sturgeon in recreational and commercial fisheries.\n\n**Chart Information:**\nThe chart would include species names, conservation status, geographic distribution, and key threats.\n\n| Species | Conservation Status | Distribution | Key Threats |\n|---------------------|---------------------|-------------------------------------|------------------------------------------------|\n| Atlantic Sturgeon | Endangered/Threatened | East Coast (Canada to Florida) | Bycatch, habitat loss, vessel strikes |\n| Green Sturgeon | Southern DPS Threatened | West Coast (Alaska to California) | Bycatch, habitat degradation, climate change |\n| Shortnose Sturgeon | Endangered | East Coast estuarine and riverine habitats | Bycatch, habitat degradation, dams |\n\n**Conclusion:**\nNorth American sturgeons face numerous threats that have led to a decline in their populations. However, ongoing conservation efforts, including habitat restoration and protective regulations, are crucial in supporting their recovery and ensuring the survival of these ancient and ecologically important species.', name='Web Scraper')]}}
---
{'supervisor': {'next': 'Research team'}}
---
{'Research team': {'messages': [HumanMessage(content='Based on the information gathered from the provided URLs, here is a detailed research report on the North American sturgeon along with a chart that summarizes some of the key data:\n\n**North American Sturgeon Research Report**\n\n**Overview:**\nNorth American sturgeons are ancient fish that belong to the Acipenseridae family. These bony, bottom-dwelling fish are characterized by their elongated bodies, scutes (bony plates), and barbels near the mouth. They are anadromous, meaning they migrate from saltwater to freshwater to spawn.\n\n**Species and Distribution:**\n- Atlantic Sturgeon (*Acipenser oxyrinchus*): Found along the East Coast from Canada to Florida.\n- Green Sturgeon (*Acipenser medirostris*): Found on the West Coast from Alaska to California.\n- Shortnose Sturgeon (*Acipenser brevirostrum*): Distributed along the East Coast in estuarine and riverine habitats.\n\n**Conservation Status:**\n- Atlantic Sturgeon: Multiple distinct population segments (DPSs) listed as endangered or threatened under the Endangered Species Act (ESA).\n- Green Sturgeon: Southern DPS listed as threatened under the ESA.\n- Shortnose Sturgeon: Listed as endangered throughout its range under the ESA.\n\n**Threats:**\n- Bycatch in commercial fisheries.\n- Habitat degradation and loss due to dams, pollution, and development.\n- Climate change affecting water temperatures and spawning conditions.\n- Vessel strikes, particularly for Atlantic sturgeon in high-traffic rivers.\n\n**Conservation Efforts:**\nEfforts include habitat restoration, removal of barriers to improve fish passage, protection from bycatch, and public education. Critical habitat has been designated for certain species, and regulations prohibit the retention of green sturgeon in recreational and commercial fisheries.\n\n**Chart Information:**\nThe chart would include species names, conservation status, geographic distribution, and key threats.\n\n| Species | Conservation Status | Distribution | Key Threats |\n|---------------------|---------------------|-------------------------------------|------------------------------------------------|\n| Atlantic Sturgeon | Endangered/Threatened | East Coast (Canada to Florida) | Bycatch, habitat loss, vessel strikes |\n| Green Sturgeon | Southern DPS Threatened | West Coast (Alaska to California) | Bycatch, habitat degradation, climate change |\n| Shortnose Sturgeon | Endangered | East Coast estuarine and riverine habitats | Bycatch, habitat degradation, dams |\n\n**Conclusion:**\nNorth American sturgeons face numerous threats that have led to a decline in their populations. However, ongoing conservation efforts, including habitat restoration and protective regulations, are crucial in supporting their recovery and ensuring the survival of these ancient and ecologically important species.')]}}
---
{'supervisor': {'next': 'Research team'}}
---
{'Research team': {'messages': [HumanMessage(content='Based on the information gathered from the provided URLs, here is a detailed research report on the North American sturgeon along with a chart that summarizes some of the key data:\n\n**North American Sturgeon Research Report**\n\n**Overview:**\nNorth American sturgeons are ancient fish that belong to the Acipenseridae family. These bony, bottom-dwelling fish are characterized by their elongated bodies, scutes (bony plates), and barbels near the mouth. They are anadromous, meaning they migrate from saltwater to freshwater to spawn.\n\n**Species and Distribution:**\n- Atlantic Sturgeon (*Acipenser oxyrinchus*): Found along the East Coast from Canada to Florida.\n- Green Sturgeon (*Acipenser medirostris*): Found on the West Coast from Alaska to California.\n- Shortnose Sturgeon (*Acipenser brevirostrum*): Distributed along the East Coast in estuarine and riverine habitats.\n\n**Conservation Status:**\n- Atlantic Sturgeon: Multiple distinct population segments (DPSs) listed as endangered or threatened under the Endangered Species Act (ESA).\n- Green Sturgeon: Southern DPS listed as threatened under the ESA.\n- Shortnose Sturgeon: Listed as endangered throughout its range under the ESA.\n\n**Threats:**\n- Bycatch in commercial fisheries.\n- Habitat degradation and loss due to dams, pollution, and development.\n- Climate change affecting water temperatures and spawning conditions.\n- Vessel strikes, particularly for Atlantic sturgeon in high-traffic rivers.\n\n**Conservation Efforts:**\nEfforts include habitat restoration, removal of barriers to improve fish passage, protection from bycatch, and public education. Critical habitat has been designated for certain species, and regulations prohibit the retention of green sturgeon in recreational and commercial fisheries.\n\n**Chart Information:**\nThe chart would include species names, conservation status, geographic distribution, and key threats.\n\n| Species | Conservation Status | Distribution | Key Threats |\n|---------------------|---------------------|-------------------------------------|------------------------------------------------|\n| Atlantic Sturgeon | Endangered/Threatened | East Coast (Canada to Florida) | Bycatch, habitat loss, vessel strikes |\n| Green Sturgeon | Southern DPS Threatened | West Coast (Alaska to California) | Bycatch, habitat degradation, climate change |\n| Shortnose Sturgeon | Endangered | East Coast estuarine and riverine habitats | Bycatch, habitat degradation, dams |\n\n**Conclusion:**\nNorth American sturgeons face numerous threats that have led to a decline in their populations. However, ongoing conservation efforts, including habitat restoration and protective regulations, are crucial in supporting their recovery and ensuring the survival of these ancient and ecologically important species.')]}}
---
{'supervisor': {'next': 'Research team'}}
---
{'Research team': {'messages': [HumanMessage(content='Based on the information gathered from the provided URLs, here is a detailed research report on the North American sturgeon along with a chart that summarizes some of the key data:\n\n**North American Sturgeon Research Report**\n\n**Overview:**\nNorth American sturgeons are ancient fish that belong to the Acipenseridae family. These bony, bottom-dwelling fish are characterized by their elongated bodies, scutes (bony plates), and barbels near the mouth. They are anadromous, meaning they migrate from saltwater to freshwater to spawn.\n\n**Species and Distribution:**\n- Atlantic Sturgeon (*Acipenser oxyrinchus*): Found along the East Coast from Canada to Florida.\n- Green Sturgeon (*Acipenser medirostris*): Found on the West Coast from Alaska to California.\n- Shortnose Sturgeon (*Acipenser brevirostrum*): Distributed along the East Coast in estuarine and riverine habitats.\n\n**Conservation Status:**\n- Atlantic Sturgeon: Multiple distinct population segments (DPSs) listed as endangered or threatened under the Endangered Species Act (ESA).\n- Green Sturgeon: Southern DPS listed as threatened under the ESA.\n- Shortnose Sturgeon: Listed as endangered throughout its range under the ESA.\n\n**Threats:**\n- Bycatch in commercial fisheries.\n- Habitat degradation and loss due to dams, pollution, and development.\n- Climate change affecting water temperatures and spawning conditions.\n- Vessel strikes, particularly for Atlantic sturgeon in high-traffic rivers.\n\n**Conservation Efforts:**\nEfforts include habitat restoration, removal of barriers to improve fish passage, protection from bycatch, and public education. Critical habitat has been designated for certain species, and regulations prohibit the retention of green sturgeon in recreational and commercial fisheries.\n\n**Chart Information:**\nThe chart would include species names, conservation status, geographic distribution, and key threats.\n\n| Species | Conservation Status | Distribution | Key Threats |\n|---------------------|---------------------|-------------------------------------|------------------------------------------------|\n| Atlantic Sturgeon | Endangered/Threatened | East Coast (Canada to Florida) | Bycatch, habitat loss, vessel strikes |\n| Green Sturgeon | Southern DPS Threatened | West Coast (Alaska to California) | Bycatch, habitat degradation, climate change |\n| Shortnose Sturgeon | Endangered | East Coast estuarine and riverine habitats | Bycatch, habitat degradation, dams |\n\n**Conclusion:**\nNorth American sturgeons face numerous threats that have led to a decline in their populations. However, ongoing conservation efforts, including habitat restoration and protective regulations, are crucial in supporting their recovery and ensuring the survival of these ancient and ecologically important species.')]}}
---
{'supervisor': {'next': 'Research team'}}
---
{'Research team': {'messages': [HumanMessage(content='Based on the information gathered from the provided URLs, here is a detailed research report on the North American sturgeon along with a chart that summarizes some of the key data:\n\n**North American Sturgeon Research Report**\n\n**Overview:**\nNorth American sturgeons are ancient fish that belong to the Acipenseridae family. These bony, bottom-dwelling fish are characterized by their elongated bodies, scutes (bony plates), and barbels near the mouth. They are anadromous, meaning they migrate from saltwater to freshwater to spawn.\n\n**Species and Distribution:**\n- Atlantic Sturgeon (*Acipenser oxyrinchus*): Found along the East Coast from Canada to Florida.\n- Green Sturgeon (*Acipenser medirostris*): Found on the West Coast from Alaska to California.\n- Shortnose Sturgeon (*Acipenser brevirostrum*): Distributed along the East Coast in estuarine and riverine habitats.\n\n**Conservation Status:**\n- Atlantic Sturgeon: Multiple distinct population segments (DPSs) listed as endangered or threatened under the Endangered Species Act (ESA).\n- Green Sturgeon: Southern DPS listed as threatened under the ESA.\n- Shortnose Sturgeon: Listed as endangered throughout its range under the ESA.\n\n**Threats:**\n- Bycatch in commercial fisheries.\n- Habitat degradation and loss due to dams, pollution, and development.\n- Climate change affecting water temperatures and spawning conditions.\n- Vessel strikes, particularly for Atlantic sturgeon in high-traffic rivers.\n\n**Conservation Efforts:**\nEfforts include habitat restoration, removal of barriers to improve fish passage, protection from bycatch, and public education. Critical habitat has been designated for certain species, and regulations prohibit the retention of green sturgeon in recreational and commercial fisheries.\n\n**Chart Information:**\nThe chart would include species names, conservation status, geographic distribution, and key threats.\n\n| Species | Conservation Status | Distribution | Key Threats |\n|---------------------|---------------------|-------------------------------------|------------------------------------------------|\n| Atlantic Sturgeon | Endangered/Threatened | East Coast (Canada to Florida) | Bycatch, habitat loss, vessel strikes |\n| Green Sturgeon | Southern DPS Threatened | West Coast (Alaska to California) | Bycatch, habitat degradation, climate change |\n| Shortnose Sturgeon | Endangered | East Coast estuarine and riverine habitats | Bycatch, habitat degradation, dams |\n\n**Conclusion:**\nNorth American sturgeons face numerous threats that have led to a decline in their populations. However, ongoing conservation efforts, including habitat restoration and protective regulations, are crucial in supporting their recovery and ensuring the survival of these ancient and ecologically important species.')]}}
---
{'supervisor': {'next': 'Research team'}}
---
{'Research team': {'messages': [HumanMessage(content='Based on the information gathered from the provided URLs, here is a detailed research report on the North American sturgeon along with a chart that summarizes some of the key data:\n\n**North American Sturgeon Research Report**\n\n**Overview:**\nNorth American sturgeons are ancient fish that belong to the Acipenseridae family. These bony, bottom-dwelling fish are characterized by their elongated bodies, scutes (bony plates), and barbels near the mouth. They are anadromous, meaning they migrate from saltwater to freshwater to spawn.\n\n**Species and Distribution:**\n- Atlantic Sturgeon (*Acipenser oxyrinchus*): Found along the East Coast from Canada to Florida.\n- Green Sturgeon (*Acipenser medirostris*): Found on the West Coast from Alaska to California.\n- Shortnose Sturgeon (*Acipenser brevirostrum*): Distributed along the East Coast in estuarine and riverine habitats.\n\n**Conservation Status:**\n- Atlantic Sturgeon: Multiple distinct population segments (DPSs) listed as endangered or threatened under the Endangered Species Act (ESA).\n- Green Sturgeon: Southern DPS listed as threatened under the ESA.\n- Shortnose Sturgeon: Listed as endangered throughout its range under the ESA.\n\n**Threats:**\n- Bycatch in commercial fisheries.\n- Habitat degradation and loss due to dams, pollution, and development.\n- Climate change affecting water temperatures and spawning conditions.\n- Vessel strikes, particularly for Atlantic sturgeon in high-traffic rivers.\n\n**Conservation Efforts:**\nEfforts include habitat restoration, removal of barriers to improve fish passage, protection from bycatch, and public education. Critical habitat has been designated for certain species, and regulations prohibit the retention of green sturgeon in recreational and commercial fisheries.\n\n**Chart Information:**\nThe chart would include species names, conservation status, geographic distribution, and key threats.\n\n| Species | Conservation Status | Distribution | Key Threats |\n|---------------------|---------------------|-------------------------------------|------------------------------------------------|\n| Atlantic Sturgeon | Endangered/Threatened | East Coast (Canada to Florida) | Bycatch, habitat loss, vessel strikes |\n| Green Sturgeon | Southern DPS Threatened | West Coast (Alaska to California) | Bycatch, habitat degradation, climate change |\n| Shortnose Sturgeon | Endangered | East Coast estuarine and riverine habitats | Bycatch, habitat degradation, dams |\n\n**Conclusion:**\nNorth American sturgeons face numerous threats that have led to a decline in their populations. However, ongoing conservation efforts, including habitat restoration and protective regulations, are crucial in supporting their recovery and ensuring the survival of these ancient and ecologically important species.')]}}
---
{'supervisor': {'next': 'Research team'}}
---
{'Research team': {'messages': [HumanMessage(content='Based on the information gathered from the provided URLs, here is a detailed research report on the North American sturgeon along with a chart that summarizes some of the key data:\n\n**North American Sturgeon Research Report**\n\n**Overview:**\nNorth American sturgeons are ancient fish that belong to the Acipenseridae family. These bony, bottom-dwelling fish are characterized by their elongated bodies, scutes (bony plates), and barbels near the mouth. They are anadromous, meaning they migrate from saltwater to freshwater to spawn.\n\n**Species and Distribution:**\n- Atlantic Sturgeon (*Acipenser oxyrinchus*): Found along the East Coast from Canada to Florida.\n- Green Sturgeon (*Acipenser medirostris*): Found on the West Coast from Alaska to California.\n- Shortnose Sturgeon (*Acipenser brevirostrum*): Distributed along the East Coast in estuarine and riverine habitats.\n\n**Conservation Status:**\n- Atlantic Sturgeon: Multiple distinct population segments (DPSs) listed as endangered or threatened under the Endangered Species Act (ESA).\n- Green Sturgeon: Southern DPS listed as threatened under the ESA.\n- Shortnose Sturgeon: Listed as endangered throughout its range under the ESA.\n\n**Threats:**\n- Bycatch in commercial fisheries.\n- Habitat degradation and loss due to dams, pollution, and development.\n- Climate change affecting water temperatures and spawning conditions.\n- Vessel strikes, particularly for Atlantic sturgeon in high-traffic rivers.\n\n**Conservation Efforts:**\nEfforts include habitat restoration, removal of barriers to improve fish passage, protection from bycatch, and public education. Critical habitat has been designated for certain species, and regulations prohibit the retention of green sturgeon in recreational and commercial fisheries.\n\n**Chart Information:**\nThe chart would include species names, conservation status, geographic distribution, and key threats.\n\n| Species | Conservation Status | Distribution | Key Threats |\n|---------------------|---------------------|-------------------------------------|------------------------------------------------|\n| Atlantic Sturgeon | Endangered/Threatened | East Coast (Canada to Florida) | Bycatch, habitat loss, vessel strikes |\n| Green Sturgeon | Southern DPS Threatened | West Coast (Alaska to California) | Bycatch, habitat degradation, climate change |\n| Shortnose Sturgeon | Endangered | East Coast estuarine and riverine habitats | Bycatch, habitat degradation, dams |\n\n**Conclusion:**\nNorth American sturgeons face numerous threats that have led to a decline in their populations. However, ongoing conservation efforts, including habitat restoration and protective regulations, are crucial in supporting their recovery and ensuring the survival of these ancient and ecologically important species.')]}}
---
{'supervisor': {'next': 'Research team'}}
---
{'Research team': {'messages': [HumanMessage(content='Based on the information gathered from the provided URLs, here is a detailed research report on the North American sturgeon along with a chart that summarizes some of the key data:\n\n**North American Sturgeon Research Report**\n\n**Overview:**\nNorth American sturgeons are ancient fish that belong to the Acipenseridae family. These bony, bottom-dwelling fish are characterized by their elongated bodies, scutes (bony plates), and barbels near the mouth. They are anadromous, meaning they migrate from saltwater to freshwater to spawn.\n\n**Species and Distribution:**\n- Atlantic Sturgeon (*Acipenser oxyrinchus*): Found along the East Coast from Canada to Florida.\n- Green Sturgeon (*Acipenser medirostris*): Found on the West Coast from Alaska to California.\n- Shortnose Sturgeon (*Acipenser brevirostrum*): Distributed along the East Coast in estuarine and riverine habitats.\n\n**Conservation Status:**\n- Atlantic Sturgeon: Multiple distinct population segments (DPSs) listed as endangered or threatened under the Endangered Species Act (ESA).\n- Green Sturgeon: Southern DPS listed as threatened under the ESA.\n- Shortnose Sturgeon: Listed as endangered throughout its range under the ESA.\n\n**Threats:**\n- Bycatch in commercial fisheries.\n- Habitat degradation and loss due to dams, pollution, and development.\n- Climate change affecting water temperatures and spawning conditions.\n- Vessel strikes, particularly for Atlantic sturgeon in high-traffic rivers.\n\n**Conservation Efforts:**\nEfforts include habitat restoration, removal of barriers to improve fish passage, protection from bycatch, and public education. Critical habitat has been designated for certain species, and regulations prohibit the retention of green sturgeon in recreational and commercial fisheries.\n\n**Chart Information:**\nThe chart would include species names, conservation status, geographic distribution, and key threats.\n\n| Species | Conservation Status | Distribution | Key Threats |\n|---------------------|---------------------|-------------------------------------|------------------------------------------------|\n| Atlantic Sturgeon | Endangered/Threatened | East Coast (Canada to Florida) | Bycatch, habitat loss, vessel strikes |\n| Green Sturgeon | Southern DPS Threatened | West Coast (Alaska to California) | Bycatch, habitat degradation, climate change |\n| Shortnose Sturgeon | Endangered | East Coast estuarine and riverine habitats | Bycatch, habitat degradation, dams |\n\n**Conclusion:**\nNorth American sturgeons face numerous threats that have led to a decline in their populations. However, ongoing conservation efforts, including habitat restoration and protective regulations, are crucial in supporting their recovery and ensuring the survival of these ancient and ecologically important species.')]}}
---
{'supervisor': {'next': 'Research team'}}
---
{'Research team': {'messages': [HumanMessage(content='Based on the information gathered from the provided URLs, here is a detailed research report on the North American sturgeon along with a chart that summarizes some of the key data:\n\n**North American Sturgeon Research Report**\n\n**Overview:**\nNorth American sturgeons are ancient fish that belong to the Acipenseridae family. These bony, bottom-dwelling fish are characterized by their elongated bodies, scutes (bony plates), and barbels near the mouth. They are anadromous, meaning they migrate from saltwater to freshwater to spawn.\n\n**Species and Distribution:**\n- Atlantic Sturgeon (*Acipenser oxyrinchus*): Found along the East Coast from Canada to Florida.\n- Green Sturgeon (*Acipenser medirostris*): Found on the West Coast from Alaska to California.\n- Shortnose Sturgeon (*Acipenser brevirostrum*): Distributed along the East Coast in estuarine and riverine habitats.\n\n**Conservation Status:**\n- Atlantic Sturgeon: Multiple distinct population segments (DPSs) listed as endangered or threatened under the Endangered Species Act (ESA).\n- Green Sturgeon: Southern DPS listed as threatened under the ESA.\n- Shortnose Sturgeon: Listed as endangered throughout its range under the ESA.\n\n**Threats:**\n- Bycatch in commercial fisheries.\n- Habitat degradation and loss due to dams, pollution, and development.\n- Climate change affecting water temperatures and spawning conditions.\n- Vessel strikes, particularly for Atlantic sturgeon in high-traffic rivers.\n\n**Conservation Efforts:**\nEfforts include habitat restoration, removal of barriers to improve fish passage, protection from bycatch, and public education. Critical habitat has been designated for certain species, and regulations prohibit the retention of green sturgeon in recreational and commercial fisheries.\n\n**Chart Information:**\nThe chart would include species names, conservation status, geographic distribution, and key threats.\n\n| Species | Conservation Status | Distribution | Key Threats |\n|---------------------|---------------------|-------------------------------------|------------------------------------------------|\n| Atlantic Sturgeon | Endangered/Threatened | East Coast (Canada to Florida) | Bycatch, habitat loss, vessel strikes |\n| Green Sturgeon | Southern DPS Threatened | West Coast (Alaska to California) | Bycatch, habitat degradation, climate change |\n| Shortnose Sturgeon | Endangered | East Coast estuarine and riverine habitats | Bycatch, habitat degradation, dams |\n\n**Conclusion:**\nNorth American sturgeons face numerous threats that have led to a decline in their populations. However, ongoing conservation efforts, including habitat restoration and protective regulations, are crucial in supporting their recovery and ensuring the survival of these ancient and ecologically important species.')]}}
---
{'supervisor': {'next': 'Paper writing team'}}
---
{'Paper writing team': {'messages': [HumanMessage(content='The contents of the "AnalysisOfWhispersOfTheWindPoem.txt" file have been successfully retrieved. It appears to contain the structured paper that was conceptualized earlier, including the introduction, a detailed analysis of the poem\'s structure and content, exploration of poetic devices and imagery, discussion on the philosophical and environmental implications, and the paper\'s conclusion.\n\nWith this analysis, the paper provides a comprehensive examination of the poem "Whispers of the Wind," capturing the essence of the poem\'s use of the wind as a symbol to articulate themes related to the natural world. It reflects on how the poet utilizes language and form to convey the power and beauty of nature, as well as the philosophical undertones that underscore human connection with the environment.\n\nThe conclusion of the paper emphasizes the significance of the poem in fostering a greater appreciation for nature and highlights the relevance of its message in the context of contemporary environmental discourse. This analysis serves as an important contribution to the understanding of the poem\'s artistic and thematic dimensions.', name='DocWriter')]}}
---
{'supervisor': {'next': 'Research team'}}
---
{'Research team': {'messages': [HumanMessage(content='The contents of the "AnalysisOfWhispersOfTheWindPoem.txt" file have been successfully retrieved. It appears to contain the structured paper that was conceptualized earlier, including the introduction, a detailed analysis of the poem\'s structure and content, exploration of poetic devices and imagery, discussion on the philosophical and environmental implications, and the paper\'s conclusion.\n\nWith this analysis, the paper provides a comprehensive examination of the poem "Whispers of the Wind," capturing the essence of the poem\'s use of the wind as a symbol to articulate themes related to the natural world. It reflects on how the poet utilizes language and form to convey the power and beauty of nature, as well as the philosophical undertones that underscore human connection with the environment.\n\nThe conclusion of the paper emphasizes the significance of the poem in fostering a greater appreciation for nature and highlights the relevance of its message in the context of contemporary environmental discourse. This analysis serves as an important contribution to the understanding of the poem\'s artistic and thematic dimensions.')]}}
---
{'supervisor': {'next': 'FINISH'}}
---