release(sdk-py): Configure loopback client (#6536)

Will defer defaulting to deferred registration until a later date.
This commit is contained in:
William FH
2025-12-05 11:56:40 -08:00
committed by GitHub
parent 024468c5dd
commit f211fadc2b
2 changed files with 10 additions and 6 deletions
+1 -1
View File
@@ -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"]
+9 -5
View File
@@ -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)