Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Agent Team does not work well with some other model #2213

Open
huang-sh opened this issue Feb 24, 2025 · 5 comments
Open

[Bug] Agent Team does not work well with some other model #2213

huang-sh opened this issue Feb 24, 2025 · 5 comments
Labels
bug Something isn't working

Comments

@huang-sh
Copy link

Description

According to https://docs.agno.com/agents/teams , I replace gpt-4o with other model, like Qwen, it didn't work,

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=OpenAILike(
        id="Qwen/Qwen2.5-72B-Instruct-128K",
        api_key=getenv("SILICONFLOW_API_KEY"),
        base_url="https://api.siliconflow.cn/v1"
    ),
    role="Gets top stories from hackernews.",
    tools=[HackerNewsTools()],
)

web_searcher = Agent(
    name="Web Searcher",
    model=OpenAILike(
        id="Qwen/Qwen2.5-72B-Instruct-128K",
        api_key=getenv("SILICONFLOW_API_KEY"),
        base_url="https://api.siliconflow.cn/v1"
    ),
    role="Searches the web for information on a topic",
    tools=[DuckDuckGoTools()],
    add_datetime_to_instructions=True, debug_mode=True,
)

article_reader = Agent(
    name="Article Reader",
    model=OpenAILike(
        id="Qwen/Qwen2.5-72B-Instruct-128K",
        api_key=getenv("SILICONFLOW_API_KEY"),
        base_url="https://api.siliconflow.cn/v1"
    ),
    role="Reads articles from URLs.",
    tools=[Newspaper4kTools()], debug_mode=True,
)

hn_team = Agent(
    name="Hackernews Team",
    model=OpenAILike(
        id="Qwen/Qwen2.5-72B-Instruct-128K",
        api_key=getenv("SILICONFLOW_API_KEY"),
        base_url="https://api.siliconflow.cn/v1"
    ),
    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,
    debug_mode=True,
)
hn_team.print_response("Write an article about the top 2 stories on hackernews", stream=True)

Here is output:

To write an engaging summary of the top 2 stories on HackerNews, I'll first delegate the task to the HackerNews ┃
┃ Researcher to retrieve the stories, then to the Article Reader to read and analyze them, and finally to the Web ┃
┃ Searcher to gather some additional context and information. Let's begin.                                        ┃
┃                                                                                                                 ┃
┃ <tool_call> Thank you, HackerNews Researcher. Next, I'll delegate the task to the Article Reader to read and    ┃
┃ analyze these two stories.                                                                                      ┃
┃                                                                                                                 ┃
┃ <tool_call>                                                                                                     ┃
┃                                                                                                                 ┃
┃ <tool_call> Apologies for the error. I'll correct the task description and try again.                           ┃
┃                                                                                                                 ┃
┃ <tool_call> I apologize for the repeated issues. Let me correctly call the read_article function for each URL   ┃
┃ individually.                                                                                                   ┃
┃                                                                                                                 ┃
┃ <tool_call>                                                                                                     ┃
┃                                                                                                                 ┃
┃ I apologize for the mistake. I will correctly call the transfer_task_to_article_reader function for each URL    ┃
┃ individually.                                                                                                   ┃
┃                                                                                                                 ┃
┃ <tool_call>                                                                                                     ┃
┃                                                                                                                 ┃
┃ <tool_call>                                                                                                     ┃
┃                                                                                                                 ┃
┃ I apologize for the confusion. I will now correctly call the transfer_task_to_article_reader function for each  ┃
┃ URL individually.                                                                                               ┃
┃                                                                                                                 ┃
┃               First Article: DeepSeek Open Source FlashMLA – MLA Decoding Kernel for Hopper GPUs                ┃
┃                                                                                                                 ┃
┃ <tool_call>                                                                                                     ┃
┃                                                                                                                 ┃
┃ I apologize for the repeated errors. I will now correctly call the transfer_task_to_article_reader function for ┃
┃ each URL individually.                                                                                          ┃
┃                                                                                                                 ┃
┃               First Article: DeepSeek Open Source FlashMLA – MLA Decoding Kernel for Hopper GPUs                ┃
┃                                                                                                                 ┃
┃ <tool_call>                                                                                                     ┃
┃                                                                                                                 ┃
┃ I apologize for the persistent errors. I will now correctly call the transfer_task_to_article_reader function   ┃
┃ for each URL separately.                                                                                        ┃
┃                                                                                                                 ┃
┃               First Article: DeepSeek Open Source FlashMLA – MLA Decoding Kernel for Hopper GPUs                ┃
┃                                                                                                                 ┃
┃ <tool_call>                                                                                                     ┃
┃                                                                                                                 ┃
┃ I apologize for the confusion. I will now correctly call the transfer_task_to_article_reader function for each  ┃
┃ URL separately.                                                                                                 ┃
┃                                                                                                                 ┃
┃               First Article: DeepSeek Open Source FlashMLA – MLA Decoding Kernel for Hopper GPUs                ┃
┃                                                                                                                 ┃
┃ <tool_call>                                                                                                     ┃
┃                                                                                                                 ┃
┃ I apologize for the repeated errors. I will now correctly call the transfer_task_to_article_reader function for ┃
┃ each URL individually.                                                                                          ┃
┃                                                                                                                 ┃
┃               First Article: DeepSeek Open Source FlashMLA – MLA Decoding Kernel for Hopper GPUs                ┃
┃                                                                                                                 ┃
┃ <tool_call>                                                                                                     ┃
┃                                                                                                                 ┃
┃ I apologize for the repeated issues. I will now correctly call the transfer_task_to_article_reader function for ┃
┃ each URL individually.                                                                                          ┃
┃                                                                                                                 ┃
┃               First Article: DeepSeek Open Source FlashMLA – MLA Decoding Kernel for Hopper GPUs                ┃
┃                                                                                                                 ┃
┃ <tool_call>                                                                                                     ┃
┃                                                                                                                 ┃
┃ I apologize for the confusion. Let me correct the function calls and try again.                                 ┃
┃                                                                                                                 ┃
┃               First Article: DeepSeek Open Source FlashMLA – MLA Decoding Kernel for Hopper GPUs                ┃
┃                                                                                                                 ┃
┃ <tool_call>                                                                                                     ┃
┃                                                                                                                 ┃
┃ I apologize for the repeated errors. I will now correctly call the transfer_task_to_article_reader function for ┃
┃ each URL individually.                                                                                          ┃
┃                                                                                                                 ┃
┃               First Article: DeepSeek Open Source FlashMLA – MLA Decoding Kernel for Hopper GPUs                ┃
┃                                                                                                                 ┃
┃ <tool_call>                                                                                                     ┃
┃                                                                                                                 ┃
┃ I apologize for the persistent errors. I will now correctly call the transfer_task_to_article_reader function   ┃
┃ for each URL individually.                                                                                      ┃
┃                                                                                                                 ┃
┃               First Article: DeepSeek Open Source FlashMLA – MLA Decoding Kernel for Hopper GPUs                ┃
┃                                                                                                                 ┃
┃ <tool_call>                                                                                                     ┃
┃                                                                                                                 ┃
┃ I apologize for the repeated errors. I will now correctly call the transfer_task_to_article_reader function for ┃
┃ each URL individually.                                                                                          ┃
┃                                                                                                                 ┃
┃               First Article: DeepSeek Open Source FlashMLA – MLA Decoding Kernel for Hopper GPUs                ┃
┃                                                                                                                 ┃
┃ <tool_call>                                                                                                     ┃
┃                                                                                                                 ┃
┃ I apologize for the confusion and the repeated errors. I will now correctly call the                            ┃
┃ transfer_task_to_article_reader function for each URL individually.                                             ┃
┃                                                                                                                 ┃
┃               First Article: DeepSeek Open Source FlashMLA – MLA Decoding Kernel for Hopper GPUs                ┃
┃                                                                                                                 ┃
┃ <tool_call>                                                                                                     ┃
┃                                                                                                                 ┃
┃ I apologize for the repeated errors. I will now correctly call the transfer_task_to_article_reader function for ┃
┃ each URL individually.                                                                                          ┃
┃                                                                                                                 ┃
┃               First Article: DeepSeek Open Source FlashMLA – MLA Decoding Kernel for Hopper GPUs                ┃
┃                                                                                                                 ┃
┃ <tool_call>                                                                                                     ┃
┃                                                                                                                 ┃
┃ <tool_call>                                                                                                     ┃
┃                                                                                                                 ┃
┃         Second Article: Cloudflare takes legal action over LaLiga's "disproportionate blocking efforts"         ┃
┃                                                                                                                 ┃
┃ <tool_call>                                                                                                     ┃
┃                                                                                                                 ┃
┃ <tool_call> I apologize for the errors. I will now correctly call the transfer_task_to_article_reader function  ┃
┃ for each URL separately.                                                                                        ┃
┃                                                                                                                 ┃
┃               First Article: DeepSeek Open Source FlashMLA – MLA Decoding Kernel for Hopper GPUs                ┃
┃                                                                                                                 ┃
┃ <tool_call>                                                                                                     ┃
┃                                                                                                                 ┃
┃ <tool_call>                                                                                                     ┃
┃                                                                                                                 ┃
┃         Second Article: Cloudflare takes legal action over LaLiga's "disproportionate blocking efforts"         ┃
┃                                                                                                                 ┃
┃ <tool_call>                                                                                                     ┃
┃                                                                                                                 ┃
┃ <tool_call> I apologize for the repeated errors. I will now correctly call the transfer_task_to_article_reader  ┃
┃ function for each URL individually.                                                                             ┃
┃                                                                                                                 ┃
┃               First Article: DeepSeek Open Source FlashMLA – MLA Decoding Kernel for Hopper GPUs 

Steps to Reproduce

List the steps needed to encounter this bug or issue.

Agent Configuration (if applicable)

Provide relevant agent configuration.

Expected Behavior

What did you expect to happen?

Actual Behavior

What actually happened instead?

Screenshots or Logs (if applicable)

Include any relevant screenshots or error logs that demonstrate the issue.

Environment

  • OS: Linux
  • Browser (if relevant): (e.g. Chrome 108, Firefox 107)
  • Agno Version: v1.1.4
  • External Dependency Versions: (e.g., yfinance 0.2.52)
  • Additional Environment Details: (e.g., Python 3.10)

Possible Solutions (optional)

Suggest any ideas you might have to fix or address the issue.

Additional Context

Add any other context or details about the problem here.

@huang-sh huang-sh added the bug Something isn't working label Feb 24, 2025
@huang-sh
Copy link
Author

if I use cluade,




from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.duckduckgo import DuckDuckGoTools
from agno.tools.yfinance import YFinanceTools

web_agent = Agent(
    name="Web Agent",
    role="Search the web for information",
    model=Claude(id="claude-3-5-sonnet-20240620"),
    tools=[DuckDuckGoTools()],
    instructions="Always include sources",
    show_tool_calls=True,
    markdown=True,
)

finance_agent = Agent(
    name="Finance Agent",
    role="Get financial data",
    model=Claude(id="claude-3-5-sonnet-20240620"),
    tools=[YFinanceTools(stock_price=True, analyst_recommendations=True, company_info=True)],
    instructions="Use tables to display data",
    show_tool_calls=True,
    markdown=True,
)

agent_team = Agent(
    team=[web_agent, finance_agent],
    model=Claude(id="claude-3-5-sonnet-20240620"),
    instructions=["Always include sources", "Use tables to display data"],
    show_tool_calls=True,
    markdown=True,
)

agent_team.print_response("What's the market outlook and financial performance of AI semiconductor companies?", stream=True)

Here is the error

IndexError                                Traceback (most recent call last)
Cell In[157], line 34
     16 finance_agent = Agent(
     17     name="Finance Agent",
     18     role="Get financial data",
   (...)
     23     markdown=True,
     24 )
     26 agent_team = Agent(
     27     team=[web_agent, finance_agent],
     28     model=Claude(id="claude-3-5-sonnet-20240620"),
   (...)
     31     markdown=True,
     32 )
---> 34 agent_team.print_response("What's the market outlook and financial performance of AI semiconductor companies?", stream=True)

File ~/.conda/envs/py310/lib/python3.10/site-packages/agno/agent/agent.py:3414, in Agent.print_response(self, message, messages, audio, images, videos, stream, markdown, show_message, show_reasoning, show_full_reasoning, console, tags_to_include_in_markdown, **kwargs)
   3412 if render:
   3413     live_log.update(Group(*panels))
-> 3414 for resp in self.run(
   3415     message=message, messages=messages, audio=audio, images=images, videos=videos, stream=True, **kwargs
   3416 ):
   3417     if isinstance(resp, RunResponse) and isinstance(resp.content, str):
   3418         if resp.event == RunEvent.run_response:

File ~/.conda/envs/py310/lib/python3.10/site-packages/agno/agent/agent.py:535, in Agent._run(self, message, stream, audio, images, videos, messages, stream_intermediate_steps, **kwargs)
    533 if self.stream:
    534     model_response = ModelResponse(content="")
--> 535     for model_response_chunk in self.model.response_stream(messages=run_messages.messages):
    536         # If the model response is an assistant_response, yield a RunResponse with the content
    537         if model_response_chunk.event == ModelResponseEvent.assistant_response.value:
    538             if model_response_chunk.content is not None and model_response.content is not None:

File ~/.conda/envs/py310/lib/python3.10/site-packages/agno/models/base.py:474, in Model.response_stream(self, messages)
    471     yield from self._show_stream_tool_calls(function_calls_to_run=function_calls_to_run)
    473 # Execute function calls
--> 474 for function_call_response in self.run_function_calls(
    475     function_calls=function_calls_to_run, function_call_results=function_call_results
    476 ):
    477     yield function_call_response
    479 # Format and add results to messages

File ~/.conda/envs/py310/lib/python3.10/site-packages/agno/models/base.py:756, in Model.run_function_calls(self, function_calls, function_call_results)
    754 function_call_output: Optional[Union[List[Any], str]] = ""
    755 if isinstance(fc.result, (GeneratorType, collections.abc.Iterator)):
--> 756     for item in fc.result:
    757         function_call_output += item
    758         if fc.function.show_result:

File ~/.conda/envs/py310/lib/python3.10/site-packages/agno/agent/agent.py:2365, in Agent.get_transfer_function.<locals>._transfer_task_to_agent(task_description, expected_output, additional_information)
   2363 if self.stream and member_agent.is_streamable:
   2364     member_agent_run_response_stream = member_agent.run(member_agent_task, stream=True)
-> 2365     for member_agent_run_response_chunk in member_agent_run_response_stream:
   2366         yield member_agent_run_response_chunk.content  # type: ignore
   2367 else:

File ~/.conda/envs/py310/lib/python3.10/site-packages/agno/agent/agent.py:535, in Agent._run(self, message, stream, audio, images, videos, messages, stream_intermediate_steps, **kwargs)
    533 if self.stream:
    534     model_response = ModelResponse(content="")
--> 535     for model_response_chunk in self.model.response_stream(messages=run_messages.messages):
    536         # If the model response is an assistant_response, yield a RunResponse with the content
    537         if model_response_chunk.event == ModelResponseEvent.assistant_response.value:
    538             if model_response_chunk.content is not None and model_response.content is not None:

File ~/.conda/envs/py310/lib/python3.10/site-packages/agno/models/base.py:480, in Model.response_stream(self, messages)
    477     yield function_call_response
    479 # Format and add results to messages
--> 480 self.format_function_call_results(
    481     messages=messages, function_call_results=function_call_results, **stream_data.extra
    482 )
    484 logger.debug(f"---------- {self.get_provider()} Response Stream ----------")
    485 self._log_messages(messages)

File ~/.conda/envs/py310/lib/python3.10/site-packages/agno/models/anthropic/claude.py:455, in Claude.format_function_call_results(self, messages, function_call_results, tool_ids)
    450 fc_responses: List = []
    451 for _fc_message_index, _fc_message in enumerate(function_call_results):
    452     fc_responses.append(
    453         {
    454             "type": "tool_result",
--> 455             "tool_use_id": tool_ids[_fc_message_index],
    456             "content": _fc_message.content,
    457         }
    458     )
    459 messages.append(Message(role="user", content=fc_responses))

IndexError: list index out of range

@huang-sh
Copy link
Author

And for OpenRouter(id="openai/chatgpt-4o-latest")




from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.duckduckgo import DuckDuckGoTools
from agno.tools.yfinance import YFinanceTools
from agno.models.openrouter import OpenRouter

web_agent = Agent(
    name="Web Agent",
    role="Search the web for information",
    model=OpenRouter(id="openai/chatgpt-4o-latest"),
    tools=[DuckDuckGoTools()],
    instructions="Always include sources",
    show_tool_calls=True,
    markdown=True,
)

finance_agent = Agent(
    name="Finance Agent",
    role="Get financial data",
    model=OpenRouter(id="openai/chatgpt-4o-latest"),
    tools=[YFinanceTools(stock_price=True, analyst_recommendations=True, company_info=True)],
    instructions="Use tables to display data",
    show_tool_calls=True,
    markdown=True,
)

agent_team = Agent(
    team=[web_agent, finance_agent],
    model=OpenRouter(id="openai/chatgpt-4o-latest"),
    instructions=["Always include sources", "Use tables to display data"],
    show_tool_calls=True,
    markdown=True,
)

agent_team.print_response("What's the market outlook and financial performance of AI semiconductor companies?", stream=True)

it gives

ERROR    API status error from OpenAI API: Error code: 404 - {'error': {'message': 'No endpoints found that support
         tool use. To learn more about provider routing, visit: https://openrouter.ai/docs/provider-routing',      
         'code': 404}} 

File ~/.conda/envs/py310/lib/python3.10/site-packages/agno/models/openai/chat.py:372, in OpenAIChat.invoke_stream(self, messages)
    370 except APIStatusError as e:
    371     logger.error(f"API status error from OpenAI API: {e}")
--> 372     raise ModelProviderError(e, self.name, self.id) from e
    373 except Exception as e:
    374     logger.error(f"Error from OpenAI API: {e}")

ModelProviderError: Error code: 404 - {'error': {'message': 'No endpoints found that support tool use. To learn more about provider routing, visit: https://openrouter.ai/docs/provider-routing', 'code': 404}}

@ysolanky
Copy link
Contributor

Hello @huang-sh !

Under the hood, Agent team works by making tool calls. So the support for teams is only as good as support for tool calling for a model.

With Qwen/Qwen2.5-72B-Instruct-128K, it is not following the OpenAI specification for tool calling. Hence, the tool call does not occur. Though Qwen2.5-72B is good at tool calling, it does an excellent job when I run it locally using Ollama. The model hosted on siliconflow is following an unexpected format for function calling

With claude-3-5-sonnet-20240620 looks like there is an error on our end. I am taking a look at it.

With openai/chatgpt-4o-latest, this model does not support Tool calls. And the error is raised by openai: No endpoints found that support tool use. To learn more about provider routing, visit: https://openrouter.ai/docs/provider-routing

For best results using Agent Teams, please use models like: gpt-4o. sonnet-3.5 and gemini-2.0

@huang-sh
Copy link
Author

@ysolanky Hi, thank you very much for your reply!

@Joeao
Copy link

Joeao commented Feb 25, 2025

For best results using Agent Teams, please use models like: gpt-4o. sonnet-3.5 and gemini-2.0

Specifically using their relative model imports rather than OpenRouter.
model=OpenRouter(id="google/gemini-2.0-flash-001"), yields bad results
model=Gemini(id="gemini-2.0-flash") yields good results

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants