Agent Teams 是我们多智能体架构(2023-2025)的早期实现,使用转移/交接机制。经过两年的实验,我们发现该机制不具备可扩展性,不推荐将其用于复杂的多智能体系统。

请改用新的 Teams 架构。

我们可以组合多个智能体组成一个团队,作为统一的整体来处理任务。下面是一个简单的示例,将一个智能体转换为一个团队,以撰写关于黑客新闻头条文章的文章。

hackernews_team.py
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.hackernews import HackerNewsTools
from agno.tools.duckduckgo import DuckDuckGoTools
from agno.tools.newspaper4k import Newspaper4kTools

hn_researcher = Agent(
    name="HackerNews Researcher",
    model=OpenAIChat("gpt-4o"),
    role="Gets top stories from hackernews.",
    tools=[HackerNewsTools()],
)

web_searcher = Agent(
    name="Web Searcher",
    model=OpenAIChat("gpt-4o"),
    role="Searches the web for information on a topic",
    tools=[DuckDuckGoTools()],
    add_datetime_to_instructions=True,
)

article_reader = Agent(
    name="Article Reader",
    model=OpenAIChat("gpt-4o"),
    role="Reads articles from URLs.",
    tools=[Newspaper4kTools()],
)

hn_team = Agent(
    name="Hackernews Team",
    model=OpenAIChat("gpt-4o"),
    team=[hn_researcher, web_searcher, article_reader],
    instructions=[
        "First, search hackernews for what the user is asking about.",
        "Then, ask the article reader to read the links for the stories to get more information.",
        "Important: you must provide the article reader with the links to read.",
        "Then, ask the web searcher to search for each story to get more information.",
        "Finally, provide a thoughtful and engaging summary.",
    ],
    show_tool_calls=True,
    markdown=True,
)
hn_team.print_response("Write an article about the top 2 stories on hackernews", stream=True)

运行脚本即可查看输出。

pip install -U openai duckduckgo-search newspaper4k lxml_html_clean agno

python hackernews_team.py

如何构建 Agent Teams

  1. 为成员智能体添加 namerole 参数。
  2. 创建一个可以委派任务给团队成员的团队领导者。
  3. 像使用普通智能体一样使用您的 Agent 团队。