From f211fadc2b42d4a63ecea0b8292b44d526225d5f Mon Sep 17 00:00:00 2001 From: William FH <13333726+hinthornw@users.noreply.github.com> Date: Fri, 5 Dec 2025 11:56:40 -0800 Subject: [PATCH] release(sdk-py): Configure loopback client (#6536) Will defer defaulting to deferred registration until a later date. --- libs/sdk-py/langgraph_sdk/__init__.py | 2 +- libs/sdk-py/langgraph_sdk/client.py | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/libs/sdk-py/langgraph_sdk/__init__.py b/libs/sdk-py/langgraph_sdk/__init__.py index c9b864658..635ce7173 100644 --- a/libs/sdk-py/langgraph_sdk/__init__.py +++ b/libs/sdk-py/langgraph_sdk/__init__.py @@ -1,6 +1,6 @@ from langgraph_sdk.auth import Auth from langgraph_sdk.client import get_client, get_sync_client -__version__ = "0.2.12" +__version__ = "0.2.13" __all__ = ["Auth", "get_client", "get_sync_client"] diff --git a/libs/sdk-py/langgraph_sdk/client.py b/libs/sdk-py/langgraph_sdk/client.py index 3f7a3d5e8..d28ea626f 100644 --- a/libs/sdk-py/langgraph_sdk/client.py +++ b/libs/sdk-py/langgraph_sdk/client.py @@ -190,7 +190,8 @@ def get_client( url: Base URL of the LangGraph API. - If `None`, the client first attempts an in-process connection via ASGI transport. - If that fails, it falls back to `http://localhost:8123`. + If that fails, it defers registration until after app initialization. This + only works if the client is used from within the Agent server. api_key: API key for authentication. Can be: - A string: use this exact API key @@ -255,19 +256,22 @@ def get_client( transport: httpx.AsyncBaseTransport | None = None if url is None: + url = "http://api" if os.environ.get("__LANGGRAPH_DEFER_LOOPBACK_TRANSPORT") == "true": transport = get_asgi_transport()(app=None, root_path="/noauth") _registered_transports.append(transport) - url = "http://api" else: try: from langgraph_api.server import app # type: ignore - url = "http://api" - transport = get_asgi_transport()(app, root_path="/noauth") except Exception: - url = "http://localhost:8123" + logger.debug( + "Failed to connect to in-process LangGraph server. Deferring configuration.", + exc_info=True, + ) + transport = get_asgi_transport()(app=None, root_path="/noauth") + _registered_transports.append(transport) if transport is None: transport = httpx.AsyncHTTPTransport(retries=5)