From 897a4963daefa2ae0ef146290abcdbb58fc4a394 Mon Sep 17 00:00:00 2001 From: Eric Hansen Date: Wed, 4 Feb 2026 12:06:52 -0600 Subject: [PATCH] fix: Use correct AzureOpenAIChatClient.as_agent() API The MCP notebook example used create_agent() which does not exist on AzureOpenAIChatClient, causing runtime failures: AttributeError: 'AzureOpenAIChatClient' object has no attribute 'create_agent' Replace create_agent() with as_agent() per the Microsoft Agent Framework API. The as_agent() method also requires a name parameter, which has been added. The create_agent -> as_agent rename was a breaking change introduced in: - Python: v1.0.0b260116 (Jan 16, 2026) - PR #3249 - .NET: v1.0.0-preview.260121.1 (Jan 21, 2026) - PR #3222 Ref: https://github.com/microsoft/agent-framework/releases --- labs/model-context-protocol/model-context-protocol.ipynb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/labs/model-context-protocol/model-context-protocol.ipynb b/labs/model-context-protocol/model-context-protocol.ipynb index ba864150..1e021458 100644 --- a/labs/model-context-protocol/model-context-protocol.ipynb +++ b/labs/model-context-protocol/model-context-protocol.ipynb @@ -471,7 +471,8 @@ " api_key=api_key,\n", " api_version=inference_api_version,\n", " )\n", - " agent = chatClient.create_agent(\n", + " agent = chatClient.as_agent(\n", + " name=\"WeatherAgent\",\n", " instructions=\"You are a helpful weather agent.\",\n", " tools=[mcp_tool],\n", " # deployment_name=models_config[0]['name'],\n", @@ -881,4 +882,4 @@ }, "nbformat": 4, "nbformat_minor": 2 -} +} \ No newline at end of file