-
Notifications
You must be signed in to change notification settings - Fork 6.9k
fixes the issues where exceptions from MCP server tools aren't serial… #6482
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
Conversation
…ized properly Signed-off-by: Peter Jausovec <peter.jausovec@solo.io>
This is how the non-error/exc response looks like now:
And an error response/exception (the text value is coming from the mcp server tool):
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6482 +/- ##
==========================================
+ Coverage 79.23% 79.29% +0.06%
==========================================
Files 225 225
Lines 16666 16679 +13
==========================================
+ Hits 13205 13226 +21
+ Misses 3461 3453 -8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Hi @peterj , Can you add a minimum repro example in the PR description, thanks. Edit: able to repro # server.py
import logging
from mcp.server.fastmcp import FastMCP
# Create an MCP server
mcp = FastMCP("Demo")
# create an error agent that raises an error
@mcp.tool()
async def error_agent(task: str) -> str:
"""An agent that raises an error"""
raise Exception("This is an error agent")
if __name__ == "__main__":
mcp.run() from autogen_ext.models.openai import OpenAIChatCompletionClient
from autogen_ext.tools.mcp import StdioServerParams, mcp_server_tools
from autogen_agentchat.agents import AssistantAgent
from autogen_core import CancellationToken
from autogen_agentchat.ui import Console
async def main() -> None:
# Setup server params for local filesystem access
fetch_mcp_server = StdioServerParams(command="/pathtopython/python", args=["pathtoserver/server.py"])
tools = await mcp_server_tools(fetch_mcp_server)
# Create an agent that can use the fetch tool.
model_client = OpenAIChatCompletionClient(model="gpt-4o")
agent = AssistantAgent(name="fetcher", model_client=model_client, tools=tools, reflect_on_tool_use=True)
await Console(agent.run_stream(task="raise an error withthe errror agent", cancellation_token=CancellationToken()))
await main() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR is looking good overall.
Let me know if you need any help addressing the pyright/mypy/codecov remaining sections.
Signed-off-by: Peter Jausovec <peter.jausovec@solo.io>
will fix these |
Signed-off-by: Peter Jausovec <peter.jausovec@solo.io>
…j/fix6481 * 'peterj/fix6481' of github.com:peterj/autogen: improve Otel tracing (microsoft#6499) Fix header icons focus and hover style for better accessibility (microsoft#6409)
Signed-off-by: Peter Jausovec <peter.jausovec@solo.io>
Signed-off-by: Peter Jausovec <peter.jausovec@solo.io>
one of these days I'll be able to fix all lining errors :) |
Haha, This is mostly ready to get merged, thanks again! |
…ized properly
Why are these changes needed?
The exceptions thrown by MCP server tools weren't being serialized properly - the user would see
[{}, {}, ... {}]
instead of an actual error/exception message.Related issue number
Fixes #6481
Checks