I’m not sure if this is a bug or if there is another way to fix it. When using reasoning models with async tools (MCP tools), the arun() method returns a coroutine instead of an async generator, causing this error : ‘async for’ requires an object with _aiter_ method, got coroutine errors.
How to reproduce:
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.mcp import MCPTools
# Setup MCP tools (async tools)
async with MCPTools("npx -y @modelcontextprotocol/server-brave-search") as mcp_tools:
agent = Agent(
model=OpenAIChat(id="gpt-4o"),
tools=[mcp_tools],
reasoning=True, # This causes the issue
markdown=True,
)
# This fails with async reasoning
response = await agent.arun("What is the weather?")
# Error: 'async for' requires an object with __aiter__ method, got coroutine
Expected Behavior
When reasoning=True with async tools, agent.arun() should return an async generator that can be iterated with async for.
Actual Behavior
When reasoning=True with async tools, agent.arun() returns a coroutine that cannot be iterated, causing the error.