Skip to content

Autogen MCP : Error: unhandled errors in a TaskGroup (1 sub-exception) using Autogen and gpt-4o. #6096

@appuk45

Description

@appuk45

What happened?

Describe the bug
I faced a bug when I tried to use Autogen with the Shopify MCP server. The model calls the tool correctly, including the correct query. It is working fine when tried using langchain and MCP Inspector.

To Reproduce

import asyncio

from autogen_agentchat.agents import AssistantAgent
from autogen_ext.models.openai import OpenAIChatCompletionClient
from autogen_ext.tools.mcp import StdioServerParams, mcp_server_tools
from autogen_agentchat.ui import Console
import os
from dotenv import load_dotenv
load_dotenv()

async def main() -> None:
# Get the fetch tool from mcp-server-fetch.
shopify_mcp_server = StdioServerParams(command="node", args=["shopify-mcp-server/build/index.js"],env={'SHOPIFY_ACCESS_TOKEN':#shopify_access_token ,'MYSHOPIFY_DOMAIN':#shopify_domain})
tools = await mcp_server_tools(shopify_mcp_server)

# Create an agent that can use the fetch tool.
model_client = OpenAIChatCompletionClient(model="gpt-4o",api_key=#api_key)
agent = AssistantAgent(name="shopify_assistant", model_client=model_client, tools=tools, reflect_on_tool_use=True)  # type: ignore
# Let the agent fetch the content of a URL and summarize it.
await Console (agent.run_stream(task="show order #1001"))
# print(result.messages[-1].content)

asyncio.run(main())

Current Behavior
When I asked to show an order of order number 100 it is showing this output:
Shopify MCP Server running on stdio
---------- user ----------
show order 100
---------- shopify_assistant ----------
[FunctionCall(id='call_2gEpQguofxe0Z5cLkLYNg3yk', arguments='{"query":"name:100","first":1}', name='get-orders')]
Shopify MCP Server running on stdio
---------- shopify_assistant ----------
[FunctionExecutionResult(content='Error: unhandled errors in a TaskGroup (1 sub-exception)', name='get-orders', call_id='call_2gEpQguofxe0Z5cLkLYNg3yk', is_error=True)]
---------- shopify_assistant ----------
It seems there was an error processing your request to fetch order 100. Could you please verify the order number or check if there are any connectivity issues? Let me know if you would like me to try again or assist further.

When I give the orderId instead or order_number the model is fetching the correct result. But for most of the queries the same issue is happening.

Which packages was the bug in?

Python Extensions (autogen-ext)

AutoGen library version.

Python dev (main branch)

Other library version.

No response

Model used

gpt-4o

Model provider

OpenAI

Other model provider

No response

Python version

None

.NET version

None

Operating system

Windows

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions