-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Description
Upgrading to last build 0116 my agent is failing when using local mcp.
Specifically I'm using an AzureAIClient (v2) that is connecting to a local mcp server which has a method: getAccountsByUserName(userName).
It seems the agent framework is sending the wrong param to the mcp server.
My agent on AgentService V2 is correctly requesting a tool call win userName=bob.user@contoso.com.
Agent framework isn't sending "bob.user@contoso.com" as tool param to the mcp server. Instead , it's sending sending the OpenResponse resp.id value ( see log).
This is the log from my mcp server (fastmcp):
This is the trace from foundry portal:
Additional Info:
if I switch to AzureOpenAIClient it works, if I move back to 0107 version it works also with AzureAIClient
Code Sample
account_agent = AccountAgent(
azure_ai_client=azure_ai_client,
account_mcp_server_url= f"{account_mcp_server_url}/mcp"
)
# Build the agent framework agent
agent = await account_agent.build_af_agent()
# Execute a query
query = "How much I have on my account?"
print(f"\nUser: {query}")
print("Agent: ", end="", flush=True)
response_chunks = []
async for chunk in agent.run_stream(query):
if chunk.text:
print(chunk.text, end="", flush=True)
response_chunks.append(chunk.text)
print("\n")
# Verify we got a response
full_response = "".join(response_chunks)
assert len(full_response) > 0, "Agent should return a response"
------------------------------
class AccountAgent :
instructions = """
you are a personal financial advisor who help the user to retrieve information about their bank accounts.
Always use markdown to format your response.
Always use the below logged user details to retrieve account info:
{user_mail}
"""
name = "AccountAgent"
description = "This agent manages user accounts related information such as balance, credit cards."
def __init__(self, azure_ai_client: AzureAIClient, account_mcp_server_url: str):
self.azure_ai_client = azure_ai_client
self.account_mcp_server_url = account_mcp_server_url
async def build_af_agent(self)-> ChatAgent:
logger.info("Initializing Account Agent connection for account api ")
user_mail="bob.user@contoso.com"
full_instruction = AccountAgent.instructions.format(user_mail=user_mail)
# account_mcp_server = MCPStreamableHTTPTool(
# name="Account MCP server client",
# url=self.account_mcp_server_url,
# approval_mode = { "always_require_approval": ["getAccountsByUserName"] })
account_mcp_server = MCPStreamableHTTPTool(
name="Account MCP server client",
url=self.account_mcp_server_url)
logger.info("Initializing Account MCP server tools ")
await account_mcp_server.connect()
return ChatAgent(
chat_client=self.azure_ai_client,
instructions=full_instruction,
name=AccountAgent.name,
tools=[account_mcp_server]
)Error Messages / Stack Traces
from MCP server:
INFO: 127.0.0.1:53606 - "POST /mcp/mcp HTTP/1.1" 200 OK
2026-01-19 16:47:56,839 | INFO | mcp.server.lowlevel.server | Processing request of type CallToolRequest
[01/19/26 16:47:56] ERROR Error calling tool 'getAccountsByUserName' tool_manager.py:233
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ c:\Users\dantelmo\code\ai-experiments\agent-openai-python-banking-assistant\app\business-api\pyt │
│ hon\transaction\.venv\Lib\site-packages\fastmcp\tools\tool_manager.py:224 in call_tool │
│ │
│ 221 │ │ │ │ raise NotFoundError(f"Tool {key!r} not found") │
│ 222 │ │ │ │
│ 223 │ │ │ try: │
│ ❱ 224 │ │ │ │ return await tool.run(arguments) │
│ 225 │ │ │ │
│ 226 │ │ │ # raise ToolErrors as-is │
│ 227 │ │ │ except ToolError as e: │
│ │
│ c:\Users\dantelmo\code\ai-experiments\agent-openai-python-banking-assistant\app\business-api\pyt │
│ hon\transaction\.venv\Lib\site-packages\fastmcp\tools\tool.py:314 in run │
│ │
│ 311 │ │ │ arguments[context_kwarg] = get_context() │
│ 312 │ │ │
│ 313 │ │ type_adapter = get_cached_typeadapter(self.fn) │
│ ❱ 314 │ │ result = type_adapter.validate_python(arguments) │
│ 315 │ │ │
│ 316 │ │ if inspect.isawaitable(result): │
│ 317 │ │ │ result = await result │
│ │
│ c:\Users\dantelmo\code\ai-experiments\agent-openai-python-banking-assistant\app\business-api\pyt │
│ hon\transaction\.venv\Lib\site-packages\pydantic\type_adapter.py:421 in validate_python │
│ │
│ 418 │ │ │ │ code='validate-by-alias-and-name-false', │
│ 419 │ │ │ ) │
│ 420 │ │ │
│ ❱ 421 │ │ return self.validator.validate_python( │
│ 422 │ │ │ object, │
│ 423 │ │ │ strict=strict, │
│ 424 │ │ │ from_attributes=from_attributes, │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
ValidationError: 1 validation error for call[get_accounts_by_user_name]
conversation_id
Unexpected keyword argument [type=unexpected_keyword_argument,
input_value='resp_0aee1c200d923f7a006...a5c81969eda589d9a02e0dc', input_type=str]
For further information visit https://errors.pydantic.dev/2.11/v/unexpected_keyword_argumentPackage Versions
"agent-framework-core==1.0.0b260116", "agent-framework-azure-ai==1.0.0b260116"
Python Version
No response
Additional Context
if I switch to AzureOpenAIClient it works, if I move back to 0107 version it works also with AzureAIClient
Metadata
Metadata
Assignees
Labels
Type
Projects
Status