BuildRiot
Sign in

Article · AI

Microsoft Agent Framework Python 1.23.0 ties MCP recovery to client ownership

Python 1.23.0 includes a breaking MCP SDK migration and a change to connection-loss recovery. This guide covers dependency checks, SDK changes, client ownership, and proposed tests for recovery and shutdown.

A sunlit miniature workbench shows connector adapters, a blue housing with an attached recovery arm, and lavender plugs arranged for reconnection and shutdown tests.
Illustration: BuildRiot (AI-generated)

Key takeaway

Client ownership determines whether Agent Framework can replace a failed connection or must return control to the application. Migration tests should distinguish reconnection from operation replay and check that cleanup finishes after cancellation.

Start with the connection replacement boundary

Microsoft Agent Framework Python 1.23.0 introduced ownership-aware connection recovery alongside a breaking Model Context Protocol (MCP) migration on October 22, 2026. Pull request #9583 says the recovery change requires replacement of an ended caller-owned client before another remote procedure call reaches it. The practical question is which component has permission to replace a failed connection. Sources: Microsoft

The migration spans Core, AG-UI, declarative, hosting, and other packages; several consumers raise their Core minimum to 1.23. The release also lists lifecycle documentation, task-context isolation, and removal of DevUI’s stale-connection workaround. Treat the upgrade as a coordinated dependency change and preserve the complete lockfile before investigating transport failures. Sources: Microsoft

MCP 2.x names the Python SDK generation, not a single wire-protocol version. Microsoft’s sample documentation describes negotiation through server/discover with modern servers. Older peers use a fallback to initialize. Include both generations in migration tests if the application uses them. Sources: Microsoft

Check context entry in a clean installation

Discussion #9613 describes a minimal environment where Core and MCP installed, but context entry failed because subscription recovery required Tenacity. The service operator’s assistant-authored report describes success after adding Tenacity 9.1.4. It ran on Windows with Python 3.12.14 and gives the following installation command. Sources: GitHub

python -m pip install \
  "agent-framework-core==1.23.0" \
  "mcp==2.3.0" \
  "tenacity==9.1.4"

The reported smoke test made one public read, exposed only get_creation, disabled prompt loading, and checked a three-field result projection. It used no model or credentials and reportedly exited its context normally. The test covered installation and adapter behavior, not disconnect recovery. An import-only check would miss the reported context-entry failure. Sources: GitHub

  1. Create a clean environment with Core 1.23.0 and MCP 2.3.0, the versions in the report. Attempt context entry and preserve the complete exception chain.
  2. Create a separate environment adding the reported Tenacity 9.1.4 dependency. Repeat the same operation.
  3. Repeat with the standard framework installation and compare resolved dependencies.
  4. Record package versions, dependency consistency results, Python patch version, operating system, and server version for each run. Sources: GitHub

Audit SDK objects and error classification

The compatibility pull request moves MCP integration to httpx2, updates hosting and conversion code, and removes legacy Tasks APIs. Microsoft documents that WebSocket transport was removed in Python 1.23. Microsoft’s sample documentation says MCP Tasks remain unsupported. Audit direct SDK use alongside framework constructors, including custom parsers, mocks, authentication adapters, and exception handlers. Sources: Microsoft

Issue #7446 identifies the interface changes in the table below, including renamed attributes and numeric timeout values. Use the issue as an audit checklist rather than a final release specification. The attribute changes concern SDK objects. Check serialized payloads and server tool schemas separately before renaming application JSON keys. Sources: Microsoft

Table

Direct SDK migration audit

Earlier usageMigration target
McpErrorMCPError
Older error-construction shapeCode, message, and optional data arguments
Timedelta-based read timeoutNumeric seconds
mimeTypemime_type
structuredContentstructured_content
isErroris_error
inputSchemainput_schema
Issue #7446 identifies these SDK changes; check application payloads separately.Source: Microsoft

The SDK migration documentation assigns different errors to HTTP 404 responses depending on whether a session exists. An established session yields code -32600 for termination; a missing session yields -32601 for not found. Other HTTP 4xx and 5xx responses produce -32603 for a server error response. Handlers expecting positive 32600 or the old transport-context HTTPStatusError path no longer match those cases. Test ordinary HTTP errors, expired sessions, and definitive connection loss separately. Sources: Model Context Protocol

Microsoft’s documentation names different libraries for custom HTTP clients. Microsoft Learn’s cookie guidance names httpx.AsyncClient. The migration pull request moves MCP transport support to httpx2. Verify accepted client types against the pinned implementation before copying that example. Sources: Microsoft Learn, Microsoft

Choose the owner before adding recovery

Microsoft documents framework-owned construction through a URL for HTTP or a command for standard input/output transport, or stdio. For caller ownership, enter mcp.Client first, pass it through mcp_client, and keep it entered throughout the agent or workflow run. Agent Framework does not enter, close, replace, or recreate that client. Microsoft also prohibits combining mcp_client with a URL, command, headers, or transport-construction options. Sources: Microsoft Learn, Microsoft

The following scaffolds assume a local server exposing an echo tool. The first delegates lifecycle management to the framework; the second follows Microsoft’s documented caller-owned nesting. The scaffolds and proposed acceptance tests have not been executed. Python 1.23.0 includes the ownership-aware recovery change: an ended caller-owned client requires replacement before another remote procedure call reaches it. The architectural contracts describe the moving main branch. Current Microsoft Learn and sample documentation also should not be treated as specifications for the 1.23.0 release. Check constructor options, client types, session behavior, and cancellation details against the pinned version. Establish normal entry, invocation, and exit before introducing failures. Sources: Microsoft, Microsoft Learn

from agent_framework import MCPStreamableHTTPTool

async def framework_owned(url):
    async with MCPStreamableHTTPTool(
        name="probe",
        url=url,
        load_prompts=False,
    ) as tool:
        return await tool.call_tool("echo", text="hello")
from mcp import Client
from agent_framework import MCPStreamableHTTPTool

async def caller_owned(url):
    async with Client(server=url) as client:
        async with MCPStreamableHTTPTool(
            name="probe",
            mcp_client=client,
            load_prompts=False,
        ) as tool:
            result = await tool.call_tool("echo", text="hello")

        # Test client usability here, before leaving its owning context.
        return result

Microsoft’s architectural guidance says both high-level ownership modes use mcp.Client and have no session. MCPTool.session applies only to the deprecated low-level ClientSession path. Microsoft documents that caller-supplied low-level sessions remain uncached. They receive no automatic retries for missing-resource or missing-template responses. Application ownership allows a client lifetime shared across operations. The application handles replacement and orderly closure. Sources: Microsoft

Separate reconnection from operation replay

Pull request #9583 guards discovery, liveness checks, tool calls, and prompt calls against definitive caller-owned connection loss. It describes a replacement error before reconnect logging or a second remote procedure call to the ended client, while leaving framework-owned recovery unchanged. Test each guarded path independently, including discovery and liveness checks. Sources: Microsoft

Use a controllable local server and assign each invocation a unique identifier. Log receipt, completion, connection identity, and cleanup so reconnect attempts cannot hide duplicate work. The table below proposes checks for both ownership modes, including a write that completes just before its response disappears.

Table

Proposed connection ownership acceptance tests

ScenarioFramework-owned checkCaller-owned check
Normal read and exitCheck entry and cleanupCheck client usability after wrapper exit
Definitive loss during discoveryRecord replacement and discovery attemptsCheck replacement error and absence of a substitute or second call
Loss during tool or prompt callRecord reconnect and operation attempts separatelyCheck that replacement is required
Write completes; response is lostDetect duplicates by invocation IDDetect duplicates by invocation ID
Application supplies replacementNot applicableCheck operation with a newly entered client and wrapper
Tool error with live transportCheck for transport-loss misclassificationCheck that the healthy client is preserved
Use these proposed checks to exercise client ownership, operation replay, and cleanup.Sources: Microsoft Learn, Microsoft

Replacing a connection and replaying an operation are separate events. An exception after a write does not prove the write failed. For write tools, test idempotency and expose duplicate execution before enabling application retries.

Make cancellation and cleanup observable

Microsoft’s architectural guidance says canceled queued connection requests should be skipped, while cancellation before acceptance of a new connection triggers teardown. Canceling a redundant connect must preserve an established connection, and canceling a close waiter must not interrupt teardown. Use barriers or events to reach these boundaries deterministically instead of relying on short sleeps. Sources: Microsoft

  1. Cancel a queued connection request before setup starts.
  2. Cancel after transport establishment but before successful setup is accepted.
  3. Cancel a redundant connection request while another connection remains healthy.
  4. Cancel an in-flight slow tool call.
  5. Cancel the task awaiting close while teardown is blocked.
  6. Shut down with active calls, then repeat shutdown.

Count transport entries and exits, outstanding tasks, HTTP-client closures, and stdio child-process exits. Give cleanup an explicit deadline and fail the test if resources remain. For caller-owned clients, close the wrapper, check that the client still works, then exit its owning context. Also reverse that order deliberately and check for a clear failure without hidden replacement.

Run the matrix across HTTP and stdio, modern and legacy peers, and any retained low-level session path. Include multiple wrappers sharing one caller-owned client if that matches production. Record recovery and cleanup durations, duplicate invocations, and leaked resources separately from normal connection and call latency. Use those observations as migration acceptance criteria, including explicit checks for shutdown completion.

Attribution

Sources

  1. 1MicrosoftRelease python-1.23.0Source published (UTC)
  2. 2Microsoft LearnUsing MCP Tools
  3. 3MicrosoftPython: Make MCP connection-loss recovery ownership-aware
  4. 4MicrosoftPython: [BREAKING] Add MCP 2.x compatibility foundation
  5. 5GitHubMCPStreamableHTTPTool: a three-field result projection, with explicit dependencies and host-retention limits
  6. 6Model Context ProtocolPython SDK migration documentation
  7. 7MicrosoftPython: Support mcp 2.x (Python SDK): pin blocks mcp 2.0.0
  8. 8MicrosoftAgent Framework Python MCP samples
  9. 9MicrosoftAgent Framework Python Core architectural guidance

Read the original source for full details and context.

Report a problem

Links, dates or what you expected. Do not include passwords or private data.

More on AI

All AI stories
Microsoft Agent Framework Python 1.23.0 ties MCP recovery to client ownership · BuildRiot