Skip to content

LocalLink

LocalLink(hub)

Factory creating in-process duplex pairs against one Hub.

Pass to HubClient(link=LocalLink(hub), hub=hub). Each HubClient requests one LocalLinkClient (held for the life of the process); multiple AgentClients registered through that HubClient share the connection.

Each client() call constructs a fresh endpoint and immediately hands it to Hub.attach_endpoint so the hub spawns its frame-processor task. A wire transport follows the same shape — its connect handler calls Hub.attach_endpoint once the connection is up.

Source code in autogen/beta/network/transport/local.py
def __init__(self, hub: "Hub") -> None:
    # __init__ stores params; side effects deferred to client().
    self._hub = hub

hub property #

hub

client #

client()

Create a fresh client+endpoint pair; attach to the hub.

Source code in autogen/beta/network/transport/local.py
def client(self) -> LocalLinkClient:
    """Create a fresh client+endpoint pair; attach to the hub."""
    endpoint_id = make_id()
    c2h: asyncio.Queue[Frame | None] = asyncio.Queue()
    h2c: asyncio.Queue[Frame | None] = asyncio.Queue()
    endpoint = LocalLinkEndpoint(endpoint_id=endpoint_id, client_to_hub=c2h, hub_to_client=h2c)
    client = LocalLinkClient(endpoint_id=endpoint_id, client_to_hub=c2h, hub_to_client=h2c)
    self._hub.attach_endpoint(endpoint)
    return client